From 025ac2a53b5a568b81042cf3a1038fee82b67edb Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 15 Aug 2020 17:41:38 +0900 Subject: [PATCH] Support embedded struct --- cmd/generator/main.go | 311 +++++ encode_compile.go | 404 +----- encode_opcode.go | 1078 +-------------- encode_optype.go | 2929 +++++++++++++++++++++++++++++++++++++++++ encode_test.go | 27 +- encode_vm.go | 434 ++++-- 6 files changed, 3650 insertions(+), 1533 deletions(-) create mode 100644 cmd/generator/main.go create mode 100644 encode_optype.go diff --git a/cmd/generator/main.go b/cmd/generator/main.go new file mode 100644 index 0000000..b94bef1 --- /dev/null +++ b/cmd/generator/main.go @@ -0,0 +1,311 @@ +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "path/filepath" + "runtime" + "strings" + "text/template" +) + +type opType struct { + Op string + IndentOp string + Code string +} + +type headType struct { + Head string + PtrHead string + AnonymousHead string + AnonymousPtrHead string + OmitEmptyHead string + OmitEmptyPtrHead string +} + +type fieldType struct { + Field string + OmitEmptyField string +} + +func _main() error { + tmpl, err := template.New("").Parse(`// Code generated by cmd/generator. DO NOT EDIT! +package json + +type codeType int + +const ( +{{- range $index, $type := .CodeTypes }} + code{{ $type }} codeType = {{ $index }} +{{- end }} +) + +type opType int + +const ( +{{- range $index, $type := .OpTypes }} + op{{ $type.Op }} opType = {{ $index }} +{{- end }} +) + +func (t opType) String() string { + switch t { +{{- range $type := .OpTypes }} + case op{{ $type.Op }}: + return "{{ $type.Op }}" +{{- end }} + } + return "" +} + +func (t opType) codeType() codeType { + switch t { +{{- range $type := .OpTypes }} + case op{{ $type.Op }}: + return code{{ $type.Code }} +{{- end }} + } + return codeOp +} + +func (t opType) toIndent() opType { + switch t { +{{- range $type := .OpTypes }} + case op{{ $type.Op }}: + return op{{ $type.IndentOp }} +{{- end }} + } + return t +} + +func (t opType) headToPtrHead() opType { + switch t { +{{- range $type := .HeadTypes }} + case op{{ $type.Head }}: + return op{{ $type.PtrHead }} + case op{{ $type.AnonymousHead }}: + return op{{ $type.AnonymousPtrHead }} + case op{{ $type.OmitEmptyHead }}: + return op{{ $type.OmitEmptyPtrHead }} +{{- end }} + } + return t +} + +func (t opType) headToAnonymousHead() opType { + switch t { +{{- range $type := .HeadTypes }} + case op{{ $type.Head }}: + return op{{ $type.AnonymousHead }} + case op{{ $type.PtrHead }}: + return op{{ $type.AnonymousPtrHead }} +{{- end }} + } + return t +} + +func (t opType) headToOmitEmptyHead() opType { + switch t { +{{- range $type := .HeadTypes }} + case op{{ $type.Head }}: + return op{{ $type.OmitEmptyHead }} + case op{{ $type.PtrHead }}: + return op{{ $type.OmitEmptyPtrHead }} +{{- end }} + } + return t +} + +func (t opType) ptrHeadToHead() opType { + switch t { +{{- range $type := .HeadTypes }} + case op{{ $type.PtrHead }}: + return op{{ $type.Head }} + case op{{ $type.AnonymousPtrHead }}: + return op{{ $type.AnonymousHead }} + case op{{ $type.OmitEmptyPtrHead }}: + return op{{ $type.OmitEmptyHead }} +{{- end }} + } + return t +} + +func (t opType) fieldToOmitEmptyField() opType { + switch t { +{{- range $type := .FieldTypes }} + case op{{ $type.Field }}: + return op{{ $type.OmitEmptyField }} +{{- end }} + } + return t +} + +`) + if err != nil { + return err + } + codeTypes := []string{ + "Op", + "ArrayHead", + "ArrayElem", + "SliceHead", + "SliceElem", + "MapHead", + "MapKey", + "MapValue", + "StructFieldRecursive", + "StructField", + } + primitiveTypes := []string{ + "int", "int8", "int16", "int32", "int64", + "uint", "uint8", "uint16", "uint32", "uint64", + "float32", "float64", "bool", "string", + } + primitiveTypesUpper := []string{} + for _, typ := range primitiveTypes { + primitiveTypesUpper = append(primitiveTypesUpper, strings.ToUpper(string(typ[0]))+typ[1:]) + } + opTypes := []opType{ + {"End", "EndIndent", "Op"}, + {"Interface", "InterfaceIndent", "Op"}, + {"Ptr", "PtrIndent", "Op"}, + {"MarshalJSON", "MarshalJSONIndent", "Op"}, + {"MarshalText", "MarshalTextIndent", "Op"}, + {"SliceHead", "SliceHeadIndent", "SliceHead"}, + {"RootSliceHead", "RootSliceHeadIndent", "SliceHead"}, + {"SliceElem", "SliceElemIndent", "SliceElem"}, + {"RootSliceElem", "RootSliceElemIndent", "SliceElem"}, + {"SliceEnd", "SliceEndIndent", "Op"}, + {"ArrayHead", "ArrayHeadIndent", "ArrayHead"}, + {"ArrayElem", "ArrayElemIndent", "ArrayElem"}, + {"ArrayEnd", "ArrayEndIndent", "Op"}, + {"MapHead", "MapHeadIndent", "MapHead"}, + {"MapHeadLoad", "MapHeadLoadIndent", "MapHead"}, + {"RootMapHead", "RootMapHeadIndent", "MapHead"}, + {"MapKey", "MapKeyIndent", "MapKey"}, + {"RootMapKey", "RootMapKeyIndent", "MapKey"}, + {"MapValue", "MapValueIndent", "MapValue"}, + {"MapEnd", "MapEndIndent", "Op"}, + {"StructFieldHead", "StructFieldHeadIndent", "StructField"}, + {"StructFieldHeadOmitEmpty", "StructFieldHeadOmitEmptyIndent", "StructField"}, + {"StructFieldAnonymousHead", "StructFieldAnonymousHeadIndent", "StructField"}, + {"StructFieldPtrHead", "StructFieldPtrHeadIndent", "StructField"}, + {"StructFieldPtrHeadOmitEmpty", "StructFieldPtrHeadOmitEmptyIndent", "StructField"}, + {"StructFieldPtrAnonymousHead", "StructFieldPtrAnonymousHeadIndent", "StructField"}, + {"StructField", "StructFieldIndent", "StructField"}, + {"StructFieldOmitEmpty", "StructFieldOmitEmptyIndent", "StructField"}, + {"StructFieldRecursive", "StructFieldRecursiveIndent", "StructFieldRecursive"}, + {"StructEnd", "StructEndIndent", "StructField"}, + {"StructAnonymousEnd", "StructAnonymousEndIndent", "StructField"}, + } + for _, typ := range primitiveTypesUpper { + opTypes = append(opTypes, opType{ + Op: typ, + IndentOp: fmt.Sprintf("%sIndent", typ), + Code: "Op", + }) + } + for _, prefix := range []string{ + "StructFieldHead", + "StructFieldHeadOmitEmpty", + "StructFieldAnonymousHead", + "StructFieldPtrHead", + "StructFieldPtrHeadOmitEmpty", + "StructFieldPtrAnonymousHead", + "StructField", + "StructFieldOmitEmpty", + } { + for _, typ := range primitiveTypesUpper { + opTypes = append(opTypes, opType{ + Op: fmt.Sprintf("%s%s", prefix, typ), + IndentOp: fmt.Sprintf("%s%sIndent", prefix, typ), + Code: "StructField", + }) + } + } + for _, typ := range opTypes { + opTypes = append(opTypes, opType{ + Op: typ.IndentOp, + IndentOp: typ.IndentOp, + Code: typ.Code, + }) + } + base := headType{ + Head: "StructFieldHead", + PtrHead: "StructFieldPtrHead", + AnonymousHead: "StructFieldAnonymousHead", + AnonymousPtrHead: "StructFieldPtrAnonymousHead", + OmitEmptyHead: "StructFieldHeadOmitEmpty", + OmitEmptyPtrHead: "StructFieldPtrHeadOmitEmpty", + } + headTypes := []headType{base} + for _, prim := range primitiveTypesUpper { + headTypes = append(headTypes, headType{ + Head: fmt.Sprintf("%s%s", base.Head, prim), + PtrHead: fmt.Sprintf("%s%s", base.PtrHead, prim), + AnonymousHead: fmt.Sprintf("%s%s", base.AnonymousHead, prim), + AnonymousPtrHead: fmt.Sprintf("%s%s", base.AnonymousPtrHead, prim), + OmitEmptyHead: fmt.Sprintf("%s%s", base.OmitEmptyHead, prim), + OmitEmptyPtrHead: fmt.Sprintf("%s%s", base.OmitEmptyPtrHead, prim), + }) + } + for _, typ := range headTypes { + headTypes = append(headTypes, headType{ + Head: fmt.Sprintf("%sIndent", typ.Head), + PtrHead: fmt.Sprintf("%sIndent", typ.PtrHead), + AnonymousHead: fmt.Sprintf("%sIndent", typ.AnonymousHead), + AnonymousPtrHead: fmt.Sprintf("%sIndent", typ.AnonymousPtrHead), + OmitEmptyHead: fmt.Sprintf("%sIndent", typ.OmitEmptyHead), + OmitEmptyPtrHead: fmt.Sprintf("%sIndent", typ.OmitEmptyPtrHead), + }) + } + + baseField := fieldType{ + Field: "StructField", + OmitEmptyField: "StructFieldOmitEmpty", + } + fieldTypes := []fieldType{baseField} + for _, prim := range primitiveTypesUpper { + fieldTypes = append(fieldTypes, fieldType{ + Field: fmt.Sprintf("%s%s", baseField.Field, prim), + OmitEmptyField: fmt.Sprintf("%s%s", baseField.OmitEmptyField, prim), + }) + } + for _, typ := range fieldTypes { + fieldTypes = append(fieldTypes, fieldType{ + Field: fmt.Sprintf("%sIndent", typ.Field), + OmitEmptyField: fmt.Sprintf("%sIndent", typ.OmitEmptyField), + }) + } + + var b bytes.Buffer + if err := tmpl.Execute(&b, struct { + CodeTypes []string + OpTypes []opType + HeadTypes []headType + FieldTypes []fieldType + }{ + CodeTypes: codeTypes, + OpTypes: opTypes, + HeadTypes: headTypes, + FieldTypes: fieldTypes, + }); err != nil { + return err + } + path := filepath.Join(repoRoot(), "encode_optype.go") + return ioutil.WriteFile(path, b.Bytes(), 0644) +} + +func repoRoot() string { + _, file, _, _ := runtime.Caller(0) + relativePathFromRepoRoot := filepath.Join("cmd", "generator") + return strings.TrimSuffix(filepath.Dir(file), relativePathFromRepoRoot) +} + +func main() { + if err := _main(); err != nil { + panic(err) + } +} diff --git a/encode_compile.go b/encode_compile.go index 6963bc9..2817a66 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -77,132 +77,12 @@ func (e *Encoder) compile(typ *rtype, root, withIndent bool) (*opcode, error) { } func (e *Encoder) optimizeStructFieldPtrHead(typ *rtype, code *opcode) *opcode { - switch code.op { - case opStructFieldHead: - code.op = opStructFieldPtrHead - case opStructFieldHeadInt: - code.op = opStructFieldPtrHeadInt - case opStructFieldHeadInt8: - code.op = opStructFieldPtrHeadInt8 - case opStructFieldHeadInt16: - code.op = opStructFieldPtrHeadInt16 - case opStructFieldHeadInt32: - code.op = opStructFieldPtrHeadInt32 - case opStructFieldHeadInt64: - code.op = opStructFieldPtrHeadInt64 - case opStructFieldHeadUint: - code.op = opStructFieldPtrHeadUint - case opStructFieldHeadUint8: - code.op = opStructFieldPtrHeadUint8 - case opStructFieldHeadUint16: - code.op = opStructFieldPtrHeadUint16 - case opStructFieldHeadUint32: - code.op = opStructFieldPtrHeadUint32 - case opStructFieldHeadUint64: - code.op = opStructFieldPtrHeadUint64 - case opStructFieldHeadFloat32: - code.op = opStructFieldPtrHeadFloat32 - case opStructFieldHeadFloat64: - code.op = opStructFieldPtrHeadFloat64 - case opStructFieldHeadString: - code.op = opStructFieldPtrHeadString - case opStructFieldHeadBool: - code.op = opStructFieldPtrHeadBool - case opStructFieldHeadOmitEmpty: - code.op = opStructFieldPtrHeadOmitEmpty - case opStructFieldHeadIntOmitEmpty: - code.op = opStructFieldPtrHeadIntOmitEmpty - case opStructFieldHeadInt8OmitEmpty: - code.op = opStructFieldPtrHeadInt8OmitEmpty - case opStructFieldHeadInt16OmitEmpty: - code.op = opStructFieldPtrHeadInt16OmitEmpty - case opStructFieldHeadInt32OmitEmpty: - code.op = opStructFieldPtrHeadInt32OmitEmpty - case opStructFieldHeadInt64OmitEmpty: - code.op = opStructFieldPtrHeadInt64OmitEmpty - case opStructFieldHeadUintOmitEmpty: - code.op = opStructFieldPtrHeadUintOmitEmpty - case opStructFieldHeadUint8OmitEmpty: - code.op = opStructFieldPtrHeadUint8OmitEmpty - case opStructFieldHeadUint16OmitEmpty: - code.op = opStructFieldPtrHeadUint16OmitEmpty - case opStructFieldHeadUint32OmitEmpty: - code.op = opStructFieldPtrHeadUint32OmitEmpty - case opStructFieldHeadUint64OmitEmpty: - code.op = opStructFieldPtrHeadUint64OmitEmpty - case opStructFieldHeadFloat32OmitEmpty: - code.op = opStructFieldPtrHeadFloat32OmitEmpty - case opStructFieldHeadFloat64OmitEmpty: - code.op = opStructFieldPtrHeadFloat64OmitEmpty - case opStructFieldHeadStringOmitEmpty: - code.op = opStructFieldPtrHeadStringOmitEmpty - case opStructFieldHeadBoolOmitEmpty: - code.op = opStructFieldPtrHeadBoolOmitEmpty - - case opStructFieldHeadIndent: - code.op = opStructFieldPtrHeadIndent - case opStructFieldHeadIntIndent: - code.op = opStructFieldPtrHeadIntIndent - case opStructFieldHeadInt8Indent: - code.op = opStructFieldPtrHeadInt8Indent - case opStructFieldHeadInt16Indent: - code.op = opStructFieldPtrHeadInt16Indent - case opStructFieldHeadInt32Indent: - code.op = opStructFieldPtrHeadInt32Indent - case opStructFieldHeadInt64Indent: - code.op = opStructFieldPtrHeadInt64Indent - case opStructFieldHeadUintIndent: - code.op = opStructFieldPtrHeadUintIndent - case opStructFieldHeadUint8Indent: - code.op = opStructFieldPtrHeadUint8Indent - case opStructFieldHeadUint16Indent: - code.op = opStructFieldPtrHeadUint16Indent - case opStructFieldHeadUint32Indent: - code.op = opStructFieldPtrHeadUint32Indent - case opStructFieldHeadUint64Indent: - code.op = opStructFieldPtrHeadUint64Indent - case opStructFieldHeadFloat32Indent: - code.op = opStructFieldPtrHeadFloat32Indent - case opStructFieldHeadFloat64Indent: - code.op = opStructFieldPtrHeadFloat64Indent - case opStructFieldHeadStringIndent: - code.op = opStructFieldPtrHeadStringIndent - case opStructFieldHeadBoolIndent: - code.op = opStructFieldPtrHeadBoolIndent - case opStructFieldHeadOmitEmptyIndent: - code.op = opStructFieldPtrHeadOmitEmptyIndent - case opStructFieldHeadIntOmitEmptyIndent: - code.op = opStructFieldPtrHeadIntOmitEmptyIndent - case opStructFieldHeadInt8OmitEmptyIndent: - code.op = opStructFieldPtrHeadInt8OmitEmptyIndent - case opStructFieldHeadInt16OmitEmptyIndent: - code.op = opStructFieldPtrHeadInt16OmitEmptyIndent - case opStructFieldHeadInt32OmitEmptyIndent: - code.op = opStructFieldPtrHeadInt32OmitEmptyIndent - case opStructFieldHeadInt64OmitEmptyIndent: - code.op = opStructFieldPtrHeadInt64OmitEmptyIndent - case opStructFieldHeadUintOmitEmptyIndent: - code.op = opStructFieldPtrHeadUintOmitEmptyIndent - case opStructFieldHeadUint8OmitEmptyIndent: - code.op = opStructFieldPtrHeadUint8OmitEmptyIndent - case opStructFieldHeadUint16OmitEmptyIndent: - code.op = opStructFieldPtrHeadUint16OmitEmptyIndent - case opStructFieldHeadUint32OmitEmptyIndent: - code.op = opStructFieldPtrHeadUint32OmitEmptyIndent - case opStructFieldHeadUint64OmitEmptyIndent: - code.op = opStructFieldPtrHeadUint64OmitEmptyIndent - case opStructFieldHeadFloat32OmitEmptyIndent: - code.op = opStructFieldPtrHeadFloat32OmitEmptyIndent - case opStructFieldHeadFloat64OmitEmptyIndent: - code.op = opStructFieldPtrHeadFloat64OmitEmptyIndent - case opStructFieldHeadStringOmitEmptyIndent: - code.op = opStructFieldPtrHeadStringOmitEmptyIndent - case opStructFieldHeadBoolOmitEmptyIndent: - code.op = opStructFieldPtrHeadBoolOmitEmptyIndent - default: - return newOpCode(opPtr, typ, e.indent, code) + ptrHeadOp := code.op.headToPtrHead() + if code.op != ptrHeadOp { + code.op = ptrHeadOp + return code } - return code + return newOpCode(opPtr, typ, e.indent, code) } func (e *Encoder) compilePtr(typ *rtype, root, withIndent bool) (*opcode, error) { @@ -456,118 +336,7 @@ func (e *Encoder) isIgnoredStructField(field reflect.StructField) bool { return false } -func (e *Encoder) optimizeStructHeaderOmitEmptyIndent(op opType) opType { - switch op { - case opInt: - return opStructFieldHeadIntOmitEmptyIndent - case opInt8: - return opStructFieldHeadInt8OmitEmptyIndent - case opInt16: - return opStructFieldHeadInt16OmitEmptyIndent - case opInt32: - return opStructFieldHeadInt32OmitEmptyIndent - case opInt64: - return opStructFieldHeadInt64OmitEmptyIndent - case opUint: - return opStructFieldHeadUintOmitEmptyIndent - case opUint8: - return opStructFieldHeadUint8OmitEmptyIndent - case opUint16: - return opStructFieldHeadUint16OmitEmptyIndent - case opUint32: - return opStructFieldHeadUint32OmitEmptyIndent - case opUint64: - return opStructFieldHeadUint64OmitEmptyIndent - case opFloat32: - return opStructFieldHeadFloat32OmitEmptyIndent - case opFloat64: - return opStructFieldHeadFloat64OmitEmptyIndent - case opString: - return opStructFieldHeadStringOmitEmptyIndent - case opBool: - return opStructFieldHeadBoolOmitEmptyIndent - } - return opStructFieldHeadOmitEmptyIndent -} - -func (e *Encoder) optimizeStructHeaderIndent(op opType, isOmitEmpty bool) opType { - if isOmitEmpty { - return e.optimizeStructHeaderOmitEmptyIndent(op) - } - switch op { - case opInt: - return opStructFieldHeadIntIndent - case opInt8: - return opStructFieldHeadInt8Indent - case opInt16: - return opStructFieldHeadInt16Indent - case opInt32: - return opStructFieldHeadInt32Indent - case opInt64: - return opStructFieldHeadInt64Indent - case opUint: - return opStructFieldHeadUintIndent - case opUint8: - return opStructFieldHeadUint8Indent - case opUint16: - return opStructFieldHeadUint16Indent - case opUint32: - return opStructFieldHeadUint32Indent - case opUint64: - return opStructFieldHeadUint64Indent - case opFloat32: - return opStructFieldHeadFloat32Indent - case opFloat64: - return opStructFieldHeadFloat64Indent - case opString: - return opStructFieldHeadStringIndent - case opBool: - return opStructFieldHeadBoolIndent - } - return opStructFieldHeadIndent -} - -func (e *Encoder) optimizeStructHeaderOmitEmpty(op opType) opType { - switch op { - case opInt: - return opStructFieldHeadIntOmitEmpty - case opInt8: - return opStructFieldHeadInt8OmitEmpty - case opInt16: - return opStructFieldHeadInt16OmitEmpty - case opInt32: - return opStructFieldHeadInt32OmitEmpty - case opInt64: - return opStructFieldHeadInt64OmitEmpty - case opUint: - return opStructFieldHeadUintOmitEmpty - case opUint8: - return opStructFieldHeadUint8OmitEmpty - case opUint16: - return opStructFieldHeadUint16OmitEmpty - case opUint32: - return opStructFieldHeadUint32OmitEmpty - case opUint64: - return opStructFieldHeadUint64OmitEmpty - case opFloat32: - return opStructFieldHeadFloat32OmitEmpty - case opFloat64: - return opStructFieldHeadFloat64OmitEmpty - case opString: - return opStructFieldHeadStringOmitEmpty - case opBool: - return opStructFieldHeadBoolOmitEmpty - } - return opStructFieldHeadOmitEmpty -} - -func (e *Encoder) optimizeStructHeader(op opType, isOmitEmpty, withIndent bool) opType { - if withIndent { - return e.optimizeStructHeaderIndent(op, isOmitEmpty) - } - if isOmitEmpty { - return e.optimizeStructHeaderOmitEmpty(op) - } +func (e *Encoder) typeToHeaderType(op opType) opType { switch op { case opInt: return opStructFieldHeadInt @@ -601,118 +370,7 @@ func (e *Encoder) optimizeStructHeader(op opType, isOmitEmpty, withIndent bool) return opStructFieldHead } -func (e *Encoder) optimizeStructFieldOmitEmptyIndent(op opType) opType { - switch op { - case opInt: - return opStructFieldIntOmitEmptyIndent - case opInt8: - return opStructFieldInt8OmitEmptyIndent - case opInt16: - return opStructFieldInt16OmitEmptyIndent - case opInt32: - return opStructFieldInt32OmitEmptyIndent - case opInt64: - return opStructFieldInt64OmitEmptyIndent - case opUint: - return opStructFieldUintOmitEmptyIndent - case opUint8: - return opStructFieldUint8OmitEmptyIndent - case opUint16: - return opStructFieldUint16OmitEmptyIndent - case opUint32: - return opStructFieldUint32OmitEmptyIndent - case opUint64: - return opStructFieldUint64OmitEmptyIndent - case opFloat32: - return opStructFieldFloat32OmitEmptyIndent - case opFloat64: - return opStructFieldFloat64OmitEmptyIndent - case opString: - return opStructFieldStringOmitEmptyIndent - case opBool: - return opStructFieldBoolOmitEmptyIndent - } - return opStructFieldOmitEmptyIndent -} - -func (e *Encoder) optimizeStructFieldIndent(op opType, isOmitEmpty bool) opType { - if isOmitEmpty { - return e.optimizeStructFieldOmitEmptyIndent(op) - } - switch op { - case opInt: - return opStructFieldIntIndent - case opInt8: - return opStructFieldInt8Indent - case opInt16: - return opStructFieldInt16Indent - case opInt32: - return opStructFieldInt32Indent - case opInt64: - return opStructFieldInt64Indent - case opUint: - return opStructFieldUintIndent - case opUint8: - return opStructFieldUint8Indent - case opUint16: - return opStructFieldUint16Indent - case opUint32: - return opStructFieldUint32Indent - case opUint64: - return opStructFieldUint64Indent - case opFloat32: - return opStructFieldFloat32Indent - case opFloat64: - return opStructFieldFloat64Indent - case opString: - return opStructFieldStringIndent - case opBool: - return opStructFieldBoolIndent - } - return opStructFieldIndent -} - -func (e *Encoder) optimizeStructFieldOmitEmpty(op opType) opType { - switch op { - case opInt: - return opStructFieldIntOmitEmpty - case opInt8: - return opStructFieldInt8OmitEmpty - case opInt16: - return opStructFieldInt16OmitEmpty - case opInt32: - return opStructFieldInt32OmitEmpty - case opInt64: - return opStructFieldInt64OmitEmpty - case opUint: - return opStructFieldUintOmitEmpty - case opUint8: - return opStructFieldUint8OmitEmpty - case opUint16: - return opStructFieldUint16OmitEmpty - case opUint32: - return opStructFieldUint32OmitEmpty - case opUint64: - return opStructFieldUint64OmitEmpty - case opFloat32: - return opStructFieldFloat32OmitEmpty - case opFloat64: - return opStructFieldFloat64OmitEmpty - case opString: - return opStructFieldStringOmitEmpty - case opBool: - return opStructFieldBoolOmitEmpty - } - return opStructFieldOmitEmpty -} - -func (e *Encoder) optimizeStructField(op opType, isOmitEmpty, withIndent bool) opType { - if withIndent { - return e.optimizeStructFieldIndent(op, isOmitEmpty) - } - if isOmitEmpty { - return e.optimizeStructFieldOmitEmpty(op) - } +func (e *Encoder) typeToFieldType(op opType) opType { switch op { case opInt: return opStructFieldInt @@ -746,6 +404,28 @@ func (e *Encoder) optimizeStructField(op opType, isOmitEmpty, withIndent bool) o return opStructField } +func (e *Encoder) optimizeStructHeader(op opType, isOmitEmpty, withIndent bool) opType { + headType := e.typeToHeaderType(op) + if isOmitEmpty { + headType = headType.headToOmitEmptyHead() + } + if withIndent { + return headType.toIndent() + } + return headType +} + +func (e *Encoder) optimizeStructField(op opType, isOmitEmpty, withIndent bool) opType { + fieldType := e.typeToFieldType(op) + if isOmitEmpty { + fieldType = fieldType.fieldToOmitEmptyField() + } + if withIndent { + return fieldType.toIndent() + } + return fieldType +} + func (e *Encoder) recursiveCode(typ *rtype, code *compiledCode) *opcode { return (*opcode)(unsafe.Pointer(&recursiveCode{ opcodeHeader: &opcodeHeader{ @@ -848,6 +528,19 @@ func (e *Encoder) compileStruct(typ *rtype, root, withIndent bool) (*opcode, err if err != nil { return nil, err } + if field.Anonymous { + f := valueCode.toStructFieldCode() + for { + f.op = f.op.headToAnonymousHead() + if f.op == opStructEnd { + f.op = opStructAnonymousEnd + } + if f.nextField == nil { + break + } + f = f.nextField.toStructFieldCode() + } + } key := fmt.Sprintf(`"%s":`, keyName) fieldCode := &structFieldCode{ opcodeHeader: &opcodeHeader{ @@ -855,8 +548,9 @@ func (e *Encoder) compileStruct(typ *rtype, root, withIndent bool) (*opcode, err next: valueCode, indent: e.indent, }, - key: []byte(key), - offset: field.Offset, + anonymousKey: field.Anonymous, + key: []byte(key), + offset: field.Offset, } if fieldIdx == 0 { code = e.structHeader(fieldCode, valueCode, isOmitEmpty, withIndent) @@ -873,7 +567,13 @@ func (e *Encoder) compileStruct(typ *rtype, root, withIndent bool) (*opcode, err } e.indent-- - structEndCode := newOpCode(opStructEnd, nil, e.indent, nil) + structEndCode := (*opcode)(unsafe.Pointer(&structFieldCode{ + opcodeHeader: &opcodeHeader{ + op: opStructEnd, + typ: nil, + indent: e.indent, + }, + })) structEndCode.next = newEndOp(e.indent) if withIndent { structEndCode.op = opStructEndIndent diff --git a/encode_opcode.go b/encode_opcode.go index f254706..1b6e160 100644 --- a/encode_opcode.go +++ b/encode_opcode.go @@ -7,746 +7,6 @@ import ( "unsafe" ) -type opType int - -const ( - opEnd opType = iota - opInt - opInt8 - opInt16 - opInt32 - opInt64 - opUint - opUint8 - opUint16 - opUint32 - opUint64 - opFloat32 - opFloat64 - opString - opBool - opInterface - opPtr - opMarshalJSON - opMarshalText - - opSliceHead - opSliceElem - opSliceEnd - - opSliceHeadIndent - opRootSliceHeadIndent - opSliceElemIndent - opRootSliceElemIndent - opSliceEndIndent - - opArrayHead - opArrayElem - opArrayEnd - - opArrayHeadIndent - opArrayElemIndent - opArrayEndIndent - - opMapHead - opMapHeadLoad - opMapKey - opMapValue - - opMapHeadIndent - opRootMapHeadIndent - opMapHeadLoadIndent - opMapKeyIndent - opRootMapKeyIndent - opMapValueIndent - opMapEnd - opMapEndIndent - - // StructFieldHead - opStructFieldHead - opStructFieldHeadInt - opStructFieldHeadInt8 - opStructFieldHeadInt16 - opStructFieldHeadInt32 - opStructFieldHeadInt64 - opStructFieldHeadUint - opStructFieldHeadUint8 - opStructFieldHeadUint16 - opStructFieldHeadUint32 - opStructFieldHeadUint64 - opStructFieldHeadFloat32 - opStructFieldHeadFloat64 - opStructFieldHeadString - opStructFieldHeadBool - - opStructFieldHeadIndent - opStructFieldHeadIntIndent - opStructFieldHeadInt8Indent - opStructFieldHeadInt16Indent - opStructFieldHeadInt32Indent - opStructFieldHeadInt64Indent - opStructFieldHeadUintIndent - opStructFieldHeadUint8Indent - opStructFieldHeadUint16Indent - opStructFieldHeadUint32Indent - opStructFieldHeadUint64Indent - opStructFieldHeadFloat32Indent - opStructFieldHeadFloat64Indent - opStructFieldHeadStringIndent - opStructFieldHeadBoolIndent - - // StructFieldHead with omitempty - opStructFieldHeadOmitEmpty - opStructFieldHeadIntOmitEmpty - opStructFieldHeadInt8OmitEmpty - opStructFieldHeadInt16OmitEmpty - opStructFieldHeadInt32OmitEmpty - opStructFieldHeadInt64OmitEmpty - opStructFieldHeadUintOmitEmpty - opStructFieldHeadUint8OmitEmpty - opStructFieldHeadUint16OmitEmpty - opStructFieldHeadUint32OmitEmpty - opStructFieldHeadUint64OmitEmpty - opStructFieldHeadFloat32OmitEmpty - opStructFieldHeadFloat64OmitEmpty - opStructFieldHeadStringOmitEmpty - opStructFieldHeadBoolOmitEmpty - - opStructFieldHeadOmitEmptyIndent - opStructFieldHeadIntOmitEmptyIndent - opStructFieldHeadInt8OmitEmptyIndent - opStructFieldHeadInt16OmitEmptyIndent - opStructFieldHeadInt32OmitEmptyIndent - opStructFieldHeadInt64OmitEmptyIndent - opStructFieldHeadUintOmitEmptyIndent - opStructFieldHeadUint8OmitEmptyIndent - opStructFieldHeadUint16OmitEmptyIndent - opStructFieldHeadUint32OmitEmptyIndent - opStructFieldHeadUint64OmitEmptyIndent - opStructFieldHeadFloat32OmitEmptyIndent - opStructFieldHeadFloat64OmitEmptyIndent - opStructFieldHeadStringOmitEmptyIndent - opStructFieldHeadBoolOmitEmptyIndent - - // StructFieldHead for pointer structure - opStructFieldPtrHead - opStructFieldPtrHeadInt - opStructFieldPtrHeadInt8 - opStructFieldPtrHeadInt16 - opStructFieldPtrHeadInt32 - opStructFieldPtrHeadInt64 - opStructFieldPtrHeadUint - opStructFieldPtrHeadUint8 - opStructFieldPtrHeadUint16 - opStructFieldPtrHeadUint32 - opStructFieldPtrHeadUint64 - opStructFieldPtrHeadFloat32 - opStructFieldPtrHeadFloat64 - opStructFieldPtrHeadString - opStructFieldPtrHeadBool - - opStructFieldRecursive - - opStructFieldPtrHeadIndent - opStructFieldPtrHeadIntIndent - opStructFieldPtrHeadInt8Indent - opStructFieldPtrHeadInt16Indent - opStructFieldPtrHeadInt32Indent - opStructFieldPtrHeadInt64Indent - opStructFieldPtrHeadUintIndent - opStructFieldPtrHeadUint8Indent - opStructFieldPtrHeadUint16Indent - opStructFieldPtrHeadUint32Indent - opStructFieldPtrHeadUint64Indent - opStructFieldPtrHeadFloat32Indent - opStructFieldPtrHeadFloat64Indent - opStructFieldPtrHeadStringIndent - opStructFieldPtrHeadBoolIndent - - // StructFieldPtrHead with omitempty - opStructFieldPtrHeadOmitEmpty - opStructFieldPtrHeadIntOmitEmpty - opStructFieldPtrHeadInt8OmitEmpty - opStructFieldPtrHeadInt16OmitEmpty - opStructFieldPtrHeadInt32OmitEmpty - opStructFieldPtrHeadInt64OmitEmpty - opStructFieldPtrHeadUintOmitEmpty - opStructFieldPtrHeadUint8OmitEmpty - opStructFieldPtrHeadUint16OmitEmpty - opStructFieldPtrHeadUint32OmitEmpty - opStructFieldPtrHeadUint64OmitEmpty - opStructFieldPtrHeadFloat32OmitEmpty - opStructFieldPtrHeadFloat64OmitEmpty - opStructFieldPtrHeadStringOmitEmpty - opStructFieldPtrHeadBoolOmitEmpty - - opStructFieldPtrHeadOmitEmptyIndent - opStructFieldPtrHeadIntOmitEmptyIndent - opStructFieldPtrHeadInt8OmitEmptyIndent - opStructFieldPtrHeadInt16OmitEmptyIndent - opStructFieldPtrHeadInt32OmitEmptyIndent - opStructFieldPtrHeadInt64OmitEmptyIndent - opStructFieldPtrHeadUintOmitEmptyIndent - opStructFieldPtrHeadUint8OmitEmptyIndent - opStructFieldPtrHeadUint16OmitEmptyIndent - opStructFieldPtrHeadUint32OmitEmptyIndent - opStructFieldPtrHeadUint64OmitEmptyIndent - opStructFieldPtrHeadFloat32OmitEmptyIndent - opStructFieldPtrHeadFloat64OmitEmptyIndent - opStructFieldPtrHeadStringOmitEmptyIndent - opStructFieldPtrHeadBoolOmitEmptyIndent - - // StructField - opStructField - opStructFieldInt - opStructFieldInt8 - opStructFieldInt16 - opStructFieldInt32 - opStructFieldInt64 - opStructFieldUint - opStructFieldUint8 - opStructFieldUint16 - opStructFieldUint32 - opStructFieldUint64 - opStructFieldFloat32 - opStructFieldFloat64 - opStructFieldString - opStructFieldBool - - opStructFieldIndent - opStructFieldIntIndent - opStructFieldInt8Indent - opStructFieldInt16Indent - opStructFieldInt32Indent - opStructFieldInt64Indent - opStructFieldUintIndent - opStructFieldUint8Indent - opStructFieldUint16Indent - opStructFieldUint32Indent - opStructFieldUint64Indent - opStructFieldFloat32Indent - opStructFieldFloat64Indent - opStructFieldStringIndent - opStructFieldBoolIndent - - // StructField with omitempty - opStructFieldOmitEmpty - opStructFieldIntOmitEmpty - opStructFieldInt8OmitEmpty - opStructFieldInt16OmitEmpty - opStructFieldInt32OmitEmpty - opStructFieldInt64OmitEmpty - opStructFieldUintOmitEmpty - opStructFieldUint8OmitEmpty - opStructFieldUint16OmitEmpty - opStructFieldUint32OmitEmpty - opStructFieldUint64OmitEmpty - opStructFieldFloat32OmitEmpty - opStructFieldFloat64OmitEmpty - opStructFieldStringOmitEmpty - opStructFieldBoolOmitEmpty - - opStructFieldOmitEmptyIndent - opStructFieldIntOmitEmptyIndent - opStructFieldInt8OmitEmptyIndent - opStructFieldInt16OmitEmptyIndent - opStructFieldInt32OmitEmptyIndent - opStructFieldInt64OmitEmptyIndent - opStructFieldUintOmitEmptyIndent - opStructFieldUint8OmitEmptyIndent - opStructFieldUint16OmitEmptyIndent - opStructFieldUint32OmitEmptyIndent - opStructFieldUint64OmitEmptyIndent - opStructFieldFloat32OmitEmptyIndent - opStructFieldFloat64OmitEmptyIndent - opStructFieldStringOmitEmptyIndent - opStructFieldBoolOmitEmptyIndent - - opStructEnd - opStructEndIndent -) - -func (t opType) String() string { - switch t { - case opEnd: - return "END" - case opInt: - return "INT" - case opInt8: - return "INT8" - case opInt16: - return "INT16" - case opInt32: - return "INT32" - case opInt64: - return "INT64" - case opUint: - return "UINT" - case opUint8: - return "UINT8" - case opUint16: - return "UINT16" - case opUint32: - return "UINT32" - case opUint64: - return "UINT64" - case opFloat32: - return "FLOAT32" - case opFloat64: - return "FLOAT64" - case opString: - return "STRING" - case opBool: - return "BOOL" - case opInterface: - return "INTERFACE" - case opPtr: - return "PTR" - case opMarshalJSON: - return "MARSHAL_JSON" - case opMarshalText: - return "MARSHAL_TEXT" - - case opSliceHead: - return "SLICE_HEAD" - case opSliceElem: - return "SLICE_ELEM" - case opSliceEnd: - return "SLICE_END" - - case opSliceHeadIndent: - return "SLICE_HEAD_INDENT" - case opRootSliceHeadIndent: - return "ROOT_SLICE_HEAD_INDENT" - case opSliceElemIndent: - return "SLICE_ELEM_INDENT" - case opRootSliceElemIndent: - return "ROOT_SLICE_ELEM_INDENT" - case opSliceEndIndent: - return "SLICE_END_INDENT" - - case opArrayHead: - return "ARRAY_HEAD" - case opArrayElem: - return "ARRAY_ELEM" - case opArrayEnd: - return "ARRAY_END" - - case opArrayHeadIndent: - return "ARRAY_HEAD_INDENT" - case opArrayElemIndent: - return "ARRAY_ELEM_INDENT" - case opArrayEndIndent: - return "ARRAY_END_INDENT" - case opMapHead: - return "MAP_HEAD" - case opMapHeadLoad: - return "MAP_HEAD_LOAD" - case opMapKey: - return "MAP_KEY" - case opMapValue: - return "MAP_VALUE" - case opMapEnd: - return "MAP_END" - - case opMapHeadIndent: - return "MAP_HEAD_INDENT" - case opRootMapHeadIndent: - return "ROOT_MAP_HEAD_INDENT" - case opMapHeadLoadIndent: - return "MAP_HEAD_LOAD_INDENT" - case opMapKeyIndent: - return "MAP_KEY_INDENT" - case opRootMapKeyIndent: - return "ROOT_MAP_KEY_INDENT" - case opMapValueIndent: - return "MAP_VALUE_INDENT" - case opMapEndIndent: - return "MAP_END_INDENT" - - case opStructFieldRecursive: - return "STRUCT_FIELD_RECURSIVE" - case opStructFieldHead: - return "STRUCT_FIELD_HEAD" - case opStructFieldHeadInt: - return "STRUCT_FIELD_HEAD_INT" - case opStructFieldHeadInt8: - return "STRUCT_FIELD_HEAD_INT8" - case opStructFieldHeadInt16: - return "STRUCT_FIELD_HEAD_INT16" - case opStructFieldHeadInt32: - return "STRUCT_FIELD_HEAD_INT32" - case opStructFieldHeadInt64: - return "STRUCT_FIELD_HEAD_INT64" - case opStructFieldHeadUint: - return "STRUCT_FIELD_HEAD_UINT" - case opStructFieldHeadUint8: - return "STRUCT_FIELD_HEAD_UINT8" - case opStructFieldHeadUint16: - return "STRUCT_FIELD_HEAD_UINT16" - case opStructFieldHeadUint32: - return "STRUCT_FIELD_HEAD_UINT32" - case opStructFieldHeadUint64: - return "STRUCT_FIELD_HEAD_UINT64" - case opStructFieldHeadFloat32: - return "STRUCT_FIELD_HEAD_FLOAT32" - case opStructFieldHeadFloat64: - return "STRUCT_FIELD_HEAD_FLOAT64" - case opStructFieldHeadString: - return "STRUCT_FIELD_HEAD_STRING" - case opStructFieldHeadBool: - return "STRUCT_FIELD_HEAD_BOOL" - - case opStructFieldHeadIndent: - return "STRUCT_FIELD_HEAD_INDENT" - case opStructFieldHeadIntIndent: - return "STRUCT_FIELD_HEAD_INT_INDENT" - case opStructFieldHeadInt8Indent: - return "STRUCT_FIELD_HEAD_INT8_INDENT" - case opStructFieldHeadInt16Indent: - return "STRUCT_FIELD_HEAD_INT16_INDENT" - case opStructFieldHeadInt32Indent: - return "STRUCT_FIELD_HEAD_INT32_INDENT" - case opStructFieldHeadInt64Indent: - return "STRUCT_FIELD_HEAD_INT64_INDENT" - case opStructFieldHeadUintIndent: - return "STRUCT_FIELD_HEAD_UINT_INDENT" - case opStructFieldHeadUint8Indent: - return "STRUCT_FIELD_HEAD_UINT8_INDENT" - case opStructFieldHeadUint16Indent: - return "STRUCT_FIELD_HEAD_UINT16_INDENT" - case opStructFieldHeadUint32Indent: - return "STRUCT_FIELD_HEAD_UINT32_INDENT" - case opStructFieldHeadUint64Indent: - return "STRUCT_FIELD_HEAD_UINT64_INDENT" - case opStructFieldHeadFloat32Indent: - return "STRUCT_FIELD_HEAD_FLOAT32_INDENT" - case opStructFieldHeadFloat64Indent: - return "STRUCT_FIELD_HEAD_FLOAT64_INDENT" - case opStructFieldHeadStringIndent: - return "STRUCT_FIELD_HEAD_STRING_INDENT" - case opStructFieldHeadBoolIndent: - return "STRUCT_FIELD_HEAD_BOOL_INDENT" - - case opStructFieldHeadOmitEmpty: - return "STRUCT_FIELD_HEAD_OMIT_EMPTY" - case opStructFieldHeadIntOmitEmpty: - return "STRUCT_FIELD_HEAD_INT_OMIT_EMPTY" - case opStructFieldHeadInt8OmitEmpty: - return "STRUCT_FIELD_HEAD_INT8_OMIT_EMPTY" - case opStructFieldHeadInt16OmitEmpty: - return "STRUCT_FIELD_HEAD_INT16_OMIT_EMPTY" - case opStructFieldHeadInt32OmitEmpty: - return "STRUCT_FIELD_HEAD_INT32_OMIT_EMPTY" - case opStructFieldHeadInt64OmitEmpty: - return "STRUCT_FIELD_HEAD_INT64_OMIT_EMPTY" - case opStructFieldHeadUintOmitEmpty: - return "STRUCT_FIELD_HEAD_UINT_OMIT_EMPTY" - case opStructFieldHeadUint8OmitEmpty: - return "STRUCT_FIELD_HEAD_UINT8_OMIT_EMPTY" - case opStructFieldHeadUint16OmitEmpty: - return "STRUCT_FIELD_HEAD_UINT16_OMIT_EMPTY" - case opStructFieldHeadUint32OmitEmpty: - return "STRUCT_FIELD_HEAD_UINT32_OMIT_EMPTY" - case opStructFieldHeadUint64OmitEmpty: - return "STRUCT_FIELD_HEAD_UINT64_OMIT_EMPTY" - case opStructFieldHeadFloat32OmitEmpty: - return "STRUCT_FIELD_HEAD_FLOAT32_OMIT_EMPTY" - case opStructFieldHeadFloat64OmitEmpty: - return "STRUCT_FIELD_HEAD_FLOAT64_OMIT_EMPTY" - case opStructFieldHeadStringOmitEmpty: - return "STRUCT_FIELD_HEAD_STRING_OMIT_EMPTY" - case opStructFieldHeadBoolOmitEmpty: - return "STRUCT_FIELD_HEAD_BOOL_OMIT_EMPTY" - - case opStructFieldHeadOmitEmptyIndent: - return "STRUCT_FIELD_HEAD_OMIT_EMPTY_INDENT" - case opStructFieldHeadIntOmitEmptyIndent: - return "STRUCT_FIELD_HEAD_INT_OMIT_EMPTY_INDENT" - case opStructFieldHeadInt8OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_INT8_OMIT_EMPTY_INDENT" - case opStructFieldHeadInt16OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_INT16_OMIT_EMPTY_INDENT" - case opStructFieldHeadInt32OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_INT32_OMIT_EMPTY_INDENT" - case opStructFieldHeadInt64OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_INT64_OMIT_EMPTY_INDENT" - case opStructFieldHeadUintOmitEmptyIndent: - return "STRUCT_FIELD_HEAD_UINT_OMIT_EMPTY_INDENT" - case opStructFieldHeadUint8OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_UINT8_OMIT_EMPTY_INDENT" - case opStructFieldHeadUint16OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_UINT16_OMIT_EMPTY_INDENT" - case opStructFieldHeadUint32OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_UINT32_OMIT_EMPTY_INDENT" - case opStructFieldHeadUint64OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_UINT64_OMIT_EMPTY_INDENT" - case opStructFieldHeadFloat32OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_FLOAT32_OMIT_EMPTY_INDENT" - case opStructFieldHeadFloat64OmitEmptyIndent: - return "STRUCT_FIELD_HEAD_FLOAT64_OMIT_EMPTY_INDENT" - case opStructFieldHeadStringOmitEmptyIndent: - return "STRUCT_FIELD_HEAD_STRING_OMIT_EMPTY_INDENT" - case opStructFieldHeadBoolOmitEmptyIndent: - return "STRUCT_FIELD_HEAD_BOOL_OMIT_EMPTY_INDENT" - - case opStructFieldPtrHead: - return "STRUCT_FIELD_PTR_HEAD" - case opStructFieldPtrHeadInt: - return "STRUCT_FIELD_PTR_HEAD_INT" - case opStructFieldPtrHeadInt8: - return "STRUCT_FIELD_PTR_HEAD_INT8" - case opStructFieldPtrHeadInt16: - return "STRUCT_FIELD_PTR_HEAD_INT16" - case opStructFieldPtrHeadInt32: - return "STRUCT_FIELD_PTR_HEAD_INT32" - case opStructFieldPtrHeadInt64: - return "STRUCT_FIELD_PTR_HEAD_INT64" - case opStructFieldPtrHeadUint: - return "STRUCT_FIELD_PTR_HEAD_UINT" - case opStructFieldPtrHeadUint8: - return "STRUCT_FIELD_PTR_HEAD_UINT8" - case opStructFieldPtrHeadUint16: - return "STRUCT_FIELD_PTR_HEAD_UINT16" - case opStructFieldPtrHeadUint32: - return "STRUCT_FIELD_PTR_HEAD_UINT32" - case opStructFieldPtrHeadUint64: - return "STRUCT_FIELD_PTR_HEAD_UINT64" - case opStructFieldPtrHeadFloat32: - return "STRUCT_FIELD_PTR_HEAD_FLOAT32" - case opStructFieldPtrHeadFloat64: - return "STRUCT_FIELD_PTR_HEAD_FLOAT64" - case opStructFieldPtrHeadString: - return "STRUCT_FIELD_PTR_HEAD_STRING" - case opStructFieldPtrHeadBool: - return "STRUCT_FIELD_PTR_HEAD_BOOL" - - case opStructFieldPtrHeadIndent: - return "STRUCT_FIELD_PTR_HEAD_INDENT" - case opStructFieldPtrHeadIntIndent: - return "STRUCT_FIELD_PTR_HEAD_INT_INDENT" - case opStructFieldPtrHeadInt8Indent: - return "STRUCT_FIELD_PTR_HEAD_INT8_INDENT" - case opStructFieldPtrHeadInt16Indent: - return "STRUCT_FIELD_PTR_HEAD_INT16_INDENT" - case opStructFieldPtrHeadInt32Indent: - return "STRUCT_FIELD_PTR_HEAD_INT32_INDENT" - case opStructFieldPtrHeadInt64Indent: - return "STRUCT_FIELD_PTR_HEAD_INT64_INDENT" - case opStructFieldPtrHeadUintIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT_INDENT" - case opStructFieldPtrHeadUint8Indent: - return "STRUCT_FIELD_PTR_HEAD_UINT8_INDENT" - case opStructFieldPtrHeadUint16Indent: - return "STRUCT_FIELD_PTR_HEAD_UINT16_INDENT" - case opStructFieldPtrHeadUint32Indent: - return "STRUCT_FIELD_PTR_HEAD_UINT32_INDENT" - case opStructFieldPtrHeadUint64Indent: - return "STRUCT_FIELD_PTR_HEAD_UINT64_INDENT" - case opStructFieldPtrHeadFloat32Indent: - return "STRUCT_FIELD_PTR_HEAD_FLOAT32_INDENT" - case opStructFieldPtrHeadFloat64Indent: - return "STRUCT_FIELD_PTR_HEAD_FLOAT64_INDENT" - case opStructFieldPtrHeadStringIndent: - return "STRUCT_FIELD_PTR_HEAD_STRING_INDENT" - case opStructFieldPtrHeadBoolIndent: - return "STRUCT_FIELD_PTR_HEAD_BOOL_INDENT" - - case opStructFieldPtrHeadOmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_OMIT_EMPTY" - case opStructFieldPtrHeadIntOmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_INT_OMIT_EMPTY" - case opStructFieldPtrHeadInt8OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_INT8_OMIT_EMPTY" - case opStructFieldPtrHeadInt16OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_INT16_OMIT_EMPTY" - case opStructFieldPtrHeadInt32OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_INT32_OMIT_EMPTY" - case opStructFieldPtrHeadInt64OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_INT64_OMIT_EMPTY" - case opStructFieldPtrHeadUintOmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_UINT_OMIT_EMPTY" - case opStructFieldPtrHeadUint8OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_UINT8_OMIT_EMPTY" - case opStructFieldPtrHeadUint16OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_UINT16_OMIT_EMPTY" - case opStructFieldPtrHeadUint32OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_UINT32_OMIT_EMPTY" - case opStructFieldPtrHeadUint64OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_UINT64_OMIT_EMPTY" - case opStructFieldPtrHeadFloat32OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_FLOAT32_OMIT_EMPTY" - case opStructFieldPtrHeadFloat64OmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_FLOAT64_OMIT_EMPTY" - case opStructFieldPtrHeadStringOmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_STRING_OMIT_EMPTY" - case opStructFieldPtrHeadBoolOmitEmpty: - return "STRUCT_FIELD_PTR_HEAD_BOOL_OMIT_EMPTY" - - case opStructFieldPtrHeadOmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadIntOmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_INT_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadInt8OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_INT8_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadInt16OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_INT16_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadInt32OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_INT32_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadInt64OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_INT64_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadUintOmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadUint8OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT8_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadUint16OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT16_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadUint32OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT32_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadUint64OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_UINT64_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadFloat32OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_FLOAT32_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadFloat64OmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_FLOAT64_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadStringOmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_STRING_OMIT_EMPTY_INDENT" - case opStructFieldPtrHeadBoolOmitEmptyIndent: - return "STRUCT_FIELD_PTR_HEAD_BOOL_OMIT_EMPTY_INDENT" - - case opStructField: - return "STRUCT_FIELD" - case opStructFieldInt: - return "STRUCT_FIELD_INT" - case opStructFieldInt8: - return "STRUCT_FIELD_INT8" - case opStructFieldInt16: - return "STRUCT_FIELD_INT16" - case opStructFieldInt32: - return "STRUCT_FIELD_INT32" - case opStructFieldInt64: - return "STRUCT_FIELD_INT64" - case opStructFieldUint: - return "STRUCT_FIELD_UINT" - case opStructFieldUint8: - return "STRUCT_FIELD_UINT8" - case opStructFieldUint16: - return "STRUCT_FIELD_UINT16" - case opStructFieldUint32: - return "STRUCT_FIELD_UINT32" - case opStructFieldUint64: - return "STRUCT_FIELD_UINT64" - case opStructFieldFloat32: - return "STRUCT_FIELD_FLOAT32" - case opStructFieldFloat64: - return "STRUCT_FIELD_FLOAT64" - case opStructFieldString: - return "STRUCT_FIELD_STRING" - case opStructFieldBool: - return "STRUCT_FIELD_BOOL" - - case opStructFieldIndent: - return "STRUCT_FIELD_INDENT" - case opStructFieldIntIndent: - return "STRUCT_FIELD_INT_INDENT" - case opStructFieldInt8Indent: - return "STRUCT_FIELD_INT8_INDENT" - case opStructFieldInt16Indent: - return "STRUCT_FIELD_INT16_INDENT" - case opStructFieldInt32Indent: - return "STRUCT_FIELD_INT32_INDENT" - case opStructFieldInt64Indent: - return "STRUCT_FIELD_INT64_INDENT" - case opStructFieldUintIndent: - return "STRUCT_FIELD_UINT_INDENT" - case opStructFieldUint8Indent: - return "STRUCT_FIELD_UINT8_INDENT" - case opStructFieldUint16Indent: - return "STRUCT_FIELD_UINT16_INDENT" - case opStructFieldUint32Indent: - return "STRUCT_FIELD_UINT32_INDENT" - case opStructFieldUint64Indent: - return "STRUCT_FIELD_UINT64_INDENT" - case opStructFieldFloat32Indent: - return "STRUCT_FIELD_FLOAT32_INDENT" - case opStructFieldFloat64Indent: - return "STRUCT_FIELD_FLOAT64_INDENT" - case opStructFieldStringIndent: - return "STRUCT_FIELD_STRING_INDENT" - case opStructFieldBoolIndent: - return "STRUCT_FIELD_BOOL_INDENT" - - case opStructFieldOmitEmpty: - return "STRUCT_FIELD_OMIT_EMPTY" - case opStructFieldIntOmitEmpty: - return "STRUCT_FIELD_INT_OMIT_EMPTY" - case opStructFieldInt8OmitEmpty: - return "STRUCT_FIELD_INT8_OMIT_EMPTY" - case opStructFieldInt16OmitEmpty: - return "STRUCT_FIELD_INT16_OMIT_EMPTY" - case opStructFieldInt32OmitEmpty: - return "STRUCT_FIELD_INT32_OMIT_EMPTY" - case opStructFieldInt64OmitEmpty: - return "STRUCT_FIELD_INT64_OMIT_EMPTY" - case opStructFieldUintOmitEmpty: - return "STRUCT_FIELD_UINT_OMIT_EMPTY" - case opStructFieldUint8OmitEmpty: - return "STRUCT_FIELD_UINT8_OMIT_EMPTY" - case opStructFieldUint16OmitEmpty: - return "STRUCT_FIELD_UINT16_OMIT_EMPTY" - case opStructFieldUint32OmitEmpty: - return "STRUCT_FIELD_UINT32_OMIT_EMPTY" - case opStructFieldUint64OmitEmpty: - return "STRUCT_FIELD_UINT64_OMIT_EMPTY" - case opStructFieldFloat32OmitEmpty: - return "STRUCT_FIELD_FLOAT32_OMIT_EMPTY" - case opStructFieldFloat64OmitEmpty: - return "STRUCT_FIELD_FLOAT64_OMIT_EMPTY" - case opStructFieldStringOmitEmpty: - return "STRUCT_FIELD_STRING_OMIT_EMPTY" - case opStructFieldBoolOmitEmpty: - return "STRUCT_FIELD_BOOL_OMIT_EMPTY" - - case opStructFieldOmitEmptyIndent: - return "STRUCT_FIELD_OMIT_EMPTY_INDENT" - case opStructFieldIntOmitEmptyIndent: - return "STRUCT_FIELD_INT_OMIT_EMPTY_INDENT" - case opStructFieldInt8OmitEmptyIndent: - return "STRUCT_FIELD_INT8_OMIT_EMPTY_INDENT" - case opStructFieldInt16OmitEmptyIndent: - return "STRUCT_FIELD_INT16_OMIT_EMPTY_INDENT" - case opStructFieldInt32OmitEmptyIndent: - return "STRUCT_FIELD_INT32_OMIT_EMPTY_INDENT" - case opStructFieldInt64OmitEmptyIndent: - return "STRUCT_FIELD_INT64_OMIT_EMPTY_INDENT" - case opStructFieldUintOmitEmptyIndent: - return "STRUCT_FIELD_UINT_OMIT_EMPTY_INDENT" - case opStructFieldUint8OmitEmptyIndent: - return "STRUCT_FIELD_UINT8_OMIT_EMPTY_INDENT" - case opStructFieldUint16OmitEmptyIndent: - return "STRUCT_FIELD_UINT16_OMIT_EMPTY_INDENT" - case opStructFieldUint32OmitEmptyIndent: - return "STRUCT_FIELD_UINT32_OMIT_EMPTY_INDENT" - case opStructFieldUint64OmitEmptyIndent: - return "STRUCT_FIELD_UINT64_OMIT_EMPTY_INDENT" - case opStructFieldFloat32OmitEmptyIndent: - return "STRUCT_FIELD_FLOAT32_OMIT_EMPTY_INDENT" - case opStructFieldFloat64OmitEmptyIndent: - return "STRUCT_FIELD_FLOAT64_OMIT_EMPTY_INDENT" - case opStructFieldStringOmitEmptyIndent: - return "STRUCT_FIELD_STRING_OMIT_EMPTY_INDENT" - case opStructFieldBoolOmitEmptyIndent: - return "STRUCT_FIELD_BOOL_OMIT_EMPTY_INDENT" - - case opStructEnd: - return "STRUCT_END" - case opStructEndIndent: - return "STRUCT_END_INDENT" - - } - return "" -} - func copyOpcode(code *opcode) *opcode { codeMap := map[uintptr]*opcode{} return code.copy(codeMap) @@ -820,203 +80,24 @@ func (c *opcode) copy(codeMap map[uintptr]*opcode) *opcode { return code } var code *opcode - switch c.op { - case opArrayHead, opArrayHeadIndent: + switch c.op.codeType() { + case codeArrayHead: code = c.toArrayHeaderCode().copy(codeMap) - case opArrayElem, opArrayElemIndent: + case codeArrayElem: code = c.toArrayElemCode().copy(codeMap) - case opSliceHead, opSliceHeadIndent, opRootSliceHeadIndent: + case codeSliceHead: code = c.toSliceHeaderCode().copy(codeMap) - case opSliceElem, opSliceElemIndent, opRootSliceElemIndent: + case codeSliceElem: code = c.toSliceElemCode().copy(codeMap) - case opMapHead, opMapHeadLoad, opMapHeadIndent, opMapHeadLoadIndent, opRootMapHeadIndent: + case codeMapHead: code = c.toMapHeadCode().copy(codeMap) - case opMapKey, opMapKeyIndent, opRootMapKeyIndent: + case codeMapKey: code = c.toMapKeyCode().copy(codeMap) - case opMapValue, opMapValueIndent: + case codeMapValue: code = c.toMapValueCode().copy(codeMap) - case opStructFieldRecursive: + case codeStructFieldRecursive: code = c.toRecursiveCode().copy(codeMap) - case opStructFieldHead, - opStructFieldHeadInt, - opStructFieldHeadInt8, - opStructFieldHeadInt16, - opStructFieldHeadInt32, - opStructFieldHeadInt64, - opStructFieldHeadUint, - opStructFieldHeadUint8, - opStructFieldHeadUint16, - opStructFieldHeadUint32, - opStructFieldHeadUint64, - opStructFieldHeadFloat32, - opStructFieldHeadFloat64, - opStructFieldHeadString, - opStructFieldHeadBool, - opStructFieldHeadIndent, - opStructFieldHeadIntIndent, - opStructFieldHeadInt8Indent, - opStructFieldHeadInt16Indent, - opStructFieldHeadInt32Indent, - opStructFieldHeadInt64Indent, - opStructFieldHeadUintIndent, - opStructFieldHeadUint8Indent, - opStructFieldHeadUint16Indent, - opStructFieldHeadUint32Indent, - opStructFieldHeadUint64Indent, - opStructFieldHeadFloat32Indent, - opStructFieldHeadFloat64Indent, - opStructFieldHeadStringIndent, - opStructFieldHeadBoolIndent, - opStructFieldHeadOmitEmpty, - opStructFieldHeadIntOmitEmpty, - opStructFieldHeadInt8OmitEmpty, - opStructFieldHeadInt16OmitEmpty, - opStructFieldHeadInt32OmitEmpty, - opStructFieldHeadInt64OmitEmpty, - opStructFieldHeadUintOmitEmpty, - opStructFieldHeadUint8OmitEmpty, - opStructFieldHeadUint16OmitEmpty, - opStructFieldHeadUint32OmitEmpty, - opStructFieldHeadUint64OmitEmpty, - opStructFieldHeadFloat32OmitEmpty, - opStructFieldHeadFloat64OmitEmpty, - opStructFieldHeadStringOmitEmpty, - opStructFieldHeadBoolOmitEmpty, - opStructFieldHeadOmitEmptyIndent, - opStructFieldHeadIntOmitEmptyIndent, - opStructFieldHeadInt8OmitEmptyIndent, - opStructFieldHeadInt16OmitEmptyIndent, - opStructFieldHeadInt32OmitEmptyIndent, - opStructFieldHeadInt64OmitEmptyIndent, - opStructFieldHeadUintOmitEmptyIndent, - opStructFieldHeadUint8OmitEmptyIndent, - opStructFieldHeadUint16OmitEmptyIndent, - opStructFieldHeadUint32OmitEmptyIndent, - opStructFieldHeadUint64OmitEmptyIndent, - opStructFieldHeadFloat32OmitEmptyIndent, - opStructFieldHeadFloat64OmitEmptyIndent, - opStructFieldHeadStringOmitEmptyIndent, - opStructFieldHeadBoolOmitEmptyIndent, - opStructFieldPtrHead, - opStructFieldPtrHeadInt, - opStructFieldPtrHeadInt8, - opStructFieldPtrHeadInt16, - opStructFieldPtrHeadInt32, - opStructFieldPtrHeadInt64, - opStructFieldPtrHeadUint, - opStructFieldPtrHeadUint8, - opStructFieldPtrHeadUint16, - opStructFieldPtrHeadUint32, - opStructFieldPtrHeadUint64, - opStructFieldPtrHeadFloat32, - opStructFieldPtrHeadFloat64, - opStructFieldPtrHeadString, - opStructFieldPtrHeadBool, - opStructFieldPtrHeadIndent, - opStructFieldPtrHeadIntIndent, - opStructFieldPtrHeadInt8Indent, - opStructFieldPtrHeadInt16Indent, - opStructFieldPtrHeadInt32Indent, - opStructFieldPtrHeadInt64Indent, - opStructFieldPtrHeadUintIndent, - opStructFieldPtrHeadUint8Indent, - opStructFieldPtrHeadUint16Indent, - opStructFieldPtrHeadUint32Indent, - opStructFieldPtrHeadUint64Indent, - opStructFieldPtrHeadFloat32Indent, - opStructFieldPtrHeadFloat64Indent, - opStructFieldPtrHeadStringIndent, - opStructFieldPtrHeadBoolIndent, - opStructFieldPtrHeadOmitEmpty, - opStructFieldPtrHeadIntOmitEmpty, - opStructFieldPtrHeadInt8OmitEmpty, - opStructFieldPtrHeadInt16OmitEmpty, - opStructFieldPtrHeadInt32OmitEmpty, - opStructFieldPtrHeadInt64OmitEmpty, - opStructFieldPtrHeadUintOmitEmpty, - opStructFieldPtrHeadUint8OmitEmpty, - opStructFieldPtrHeadUint16OmitEmpty, - opStructFieldPtrHeadUint32OmitEmpty, - opStructFieldPtrHeadUint64OmitEmpty, - opStructFieldPtrHeadFloat32OmitEmpty, - opStructFieldPtrHeadFloat64OmitEmpty, - opStructFieldPtrHeadStringOmitEmpty, - opStructFieldPtrHeadBoolOmitEmpty, - opStructFieldPtrHeadOmitEmptyIndent, - opStructFieldPtrHeadIntOmitEmptyIndent, - opStructFieldPtrHeadInt8OmitEmptyIndent, - opStructFieldPtrHeadInt16OmitEmptyIndent, - opStructFieldPtrHeadInt32OmitEmptyIndent, - opStructFieldPtrHeadInt64OmitEmptyIndent, - opStructFieldPtrHeadUintOmitEmptyIndent, - opStructFieldPtrHeadUint8OmitEmptyIndent, - opStructFieldPtrHeadUint16OmitEmptyIndent, - opStructFieldPtrHeadUint32OmitEmptyIndent, - opStructFieldPtrHeadUint64OmitEmptyIndent, - opStructFieldPtrHeadFloat32OmitEmptyIndent, - opStructFieldPtrHeadFloat64OmitEmptyIndent, - opStructFieldPtrHeadStringOmitEmptyIndent, - opStructFieldPtrHeadBoolOmitEmptyIndent, - opStructField, - opStructFieldInt, - opStructFieldInt8, - opStructFieldInt16, - opStructFieldInt32, - opStructFieldInt64, - opStructFieldUint, - opStructFieldUint8, - opStructFieldUint16, - opStructFieldUint32, - opStructFieldUint64, - opStructFieldFloat32, - opStructFieldFloat64, - opStructFieldString, - opStructFieldBool, - opStructFieldIndent, - opStructFieldIntIndent, - opStructFieldInt8Indent, - opStructFieldInt16Indent, - opStructFieldInt32Indent, - opStructFieldInt64Indent, - opStructFieldUintIndent, - opStructFieldUint8Indent, - opStructFieldUint16Indent, - opStructFieldUint32Indent, - opStructFieldUint64Indent, - opStructFieldFloat32Indent, - opStructFieldFloat64Indent, - opStructFieldStringIndent, - opStructFieldBoolIndent, - opStructFieldOmitEmpty, - opStructFieldIntOmitEmpty, - opStructFieldInt8OmitEmpty, - opStructFieldInt16OmitEmpty, - opStructFieldInt32OmitEmpty, - opStructFieldInt64OmitEmpty, - opStructFieldUintOmitEmpty, - opStructFieldUint8OmitEmpty, - opStructFieldUint16OmitEmpty, - opStructFieldUint32OmitEmpty, - opStructFieldUint64OmitEmpty, - opStructFieldFloat32OmitEmpty, - opStructFieldFloat64OmitEmpty, - opStructFieldStringOmitEmpty, - opStructFieldBoolOmitEmpty, - opStructFieldOmitEmptyIndent, - opStructFieldIntOmitEmptyIndent, - opStructFieldInt8OmitEmptyIndent, - opStructFieldInt16OmitEmptyIndent, - opStructFieldInt32OmitEmptyIndent, - opStructFieldInt64OmitEmptyIndent, - opStructFieldUintOmitEmptyIndent, - opStructFieldUint8OmitEmptyIndent, - opStructFieldUint16OmitEmptyIndent, - opStructFieldUint32OmitEmptyIndent, - opStructFieldUint64OmitEmptyIndent, - opStructFieldFloat32OmitEmptyIndent, - opStructFieldFloat64OmitEmptyIndent, - opStructFieldStringOmitEmptyIndent, - opStructFieldBoolOmitEmptyIndent: + case codeStructField: code = c.toStructFieldCode().copy(codeMap) default: code = &opcode{} @@ -1223,10 +304,12 @@ func (c *arrayElemCode) copy(codeMap map[uintptr]*opcode) *opcode { type structFieldCode struct { *opcodeHeader - key []byte - offset uintptr - nextField *opcode - end *opcode + key []byte + offset uintptr + anonymousKey bool + anonymous bool + nextField *opcode + end *opcode } func (c *structFieldCode) copy(codeMap map[uintptr]*opcode) *opcode { @@ -1238,8 +321,10 @@ func (c *structFieldCode) copy(codeMap map[uintptr]*opcode) *opcode { return code } field := &structFieldCode{ - key: c.key, - offset: c.offset, + key: c.key, + anonymousKey: c.anonymousKey, + anonymous: c.anonymous, + offset: c.offset, } code := (*opcode)(unsafe.Pointer(field)) codeMap[addr] = code @@ -1423,127 +508,6 @@ func newRecursiveCode(recursive *recursiveCode) *opcode { head.end.next = newEndOp(0) code.ptr = recursive.ptr - switch code.op { - case opStructFieldPtrHead: - code.op = opStructFieldHead - case opStructFieldPtrHeadInt: - code.op = opStructFieldHeadInt - case opStructFieldPtrHeadInt8: - code.op = opStructFieldHeadInt8 - case opStructFieldPtrHeadInt16: - code.op = opStructFieldHeadInt16 - case opStructFieldPtrHeadInt32: - code.op = opStructFieldHeadInt32 - case opStructFieldPtrHeadInt64: - code.op = opStructFieldHeadInt64 - case opStructFieldPtrHeadUint: - code.op = opStructFieldHeadUint - case opStructFieldPtrHeadUint8: - code.op = opStructFieldHeadUint8 - case opStructFieldPtrHeadUint16: - code.op = opStructFieldHeadUint16 - case opStructFieldPtrHeadUint32: - code.op = opStructFieldHeadUint32 - case opStructFieldPtrHeadUint64: - code.op = opStructFieldHeadUint64 - case opStructFieldPtrHeadFloat32: - code.op = opStructFieldHeadFloat32 - case opStructFieldPtrHeadFloat64: - code.op = opStructFieldHeadFloat64 - case opStructFieldPtrHeadString: - code.op = opStructFieldHeadString - case opStructFieldPtrHeadBool: - code.op = opStructFieldHeadBool - case opStructFieldPtrHeadIndent: - code.op = opStructFieldHeadIndent - case opStructFieldPtrHeadIntIndent: - code.op = opStructFieldHeadIntIndent - case opStructFieldPtrHeadInt8Indent: - code.op = opStructFieldHeadInt8Indent - case opStructFieldPtrHeadInt16Indent: - code.op = opStructFieldHeadInt16Indent - case opStructFieldPtrHeadInt32Indent: - code.op = opStructFieldHeadInt32Indent - case opStructFieldPtrHeadInt64Indent: - code.op = opStructFieldHeadInt64Indent - case opStructFieldPtrHeadUintIndent: - code.op = opStructFieldHeadUintIndent - case opStructFieldPtrHeadUint8Indent: - code.op = opStructFieldHeadUint8Indent - case opStructFieldPtrHeadUint16Indent: - code.op = opStructFieldHeadUint16Indent - case opStructFieldPtrHeadUint32Indent: - code.op = opStructFieldHeadUint32Indent - case opStructFieldPtrHeadUint64Indent: - code.op = opStructFieldHeadUint64Indent - case opStructFieldPtrHeadFloat32Indent: - code.op = opStructFieldHeadFloat32Indent - case opStructFieldPtrHeadFloat64Indent: - code.op = opStructFieldHeadFloat64Indent - case opStructFieldPtrHeadStringIndent: - code.op = opStructFieldHeadStringIndent - case opStructFieldPtrHeadBoolIndent: - code.op = opStructFieldHeadBoolIndent - case opStructFieldPtrHeadOmitEmpty: - code.op = opStructFieldHeadOmitEmpty - case opStructFieldPtrHeadIntOmitEmpty: - code.op = opStructFieldHeadIntOmitEmpty - case opStructFieldPtrHeadInt8OmitEmpty: - code.op = opStructFieldHeadInt8OmitEmpty - case opStructFieldPtrHeadInt16OmitEmpty: - code.op = opStructFieldHeadInt16OmitEmpty - case opStructFieldPtrHeadInt32OmitEmpty: - code.op = opStructFieldHeadInt32OmitEmpty - case opStructFieldPtrHeadInt64OmitEmpty: - code.op = opStructFieldHeadInt64OmitEmpty - case opStructFieldPtrHeadUintOmitEmpty: - code.op = opStructFieldHeadUintOmitEmpty - case opStructFieldPtrHeadUint8OmitEmpty: - code.op = opStructFieldHeadUint8OmitEmpty - case opStructFieldPtrHeadUint16OmitEmpty: - code.op = opStructFieldHeadUint16OmitEmpty - case opStructFieldPtrHeadUint32OmitEmpty: - code.op = opStructFieldHeadUint32OmitEmpty - case opStructFieldPtrHeadUint64OmitEmpty: - code.op = opStructFieldHeadUint64OmitEmpty - case opStructFieldPtrHeadFloat32OmitEmpty: - code.op = opStructFieldHeadFloat32OmitEmpty - case opStructFieldPtrHeadFloat64OmitEmpty: - code.op = opStructFieldHeadFloat64OmitEmpty - case opStructFieldPtrHeadStringOmitEmpty: - code.op = opStructFieldHeadStringOmitEmpty - case opStructFieldPtrHeadBoolOmitEmpty: - code.op = opStructFieldHeadBoolOmitEmpty - case opStructFieldPtrHeadOmitEmptyIndent: - code.op = opStructFieldHeadOmitEmptyIndent - case opStructFieldPtrHeadIntOmitEmptyIndent: - code.op = opStructFieldHeadIntOmitEmptyIndent - case opStructFieldPtrHeadInt8OmitEmptyIndent: - code.op = opStructFieldHeadInt8OmitEmptyIndent - case opStructFieldPtrHeadInt16OmitEmptyIndent: - code.op = opStructFieldHeadInt16OmitEmptyIndent - case opStructFieldPtrHeadInt32OmitEmptyIndent: - code.op = opStructFieldHeadInt32OmitEmptyIndent - case opStructFieldPtrHeadInt64OmitEmptyIndent: - code.op = opStructFieldHeadInt64OmitEmptyIndent - case opStructFieldPtrHeadUintOmitEmptyIndent: - code.op = opStructFieldHeadUintOmitEmptyIndent - case opStructFieldPtrHeadUint8OmitEmptyIndent: - code.op = opStructFieldHeadUint8OmitEmptyIndent - case opStructFieldPtrHeadUint16OmitEmptyIndent: - code.op = opStructFieldHeadUint16OmitEmptyIndent - case opStructFieldPtrHeadUint32OmitEmptyIndent: - code.op = opStructFieldHeadUint32OmitEmptyIndent - case opStructFieldPtrHeadUint64OmitEmptyIndent: - code.op = opStructFieldHeadUint64OmitEmptyIndent - case opStructFieldPtrHeadFloat32OmitEmptyIndent: - code.op = opStructFieldHeadFloat32OmitEmptyIndent - case opStructFieldPtrHeadFloat64OmitEmptyIndent: - code.op = opStructFieldHeadFloat64OmitEmptyIndent - case opStructFieldPtrHeadStringOmitEmptyIndent: - code.op = opStructFieldHeadStringOmitEmptyIndent - case opStructFieldPtrHeadBoolOmitEmptyIndent: - code.op = opStructFieldHeadBoolOmitEmptyIndent - } + code.op = code.op.ptrHeadToHead() return code } diff --git a/encode_optype.go b/encode_optype.go new file mode 100644 index 0000000..c527a96 --- /dev/null +++ b/encode_optype.go @@ -0,0 +1,2929 @@ +// Code generated by cmd/generator. DO NOT EDIT! +package json + +type codeType int + +const ( + codeOp codeType = 0 + codeArrayHead codeType = 1 + codeArrayElem codeType = 2 + codeSliceHead codeType = 3 + codeSliceElem codeType = 4 + codeMapHead codeType = 5 + codeMapKey codeType = 6 + codeMapValue codeType = 7 + codeStructFieldRecursive codeType = 8 + codeStructField codeType = 9 +) + +type opType int + +const ( + opEnd opType = 0 + opInterface opType = 1 + opPtr opType = 2 + opMarshalJSON opType = 3 + opMarshalText opType = 4 + opSliceHead opType = 5 + opRootSliceHead opType = 6 + opSliceElem opType = 7 + opRootSliceElem opType = 8 + opSliceEnd opType = 9 + opArrayHead opType = 10 + opArrayElem opType = 11 + opArrayEnd opType = 12 + opMapHead opType = 13 + opMapHeadLoad opType = 14 + opRootMapHead opType = 15 + opMapKey opType = 16 + opRootMapKey opType = 17 + opMapValue opType = 18 + opMapEnd opType = 19 + opStructFieldHead opType = 20 + opStructFieldHeadOmitEmpty opType = 21 + opStructFieldAnonymousHead opType = 22 + opStructFieldPtrHead opType = 23 + opStructFieldPtrHeadOmitEmpty opType = 24 + opStructFieldPtrAnonymousHead opType = 25 + opStructField opType = 26 + opStructFieldOmitEmpty opType = 27 + opStructFieldRecursive opType = 28 + opStructEnd opType = 29 + opStructAnonymousEnd opType = 30 + opInt opType = 31 + opInt8 opType = 32 + opInt16 opType = 33 + opInt32 opType = 34 + opInt64 opType = 35 + opUint opType = 36 + opUint8 opType = 37 + opUint16 opType = 38 + opUint32 opType = 39 + opUint64 opType = 40 + opFloat32 opType = 41 + opFloat64 opType = 42 + opBool opType = 43 + opString opType = 44 + opStructFieldHeadInt opType = 45 + opStructFieldHeadInt8 opType = 46 + opStructFieldHeadInt16 opType = 47 + opStructFieldHeadInt32 opType = 48 + opStructFieldHeadInt64 opType = 49 + opStructFieldHeadUint opType = 50 + opStructFieldHeadUint8 opType = 51 + opStructFieldHeadUint16 opType = 52 + opStructFieldHeadUint32 opType = 53 + opStructFieldHeadUint64 opType = 54 + opStructFieldHeadFloat32 opType = 55 + opStructFieldHeadFloat64 opType = 56 + opStructFieldHeadBool opType = 57 + opStructFieldHeadString opType = 58 + opStructFieldHeadOmitEmptyInt opType = 59 + opStructFieldHeadOmitEmptyInt8 opType = 60 + opStructFieldHeadOmitEmptyInt16 opType = 61 + opStructFieldHeadOmitEmptyInt32 opType = 62 + opStructFieldHeadOmitEmptyInt64 opType = 63 + opStructFieldHeadOmitEmptyUint opType = 64 + opStructFieldHeadOmitEmptyUint8 opType = 65 + opStructFieldHeadOmitEmptyUint16 opType = 66 + opStructFieldHeadOmitEmptyUint32 opType = 67 + opStructFieldHeadOmitEmptyUint64 opType = 68 + opStructFieldHeadOmitEmptyFloat32 opType = 69 + opStructFieldHeadOmitEmptyFloat64 opType = 70 + opStructFieldHeadOmitEmptyBool opType = 71 + opStructFieldHeadOmitEmptyString opType = 72 + opStructFieldAnonymousHeadInt opType = 73 + opStructFieldAnonymousHeadInt8 opType = 74 + opStructFieldAnonymousHeadInt16 opType = 75 + opStructFieldAnonymousHeadInt32 opType = 76 + opStructFieldAnonymousHeadInt64 opType = 77 + opStructFieldAnonymousHeadUint opType = 78 + opStructFieldAnonymousHeadUint8 opType = 79 + opStructFieldAnonymousHeadUint16 opType = 80 + opStructFieldAnonymousHeadUint32 opType = 81 + opStructFieldAnonymousHeadUint64 opType = 82 + opStructFieldAnonymousHeadFloat32 opType = 83 + opStructFieldAnonymousHeadFloat64 opType = 84 + opStructFieldAnonymousHeadBool opType = 85 + opStructFieldAnonymousHeadString opType = 86 + opStructFieldPtrHeadInt opType = 87 + opStructFieldPtrHeadInt8 opType = 88 + opStructFieldPtrHeadInt16 opType = 89 + opStructFieldPtrHeadInt32 opType = 90 + opStructFieldPtrHeadInt64 opType = 91 + opStructFieldPtrHeadUint opType = 92 + opStructFieldPtrHeadUint8 opType = 93 + opStructFieldPtrHeadUint16 opType = 94 + opStructFieldPtrHeadUint32 opType = 95 + opStructFieldPtrHeadUint64 opType = 96 + opStructFieldPtrHeadFloat32 opType = 97 + opStructFieldPtrHeadFloat64 opType = 98 + opStructFieldPtrHeadBool opType = 99 + opStructFieldPtrHeadString opType = 100 + opStructFieldPtrHeadOmitEmptyInt opType = 101 + opStructFieldPtrHeadOmitEmptyInt8 opType = 102 + opStructFieldPtrHeadOmitEmptyInt16 opType = 103 + opStructFieldPtrHeadOmitEmptyInt32 opType = 104 + opStructFieldPtrHeadOmitEmptyInt64 opType = 105 + opStructFieldPtrHeadOmitEmptyUint opType = 106 + opStructFieldPtrHeadOmitEmptyUint8 opType = 107 + opStructFieldPtrHeadOmitEmptyUint16 opType = 108 + opStructFieldPtrHeadOmitEmptyUint32 opType = 109 + opStructFieldPtrHeadOmitEmptyUint64 opType = 110 + opStructFieldPtrHeadOmitEmptyFloat32 opType = 111 + opStructFieldPtrHeadOmitEmptyFloat64 opType = 112 + opStructFieldPtrHeadOmitEmptyBool opType = 113 + opStructFieldPtrHeadOmitEmptyString opType = 114 + opStructFieldPtrAnonymousHeadInt opType = 115 + opStructFieldPtrAnonymousHeadInt8 opType = 116 + opStructFieldPtrAnonymousHeadInt16 opType = 117 + opStructFieldPtrAnonymousHeadInt32 opType = 118 + opStructFieldPtrAnonymousHeadInt64 opType = 119 + opStructFieldPtrAnonymousHeadUint opType = 120 + opStructFieldPtrAnonymousHeadUint8 opType = 121 + opStructFieldPtrAnonymousHeadUint16 opType = 122 + opStructFieldPtrAnonymousHeadUint32 opType = 123 + opStructFieldPtrAnonymousHeadUint64 opType = 124 + opStructFieldPtrAnonymousHeadFloat32 opType = 125 + opStructFieldPtrAnonymousHeadFloat64 opType = 126 + opStructFieldPtrAnonymousHeadBool opType = 127 + opStructFieldPtrAnonymousHeadString opType = 128 + opStructFieldInt opType = 129 + opStructFieldInt8 opType = 130 + opStructFieldInt16 opType = 131 + opStructFieldInt32 opType = 132 + opStructFieldInt64 opType = 133 + opStructFieldUint opType = 134 + opStructFieldUint8 opType = 135 + opStructFieldUint16 opType = 136 + opStructFieldUint32 opType = 137 + opStructFieldUint64 opType = 138 + opStructFieldFloat32 opType = 139 + opStructFieldFloat64 opType = 140 + opStructFieldBool opType = 141 + opStructFieldString opType = 142 + opStructFieldOmitEmptyInt opType = 143 + opStructFieldOmitEmptyInt8 opType = 144 + opStructFieldOmitEmptyInt16 opType = 145 + opStructFieldOmitEmptyInt32 opType = 146 + opStructFieldOmitEmptyInt64 opType = 147 + opStructFieldOmitEmptyUint opType = 148 + opStructFieldOmitEmptyUint8 opType = 149 + opStructFieldOmitEmptyUint16 opType = 150 + opStructFieldOmitEmptyUint32 opType = 151 + opStructFieldOmitEmptyUint64 opType = 152 + opStructFieldOmitEmptyFloat32 opType = 153 + opStructFieldOmitEmptyFloat64 opType = 154 + opStructFieldOmitEmptyBool opType = 155 + opStructFieldOmitEmptyString opType = 156 + opEndIndent opType = 157 + opInterfaceIndent opType = 158 + opPtrIndent opType = 159 + opMarshalJSONIndent opType = 160 + opMarshalTextIndent opType = 161 + opSliceHeadIndent opType = 162 + opRootSliceHeadIndent opType = 163 + opSliceElemIndent opType = 164 + opRootSliceElemIndent opType = 165 + opSliceEndIndent opType = 166 + opArrayHeadIndent opType = 167 + opArrayElemIndent opType = 168 + opArrayEndIndent opType = 169 + opMapHeadIndent opType = 170 + opMapHeadLoadIndent opType = 171 + opRootMapHeadIndent opType = 172 + opMapKeyIndent opType = 173 + opRootMapKeyIndent opType = 174 + opMapValueIndent opType = 175 + opMapEndIndent opType = 176 + opStructFieldHeadIndent opType = 177 + opStructFieldHeadOmitEmptyIndent opType = 178 + opStructFieldAnonymousHeadIndent opType = 179 + opStructFieldPtrHeadIndent opType = 180 + opStructFieldPtrHeadOmitEmptyIndent opType = 181 + opStructFieldPtrAnonymousHeadIndent opType = 182 + opStructFieldIndent opType = 183 + opStructFieldOmitEmptyIndent opType = 184 + opStructFieldRecursiveIndent opType = 185 + opStructEndIndent opType = 186 + opStructAnonymousEndIndent opType = 187 + opIntIndent opType = 188 + opInt8Indent opType = 189 + opInt16Indent opType = 190 + opInt32Indent opType = 191 + opInt64Indent opType = 192 + opUintIndent opType = 193 + opUint8Indent opType = 194 + opUint16Indent opType = 195 + opUint32Indent opType = 196 + opUint64Indent opType = 197 + opFloat32Indent opType = 198 + opFloat64Indent opType = 199 + opBoolIndent opType = 200 + opStringIndent opType = 201 + opStructFieldHeadIntIndent opType = 202 + opStructFieldHeadInt8Indent opType = 203 + opStructFieldHeadInt16Indent opType = 204 + opStructFieldHeadInt32Indent opType = 205 + opStructFieldHeadInt64Indent opType = 206 + opStructFieldHeadUintIndent opType = 207 + opStructFieldHeadUint8Indent opType = 208 + opStructFieldHeadUint16Indent opType = 209 + opStructFieldHeadUint32Indent opType = 210 + opStructFieldHeadUint64Indent opType = 211 + opStructFieldHeadFloat32Indent opType = 212 + opStructFieldHeadFloat64Indent opType = 213 + opStructFieldHeadBoolIndent opType = 214 + opStructFieldHeadStringIndent opType = 215 + opStructFieldHeadOmitEmptyIntIndent opType = 216 + opStructFieldHeadOmitEmptyInt8Indent opType = 217 + opStructFieldHeadOmitEmptyInt16Indent opType = 218 + opStructFieldHeadOmitEmptyInt32Indent opType = 219 + opStructFieldHeadOmitEmptyInt64Indent opType = 220 + opStructFieldHeadOmitEmptyUintIndent opType = 221 + opStructFieldHeadOmitEmptyUint8Indent opType = 222 + opStructFieldHeadOmitEmptyUint16Indent opType = 223 + opStructFieldHeadOmitEmptyUint32Indent opType = 224 + opStructFieldHeadOmitEmptyUint64Indent opType = 225 + opStructFieldHeadOmitEmptyFloat32Indent opType = 226 + opStructFieldHeadOmitEmptyFloat64Indent opType = 227 + opStructFieldHeadOmitEmptyBoolIndent opType = 228 + opStructFieldHeadOmitEmptyStringIndent opType = 229 + opStructFieldAnonymousHeadIntIndent opType = 230 + opStructFieldAnonymousHeadInt8Indent opType = 231 + opStructFieldAnonymousHeadInt16Indent opType = 232 + opStructFieldAnonymousHeadInt32Indent opType = 233 + opStructFieldAnonymousHeadInt64Indent opType = 234 + opStructFieldAnonymousHeadUintIndent opType = 235 + opStructFieldAnonymousHeadUint8Indent opType = 236 + opStructFieldAnonymousHeadUint16Indent opType = 237 + opStructFieldAnonymousHeadUint32Indent opType = 238 + opStructFieldAnonymousHeadUint64Indent opType = 239 + opStructFieldAnonymousHeadFloat32Indent opType = 240 + opStructFieldAnonymousHeadFloat64Indent opType = 241 + opStructFieldAnonymousHeadBoolIndent opType = 242 + opStructFieldAnonymousHeadStringIndent opType = 243 + opStructFieldPtrHeadIntIndent opType = 244 + opStructFieldPtrHeadInt8Indent opType = 245 + opStructFieldPtrHeadInt16Indent opType = 246 + opStructFieldPtrHeadInt32Indent opType = 247 + opStructFieldPtrHeadInt64Indent opType = 248 + opStructFieldPtrHeadUintIndent opType = 249 + opStructFieldPtrHeadUint8Indent opType = 250 + opStructFieldPtrHeadUint16Indent opType = 251 + opStructFieldPtrHeadUint32Indent opType = 252 + opStructFieldPtrHeadUint64Indent opType = 253 + opStructFieldPtrHeadFloat32Indent opType = 254 + opStructFieldPtrHeadFloat64Indent opType = 255 + opStructFieldPtrHeadBoolIndent opType = 256 + opStructFieldPtrHeadStringIndent opType = 257 + opStructFieldPtrHeadOmitEmptyIntIndent opType = 258 + opStructFieldPtrHeadOmitEmptyInt8Indent opType = 259 + opStructFieldPtrHeadOmitEmptyInt16Indent opType = 260 + opStructFieldPtrHeadOmitEmptyInt32Indent opType = 261 + opStructFieldPtrHeadOmitEmptyInt64Indent opType = 262 + opStructFieldPtrHeadOmitEmptyUintIndent opType = 263 + opStructFieldPtrHeadOmitEmptyUint8Indent opType = 264 + opStructFieldPtrHeadOmitEmptyUint16Indent opType = 265 + opStructFieldPtrHeadOmitEmptyUint32Indent opType = 266 + opStructFieldPtrHeadOmitEmptyUint64Indent opType = 267 + opStructFieldPtrHeadOmitEmptyFloat32Indent opType = 268 + opStructFieldPtrHeadOmitEmptyFloat64Indent opType = 269 + opStructFieldPtrHeadOmitEmptyBoolIndent opType = 270 + opStructFieldPtrHeadOmitEmptyStringIndent opType = 271 + opStructFieldPtrAnonymousHeadIntIndent opType = 272 + opStructFieldPtrAnonymousHeadInt8Indent opType = 273 + opStructFieldPtrAnonymousHeadInt16Indent opType = 274 + opStructFieldPtrAnonymousHeadInt32Indent opType = 275 + opStructFieldPtrAnonymousHeadInt64Indent opType = 276 + opStructFieldPtrAnonymousHeadUintIndent opType = 277 + opStructFieldPtrAnonymousHeadUint8Indent opType = 278 + opStructFieldPtrAnonymousHeadUint16Indent opType = 279 + opStructFieldPtrAnonymousHeadUint32Indent opType = 280 + opStructFieldPtrAnonymousHeadUint64Indent opType = 281 + opStructFieldPtrAnonymousHeadFloat32Indent opType = 282 + opStructFieldPtrAnonymousHeadFloat64Indent opType = 283 + opStructFieldPtrAnonymousHeadBoolIndent opType = 284 + opStructFieldPtrAnonymousHeadStringIndent opType = 285 + opStructFieldIntIndent opType = 286 + opStructFieldInt8Indent opType = 287 + opStructFieldInt16Indent opType = 288 + opStructFieldInt32Indent opType = 289 + opStructFieldInt64Indent opType = 290 + opStructFieldUintIndent opType = 291 + opStructFieldUint8Indent opType = 292 + opStructFieldUint16Indent opType = 293 + opStructFieldUint32Indent opType = 294 + opStructFieldUint64Indent opType = 295 + opStructFieldFloat32Indent opType = 296 + opStructFieldFloat64Indent opType = 297 + opStructFieldBoolIndent opType = 298 + opStructFieldStringIndent opType = 299 + opStructFieldOmitEmptyIntIndent opType = 300 + opStructFieldOmitEmptyInt8Indent opType = 301 + opStructFieldOmitEmptyInt16Indent opType = 302 + opStructFieldOmitEmptyInt32Indent opType = 303 + opStructFieldOmitEmptyInt64Indent opType = 304 + opStructFieldOmitEmptyUintIndent opType = 305 + opStructFieldOmitEmptyUint8Indent opType = 306 + opStructFieldOmitEmptyUint16Indent opType = 307 + opStructFieldOmitEmptyUint32Indent opType = 308 + opStructFieldOmitEmptyUint64Indent opType = 309 + opStructFieldOmitEmptyFloat32Indent opType = 310 + opStructFieldOmitEmptyFloat64Indent opType = 311 + opStructFieldOmitEmptyBoolIndent opType = 312 + opStructFieldOmitEmptyStringIndent opType = 313 +) + +func (t opType) String() string { + switch t { + case opEnd: + return "End" + case opInterface: + return "Interface" + case opPtr: + return "Ptr" + case opMarshalJSON: + return "MarshalJSON" + case opMarshalText: + return "MarshalText" + case opSliceHead: + return "SliceHead" + case opRootSliceHead: + return "RootSliceHead" + case opSliceElem: + return "SliceElem" + case opRootSliceElem: + return "RootSliceElem" + case opSliceEnd: + return "SliceEnd" + case opArrayHead: + return "ArrayHead" + case opArrayElem: + return "ArrayElem" + case opArrayEnd: + return "ArrayEnd" + case opMapHead: + return "MapHead" + case opMapHeadLoad: + return "MapHeadLoad" + case opRootMapHead: + return "RootMapHead" + case opMapKey: + return "MapKey" + case opRootMapKey: + return "RootMapKey" + case opMapValue: + return "MapValue" + case opMapEnd: + return "MapEnd" + case opStructFieldHead: + return "StructFieldHead" + case opStructFieldHeadOmitEmpty: + return "StructFieldHeadOmitEmpty" + case opStructFieldAnonymousHead: + return "StructFieldAnonymousHead" + case opStructFieldPtrHead: + return "StructFieldPtrHead" + case opStructFieldPtrHeadOmitEmpty: + return "StructFieldPtrHeadOmitEmpty" + case opStructFieldPtrAnonymousHead: + return "StructFieldPtrAnonymousHead" + case opStructField: + return "StructField" + case opStructFieldOmitEmpty: + return "StructFieldOmitEmpty" + case opStructFieldRecursive: + return "StructFieldRecursive" + case opStructEnd: + return "StructEnd" + case opStructAnonymousEnd: + return "StructAnonymousEnd" + case opInt: + return "Int" + case opInt8: + return "Int8" + case opInt16: + return "Int16" + case opInt32: + return "Int32" + case opInt64: + return "Int64" + case opUint: + return "Uint" + case opUint8: + return "Uint8" + case opUint16: + return "Uint16" + case opUint32: + return "Uint32" + case opUint64: + return "Uint64" + case opFloat32: + return "Float32" + case opFloat64: + return "Float64" + case opBool: + return "Bool" + case opString: + return "String" + case opStructFieldHeadInt: + return "StructFieldHeadInt" + case opStructFieldHeadInt8: + return "StructFieldHeadInt8" + case opStructFieldHeadInt16: + return "StructFieldHeadInt16" + case opStructFieldHeadInt32: + return "StructFieldHeadInt32" + case opStructFieldHeadInt64: + return "StructFieldHeadInt64" + case opStructFieldHeadUint: + return "StructFieldHeadUint" + case opStructFieldHeadUint8: + return "StructFieldHeadUint8" + case opStructFieldHeadUint16: + return "StructFieldHeadUint16" + case opStructFieldHeadUint32: + return "StructFieldHeadUint32" + case opStructFieldHeadUint64: + return "StructFieldHeadUint64" + case opStructFieldHeadFloat32: + return "StructFieldHeadFloat32" + case opStructFieldHeadFloat64: + return "StructFieldHeadFloat64" + case opStructFieldHeadBool: + return "StructFieldHeadBool" + case opStructFieldHeadString: + return "StructFieldHeadString" + case opStructFieldHeadOmitEmptyInt: + return "StructFieldHeadOmitEmptyInt" + case opStructFieldHeadOmitEmptyInt8: + return "StructFieldHeadOmitEmptyInt8" + case opStructFieldHeadOmitEmptyInt16: + return "StructFieldHeadOmitEmptyInt16" + case opStructFieldHeadOmitEmptyInt32: + return "StructFieldHeadOmitEmptyInt32" + case opStructFieldHeadOmitEmptyInt64: + return "StructFieldHeadOmitEmptyInt64" + case opStructFieldHeadOmitEmptyUint: + return "StructFieldHeadOmitEmptyUint" + case opStructFieldHeadOmitEmptyUint8: + return "StructFieldHeadOmitEmptyUint8" + case opStructFieldHeadOmitEmptyUint16: + return "StructFieldHeadOmitEmptyUint16" + case opStructFieldHeadOmitEmptyUint32: + return "StructFieldHeadOmitEmptyUint32" + case opStructFieldHeadOmitEmptyUint64: + return "StructFieldHeadOmitEmptyUint64" + case opStructFieldHeadOmitEmptyFloat32: + return "StructFieldHeadOmitEmptyFloat32" + case opStructFieldHeadOmitEmptyFloat64: + return "StructFieldHeadOmitEmptyFloat64" + case opStructFieldHeadOmitEmptyBool: + return "StructFieldHeadOmitEmptyBool" + case opStructFieldHeadOmitEmptyString: + return "StructFieldHeadOmitEmptyString" + case opStructFieldAnonymousHeadInt: + return "StructFieldAnonymousHeadInt" + case opStructFieldAnonymousHeadInt8: + return "StructFieldAnonymousHeadInt8" + case opStructFieldAnonymousHeadInt16: + return "StructFieldAnonymousHeadInt16" + case opStructFieldAnonymousHeadInt32: + return "StructFieldAnonymousHeadInt32" + case opStructFieldAnonymousHeadInt64: + return "StructFieldAnonymousHeadInt64" + case opStructFieldAnonymousHeadUint: + return "StructFieldAnonymousHeadUint" + case opStructFieldAnonymousHeadUint8: + return "StructFieldAnonymousHeadUint8" + case opStructFieldAnonymousHeadUint16: + return "StructFieldAnonymousHeadUint16" + case opStructFieldAnonymousHeadUint32: + return "StructFieldAnonymousHeadUint32" + case opStructFieldAnonymousHeadUint64: + return "StructFieldAnonymousHeadUint64" + case opStructFieldAnonymousHeadFloat32: + return "StructFieldAnonymousHeadFloat32" + case opStructFieldAnonymousHeadFloat64: + return "StructFieldAnonymousHeadFloat64" + case opStructFieldAnonymousHeadBool: + return "StructFieldAnonymousHeadBool" + case opStructFieldAnonymousHeadString: + return "StructFieldAnonymousHeadString" + case opStructFieldPtrHeadInt: + return "StructFieldPtrHeadInt" + case opStructFieldPtrHeadInt8: + return "StructFieldPtrHeadInt8" + case opStructFieldPtrHeadInt16: + return "StructFieldPtrHeadInt16" + case opStructFieldPtrHeadInt32: + return "StructFieldPtrHeadInt32" + case opStructFieldPtrHeadInt64: + return "StructFieldPtrHeadInt64" + case opStructFieldPtrHeadUint: + return "StructFieldPtrHeadUint" + case opStructFieldPtrHeadUint8: + return "StructFieldPtrHeadUint8" + case opStructFieldPtrHeadUint16: + return "StructFieldPtrHeadUint16" + case opStructFieldPtrHeadUint32: + return "StructFieldPtrHeadUint32" + case opStructFieldPtrHeadUint64: + return "StructFieldPtrHeadUint64" + case opStructFieldPtrHeadFloat32: + return "StructFieldPtrHeadFloat32" + case opStructFieldPtrHeadFloat64: + return "StructFieldPtrHeadFloat64" + case opStructFieldPtrHeadBool: + return "StructFieldPtrHeadBool" + case opStructFieldPtrHeadString: + return "StructFieldPtrHeadString" + case opStructFieldPtrHeadOmitEmptyInt: + return "StructFieldPtrHeadOmitEmptyInt" + case opStructFieldPtrHeadOmitEmptyInt8: + return "StructFieldPtrHeadOmitEmptyInt8" + case opStructFieldPtrHeadOmitEmptyInt16: + return "StructFieldPtrHeadOmitEmptyInt16" + case opStructFieldPtrHeadOmitEmptyInt32: + return "StructFieldPtrHeadOmitEmptyInt32" + case opStructFieldPtrHeadOmitEmptyInt64: + return "StructFieldPtrHeadOmitEmptyInt64" + case opStructFieldPtrHeadOmitEmptyUint: + return "StructFieldPtrHeadOmitEmptyUint" + case opStructFieldPtrHeadOmitEmptyUint8: + return "StructFieldPtrHeadOmitEmptyUint8" + case opStructFieldPtrHeadOmitEmptyUint16: + return "StructFieldPtrHeadOmitEmptyUint16" + case opStructFieldPtrHeadOmitEmptyUint32: + return "StructFieldPtrHeadOmitEmptyUint32" + case opStructFieldPtrHeadOmitEmptyUint64: + return "StructFieldPtrHeadOmitEmptyUint64" + case opStructFieldPtrHeadOmitEmptyFloat32: + return "StructFieldPtrHeadOmitEmptyFloat32" + case opStructFieldPtrHeadOmitEmptyFloat64: + return "StructFieldPtrHeadOmitEmptyFloat64" + case opStructFieldPtrHeadOmitEmptyBool: + return "StructFieldPtrHeadOmitEmptyBool" + case opStructFieldPtrHeadOmitEmptyString: + return "StructFieldPtrHeadOmitEmptyString" + case opStructFieldPtrAnonymousHeadInt: + return "StructFieldPtrAnonymousHeadInt" + case opStructFieldPtrAnonymousHeadInt8: + return "StructFieldPtrAnonymousHeadInt8" + case opStructFieldPtrAnonymousHeadInt16: + return "StructFieldPtrAnonymousHeadInt16" + case opStructFieldPtrAnonymousHeadInt32: + return "StructFieldPtrAnonymousHeadInt32" + case opStructFieldPtrAnonymousHeadInt64: + return "StructFieldPtrAnonymousHeadInt64" + case opStructFieldPtrAnonymousHeadUint: + return "StructFieldPtrAnonymousHeadUint" + case opStructFieldPtrAnonymousHeadUint8: + return "StructFieldPtrAnonymousHeadUint8" + case opStructFieldPtrAnonymousHeadUint16: + return "StructFieldPtrAnonymousHeadUint16" + case opStructFieldPtrAnonymousHeadUint32: + return "StructFieldPtrAnonymousHeadUint32" + case opStructFieldPtrAnonymousHeadUint64: + return "StructFieldPtrAnonymousHeadUint64" + case opStructFieldPtrAnonymousHeadFloat32: + return "StructFieldPtrAnonymousHeadFloat32" + case opStructFieldPtrAnonymousHeadFloat64: + return "StructFieldPtrAnonymousHeadFloat64" + case opStructFieldPtrAnonymousHeadBool: + return "StructFieldPtrAnonymousHeadBool" + case opStructFieldPtrAnonymousHeadString: + return "StructFieldPtrAnonymousHeadString" + case opStructFieldInt: + return "StructFieldInt" + case opStructFieldInt8: + return "StructFieldInt8" + case opStructFieldInt16: + return "StructFieldInt16" + case opStructFieldInt32: + return "StructFieldInt32" + case opStructFieldInt64: + return "StructFieldInt64" + case opStructFieldUint: + return "StructFieldUint" + case opStructFieldUint8: + return "StructFieldUint8" + case opStructFieldUint16: + return "StructFieldUint16" + case opStructFieldUint32: + return "StructFieldUint32" + case opStructFieldUint64: + return "StructFieldUint64" + case opStructFieldFloat32: + return "StructFieldFloat32" + case opStructFieldFloat64: + return "StructFieldFloat64" + case opStructFieldBool: + return "StructFieldBool" + case opStructFieldString: + return "StructFieldString" + case opStructFieldOmitEmptyInt: + return "StructFieldOmitEmptyInt" + case opStructFieldOmitEmptyInt8: + return "StructFieldOmitEmptyInt8" + case opStructFieldOmitEmptyInt16: + return "StructFieldOmitEmptyInt16" + case opStructFieldOmitEmptyInt32: + return "StructFieldOmitEmptyInt32" + case opStructFieldOmitEmptyInt64: + return "StructFieldOmitEmptyInt64" + case opStructFieldOmitEmptyUint: + return "StructFieldOmitEmptyUint" + case opStructFieldOmitEmptyUint8: + return "StructFieldOmitEmptyUint8" + case opStructFieldOmitEmptyUint16: + return "StructFieldOmitEmptyUint16" + case opStructFieldOmitEmptyUint32: + return "StructFieldOmitEmptyUint32" + case opStructFieldOmitEmptyUint64: + return "StructFieldOmitEmptyUint64" + case opStructFieldOmitEmptyFloat32: + return "StructFieldOmitEmptyFloat32" + case opStructFieldOmitEmptyFloat64: + return "StructFieldOmitEmptyFloat64" + case opStructFieldOmitEmptyBool: + return "StructFieldOmitEmptyBool" + case opStructFieldOmitEmptyString: + return "StructFieldOmitEmptyString" + case opEndIndent: + return "EndIndent" + case opInterfaceIndent: + return "InterfaceIndent" + case opPtrIndent: + return "PtrIndent" + case opMarshalJSONIndent: + return "MarshalJSONIndent" + case opMarshalTextIndent: + return "MarshalTextIndent" + case opSliceHeadIndent: + return "SliceHeadIndent" + case opRootSliceHeadIndent: + return "RootSliceHeadIndent" + case opSliceElemIndent: + return "SliceElemIndent" + case opRootSliceElemIndent: + return "RootSliceElemIndent" + case opSliceEndIndent: + return "SliceEndIndent" + case opArrayHeadIndent: + return "ArrayHeadIndent" + case opArrayElemIndent: + return "ArrayElemIndent" + case opArrayEndIndent: + return "ArrayEndIndent" + case opMapHeadIndent: + return "MapHeadIndent" + case opMapHeadLoadIndent: + return "MapHeadLoadIndent" + case opRootMapHeadIndent: + return "RootMapHeadIndent" + case opMapKeyIndent: + return "MapKeyIndent" + case opRootMapKeyIndent: + return "RootMapKeyIndent" + case opMapValueIndent: + return "MapValueIndent" + case opMapEndIndent: + return "MapEndIndent" + case opStructFieldHeadIndent: + return "StructFieldHeadIndent" + case opStructFieldHeadOmitEmptyIndent: + return "StructFieldHeadOmitEmptyIndent" + case opStructFieldAnonymousHeadIndent: + return "StructFieldAnonymousHeadIndent" + case opStructFieldPtrHeadIndent: + return "StructFieldPtrHeadIndent" + case opStructFieldPtrHeadOmitEmptyIndent: + return "StructFieldPtrHeadOmitEmptyIndent" + case opStructFieldPtrAnonymousHeadIndent: + return "StructFieldPtrAnonymousHeadIndent" + case opStructFieldIndent: + return "StructFieldIndent" + case opStructFieldOmitEmptyIndent: + return "StructFieldOmitEmptyIndent" + case opStructFieldRecursiveIndent: + return "StructFieldRecursiveIndent" + case opStructEndIndent: + return "StructEndIndent" + case opStructAnonymousEndIndent: + return "StructAnonymousEndIndent" + case opIntIndent: + return "IntIndent" + case opInt8Indent: + return "Int8Indent" + case opInt16Indent: + return "Int16Indent" + case opInt32Indent: + return "Int32Indent" + case opInt64Indent: + return "Int64Indent" + case opUintIndent: + return "UintIndent" + case opUint8Indent: + return "Uint8Indent" + case opUint16Indent: + return "Uint16Indent" + case opUint32Indent: + return "Uint32Indent" + case opUint64Indent: + return "Uint64Indent" + case opFloat32Indent: + return "Float32Indent" + case opFloat64Indent: + return "Float64Indent" + case opBoolIndent: + return "BoolIndent" + case opStringIndent: + return "StringIndent" + case opStructFieldHeadIntIndent: + return "StructFieldHeadIntIndent" + case opStructFieldHeadInt8Indent: + return "StructFieldHeadInt8Indent" + case opStructFieldHeadInt16Indent: + return "StructFieldHeadInt16Indent" + case opStructFieldHeadInt32Indent: + return "StructFieldHeadInt32Indent" + case opStructFieldHeadInt64Indent: + return "StructFieldHeadInt64Indent" + case opStructFieldHeadUintIndent: + return "StructFieldHeadUintIndent" + case opStructFieldHeadUint8Indent: + return "StructFieldHeadUint8Indent" + case opStructFieldHeadUint16Indent: + return "StructFieldHeadUint16Indent" + case opStructFieldHeadUint32Indent: + return "StructFieldHeadUint32Indent" + case opStructFieldHeadUint64Indent: + return "StructFieldHeadUint64Indent" + case opStructFieldHeadFloat32Indent: + return "StructFieldHeadFloat32Indent" + case opStructFieldHeadFloat64Indent: + return "StructFieldHeadFloat64Indent" + case opStructFieldHeadBoolIndent: + return "StructFieldHeadBoolIndent" + case opStructFieldHeadStringIndent: + return "StructFieldHeadStringIndent" + case opStructFieldHeadOmitEmptyIntIndent: + return "StructFieldHeadOmitEmptyIntIndent" + case opStructFieldHeadOmitEmptyInt8Indent: + return "StructFieldHeadOmitEmptyInt8Indent" + case opStructFieldHeadOmitEmptyInt16Indent: + return "StructFieldHeadOmitEmptyInt16Indent" + case opStructFieldHeadOmitEmptyInt32Indent: + return "StructFieldHeadOmitEmptyInt32Indent" + case opStructFieldHeadOmitEmptyInt64Indent: + return "StructFieldHeadOmitEmptyInt64Indent" + case opStructFieldHeadOmitEmptyUintIndent: + return "StructFieldHeadOmitEmptyUintIndent" + case opStructFieldHeadOmitEmptyUint8Indent: + return "StructFieldHeadOmitEmptyUint8Indent" + case opStructFieldHeadOmitEmptyUint16Indent: + return "StructFieldHeadOmitEmptyUint16Indent" + case opStructFieldHeadOmitEmptyUint32Indent: + return "StructFieldHeadOmitEmptyUint32Indent" + case opStructFieldHeadOmitEmptyUint64Indent: + return "StructFieldHeadOmitEmptyUint64Indent" + case opStructFieldHeadOmitEmptyFloat32Indent: + return "StructFieldHeadOmitEmptyFloat32Indent" + case opStructFieldHeadOmitEmptyFloat64Indent: + return "StructFieldHeadOmitEmptyFloat64Indent" + case opStructFieldHeadOmitEmptyBoolIndent: + return "StructFieldHeadOmitEmptyBoolIndent" + case opStructFieldHeadOmitEmptyStringIndent: + return "StructFieldHeadOmitEmptyStringIndent" + case opStructFieldAnonymousHeadIntIndent: + return "StructFieldAnonymousHeadIntIndent" + case opStructFieldAnonymousHeadInt8Indent: + return "StructFieldAnonymousHeadInt8Indent" + case opStructFieldAnonymousHeadInt16Indent: + return "StructFieldAnonymousHeadInt16Indent" + case opStructFieldAnonymousHeadInt32Indent: + return "StructFieldAnonymousHeadInt32Indent" + case opStructFieldAnonymousHeadInt64Indent: + return "StructFieldAnonymousHeadInt64Indent" + case opStructFieldAnonymousHeadUintIndent: + return "StructFieldAnonymousHeadUintIndent" + case opStructFieldAnonymousHeadUint8Indent: + return "StructFieldAnonymousHeadUint8Indent" + case opStructFieldAnonymousHeadUint16Indent: + return "StructFieldAnonymousHeadUint16Indent" + case opStructFieldAnonymousHeadUint32Indent: + return "StructFieldAnonymousHeadUint32Indent" + case opStructFieldAnonymousHeadUint64Indent: + return "StructFieldAnonymousHeadUint64Indent" + case opStructFieldAnonymousHeadFloat32Indent: + return "StructFieldAnonymousHeadFloat32Indent" + case opStructFieldAnonymousHeadFloat64Indent: + return "StructFieldAnonymousHeadFloat64Indent" + case opStructFieldAnonymousHeadBoolIndent: + return "StructFieldAnonymousHeadBoolIndent" + case opStructFieldAnonymousHeadStringIndent: + return "StructFieldAnonymousHeadStringIndent" + case opStructFieldPtrHeadIntIndent: + return "StructFieldPtrHeadIntIndent" + case opStructFieldPtrHeadInt8Indent: + return "StructFieldPtrHeadInt8Indent" + case opStructFieldPtrHeadInt16Indent: + return "StructFieldPtrHeadInt16Indent" + case opStructFieldPtrHeadInt32Indent: + return "StructFieldPtrHeadInt32Indent" + case opStructFieldPtrHeadInt64Indent: + return "StructFieldPtrHeadInt64Indent" + case opStructFieldPtrHeadUintIndent: + return "StructFieldPtrHeadUintIndent" + case opStructFieldPtrHeadUint8Indent: + return "StructFieldPtrHeadUint8Indent" + case opStructFieldPtrHeadUint16Indent: + return "StructFieldPtrHeadUint16Indent" + case opStructFieldPtrHeadUint32Indent: + return "StructFieldPtrHeadUint32Indent" + case opStructFieldPtrHeadUint64Indent: + return "StructFieldPtrHeadUint64Indent" + case opStructFieldPtrHeadFloat32Indent: + return "StructFieldPtrHeadFloat32Indent" + case opStructFieldPtrHeadFloat64Indent: + return "StructFieldPtrHeadFloat64Indent" + case opStructFieldPtrHeadBoolIndent: + return "StructFieldPtrHeadBoolIndent" + case opStructFieldPtrHeadStringIndent: + return "StructFieldPtrHeadStringIndent" + case opStructFieldPtrHeadOmitEmptyIntIndent: + return "StructFieldPtrHeadOmitEmptyIntIndent" + case opStructFieldPtrHeadOmitEmptyInt8Indent: + return "StructFieldPtrHeadOmitEmptyInt8Indent" + case opStructFieldPtrHeadOmitEmptyInt16Indent: + return "StructFieldPtrHeadOmitEmptyInt16Indent" + case opStructFieldPtrHeadOmitEmptyInt32Indent: + return "StructFieldPtrHeadOmitEmptyInt32Indent" + case opStructFieldPtrHeadOmitEmptyInt64Indent: + return "StructFieldPtrHeadOmitEmptyInt64Indent" + case opStructFieldPtrHeadOmitEmptyUintIndent: + return "StructFieldPtrHeadOmitEmptyUintIndent" + case opStructFieldPtrHeadOmitEmptyUint8Indent: + return "StructFieldPtrHeadOmitEmptyUint8Indent" + case opStructFieldPtrHeadOmitEmptyUint16Indent: + return "StructFieldPtrHeadOmitEmptyUint16Indent" + case opStructFieldPtrHeadOmitEmptyUint32Indent: + return "StructFieldPtrHeadOmitEmptyUint32Indent" + case opStructFieldPtrHeadOmitEmptyUint64Indent: + return "StructFieldPtrHeadOmitEmptyUint64Indent" + case opStructFieldPtrHeadOmitEmptyFloat32Indent: + return "StructFieldPtrHeadOmitEmptyFloat32Indent" + case opStructFieldPtrHeadOmitEmptyFloat64Indent: + return "StructFieldPtrHeadOmitEmptyFloat64Indent" + case opStructFieldPtrHeadOmitEmptyBoolIndent: + return "StructFieldPtrHeadOmitEmptyBoolIndent" + case opStructFieldPtrHeadOmitEmptyStringIndent: + return "StructFieldPtrHeadOmitEmptyStringIndent" + case opStructFieldPtrAnonymousHeadIntIndent: + return "StructFieldPtrAnonymousHeadIntIndent" + case opStructFieldPtrAnonymousHeadInt8Indent: + return "StructFieldPtrAnonymousHeadInt8Indent" + case opStructFieldPtrAnonymousHeadInt16Indent: + return "StructFieldPtrAnonymousHeadInt16Indent" + case opStructFieldPtrAnonymousHeadInt32Indent: + return "StructFieldPtrAnonymousHeadInt32Indent" + case opStructFieldPtrAnonymousHeadInt64Indent: + return "StructFieldPtrAnonymousHeadInt64Indent" + case opStructFieldPtrAnonymousHeadUintIndent: + return "StructFieldPtrAnonymousHeadUintIndent" + case opStructFieldPtrAnonymousHeadUint8Indent: + return "StructFieldPtrAnonymousHeadUint8Indent" + case opStructFieldPtrAnonymousHeadUint16Indent: + return "StructFieldPtrAnonymousHeadUint16Indent" + case opStructFieldPtrAnonymousHeadUint32Indent: + return "StructFieldPtrAnonymousHeadUint32Indent" + case opStructFieldPtrAnonymousHeadUint64Indent: + return "StructFieldPtrAnonymousHeadUint64Indent" + case opStructFieldPtrAnonymousHeadFloat32Indent: + return "StructFieldPtrAnonymousHeadFloat32Indent" + case opStructFieldPtrAnonymousHeadFloat64Indent: + return "StructFieldPtrAnonymousHeadFloat64Indent" + case opStructFieldPtrAnonymousHeadBoolIndent: + return "StructFieldPtrAnonymousHeadBoolIndent" + case opStructFieldPtrAnonymousHeadStringIndent: + return "StructFieldPtrAnonymousHeadStringIndent" + case opStructFieldIntIndent: + return "StructFieldIntIndent" + case opStructFieldInt8Indent: + return "StructFieldInt8Indent" + case opStructFieldInt16Indent: + return "StructFieldInt16Indent" + case opStructFieldInt32Indent: + return "StructFieldInt32Indent" + case opStructFieldInt64Indent: + return "StructFieldInt64Indent" + case opStructFieldUintIndent: + return "StructFieldUintIndent" + case opStructFieldUint8Indent: + return "StructFieldUint8Indent" + case opStructFieldUint16Indent: + return "StructFieldUint16Indent" + case opStructFieldUint32Indent: + return "StructFieldUint32Indent" + case opStructFieldUint64Indent: + return "StructFieldUint64Indent" + case opStructFieldFloat32Indent: + return "StructFieldFloat32Indent" + case opStructFieldFloat64Indent: + return "StructFieldFloat64Indent" + case opStructFieldBoolIndent: + return "StructFieldBoolIndent" + case opStructFieldStringIndent: + return "StructFieldStringIndent" + case opStructFieldOmitEmptyIntIndent: + return "StructFieldOmitEmptyIntIndent" + case opStructFieldOmitEmptyInt8Indent: + return "StructFieldOmitEmptyInt8Indent" + case opStructFieldOmitEmptyInt16Indent: + return "StructFieldOmitEmptyInt16Indent" + case opStructFieldOmitEmptyInt32Indent: + return "StructFieldOmitEmptyInt32Indent" + case opStructFieldOmitEmptyInt64Indent: + return "StructFieldOmitEmptyInt64Indent" + case opStructFieldOmitEmptyUintIndent: + return "StructFieldOmitEmptyUintIndent" + case opStructFieldOmitEmptyUint8Indent: + return "StructFieldOmitEmptyUint8Indent" + case opStructFieldOmitEmptyUint16Indent: + return "StructFieldOmitEmptyUint16Indent" + case opStructFieldOmitEmptyUint32Indent: + return "StructFieldOmitEmptyUint32Indent" + case opStructFieldOmitEmptyUint64Indent: + return "StructFieldOmitEmptyUint64Indent" + case opStructFieldOmitEmptyFloat32Indent: + return "StructFieldOmitEmptyFloat32Indent" + case opStructFieldOmitEmptyFloat64Indent: + return "StructFieldOmitEmptyFloat64Indent" + case opStructFieldOmitEmptyBoolIndent: + return "StructFieldOmitEmptyBoolIndent" + case opStructFieldOmitEmptyStringIndent: + return "StructFieldOmitEmptyStringIndent" + } + return "" +} + +func (t opType) codeType() codeType { + switch t { + case opEnd: + return codeOp + case opInterface: + return codeOp + case opPtr: + return codeOp + case opMarshalJSON: + return codeOp + case opMarshalText: + return codeOp + case opSliceHead: + return codeSliceHead + case opRootSliceHead: + return codeSliceHead + case opSliceElem: + return codeSliceElem + case opRootSliceElem: + return codeSliceElem + case opSliceEnd: + return codeOp + case opArrayHead: + return codeArrayHead + case opArrayElem: + return codeArrayElem + case opArrayEnd: + return codeOp + case opMapHead: + return codeMapHead + case opMapHeadLoad: + return codeMapHead + case opRootMapHead: + return codeMapHead + case opMapKey: + return codeMapKey + case opRootMapKey: + return codeMapKey + case opMapValue: + return codeMapValue + case opMapEnd: + return codeOp + case opStructFieldHead: + return codeStructField + case opStructFieldHeadOmitEmpty: + return codeStructField + case opStructFieldAnonymousHead: + return codeStructField + case opStructFieldPtrHead: + return codeStructField + case opStructFieldPtrHeadOmitEmpty: + return codeStructField + case opStructFieldPtrAnonymousHead: + return codeStructField + case opStructField: + return codeStructField + case opStructFieldOmitEmpty: + return codeStructField + case opStructFieldRecursive: + return codeStructFieldRecursive + case opStructEnd: + return codeStructField + case opStructAnonymousEnd: + return codeStructField + case opInt: + return codeOp + case opInt8: + return codeOp + case opInt16: + return codeOp + case opInt32: + return codeOp + case opInt64: + return codeOp + case opUint: + return codeOp + case opUint8: + return codeOp + case opUint16: + return codeOp + case opUint32: + return codeOp + case opUint64: + return codeOp + case opFloat32: + return codeOp + case opFloat64: + return codeOp + case opBool: + return codeOp + case opString: + return codeOp + case opStructFieldHeadInt: + return codeStructField + case opStructFieldHeadInt8: + return codeStructField + case opStructFieldHeadInt16: + return codeStructField + case opStructFieldHeadInt32: + return codeStructField + case opStructFieldHeadInt64: + return codeStructField + case opStructFieldHeadUint: + return codeStructField + case opStructFieldHeadUint8: + return codeStructField + case opStructFieldHeadUint16: + return codeStructField + case opStructFieldHeadUint32: + return codeStructField + case opStructFieldHeadUint64: + return codeStructField + case opStructFieldHeadFloat32: + return codeStructField + case opStructFieldHeadFloat64: + return codeStructField + case opStructFieldHeadBool: + return codeStructField + case opStructFieldHeadString: + return codeStructField + case opStructFieldHeadOmitEmptyInt: + return codeStructField + case opStructFieldHeadOmitEmptyInt8: + return codeStructField + case opStructFieldHeadOmitEmptyInt16: + return codeStructField + case opStructFieldHeadOmitEmptyInt32: + return codeStructField + case opStructFieldHeadOmitEmptyInt64: + return codeStructField + case opStructFieldHeadOmitEmptyUint: + return codeStructField + case opStructFieldHeadOmitEmptyUint8: + return codeStructField + case opStructFieldHeadOmitEmptyUint16: + return codeStructField + case opStructFieldHeadOmitEmptyUint32: + return codeStructField + case opStructFieldHeadOmitEmptyUint64: + return codeStructField + case opStructFieldHeadOmitEmptyFloat32: + return codeStructField + case opStructFieldHeadOmitEmptyFloat64: + return codeStructField + case opStructFieldHeadOmitEmptyBool: + return codeStructField + case opStructFieldHeadOmitEmptyString: + return codeStructField + case opStructFieldAnonymousHeadInt: + return codeStructField + case opStructFieldAnonymousHeadInt8: + return codeStructField + case opStructFieldAnonymousHeadInt16: + return codeStructField + case opStructFieldAnonymousHeadInt32: + return codeStructField + case opStructFieldAnonymousHeadInt64: + return codeStructField + case opStructFieldAnonymousHeadUint: + return codeStructField + case opStructFieldAnonymousHeadUint8: + return codeStructField + case opStructFieldAnonymousHeadUint16: + return codeStructField + case opStructFieldAnonymousHeadUint32: + return codeStructField + case opStructFieldAnonymousHeadUint64: + return codeStructField + case opStructFieldAnonymousHeadFloat32: + return codeStructField + case opStructFieldAnonymousHeadFloat64: + return codeStructField + case opStructFieldAnonymousHeadBool: + return codeStructField + case opStructFieldAnonymousHeadString: + return codeStructField + case opStructFieldPtrHeadInt: + return codeStructField + case opStructFieldPtrHeadInt8: + return codeStructField + case opStructFieldPtrHeadInt16: + return codeStructField + case opStructFieldPtrHeadInt32: + return codeStructField + case opStructFieldPtrHeadInt64: + return codeStructField + case opStructFieldPtrHeadUint: + return codeStructField + case opStructFieldPtrHeadUint8: + return codeStructField + case opStructFieldPtrHeadUint16: + return codeStructField + case opStructFieldPtrHeadUint32: + return codeStructField + case opStructFieldPtrHeadUint64: + return codeStructField + case opStructFieldPtrHeadFloat32: + return codeStructField + case opStructFieldPtrHeadFloat64: + return codeStructField + case opStructFieldPtrHeadBool: + return codeStructField + case opStructFieldPtrHeadString: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt8: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt16: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt32: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt64: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint8: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint16: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint32: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint64: + return codeStructField + case opStructFieldPtrHeadOmitEmptyFloat32: + return codeStructField + case opStructFieldPtrHeadOmitEmptyFloat64: + return codeStructField + case opStructFieldPtrHeadOmitEmptyBool: + return codeStructField + case opStructFieldPtrHeadOmitEmptyString: + return codeStructField + case opStructFieldPtrAnonymousHeadInt: + return codeStructField + case opStructFieldPtrAnonymousHeadInt8: + return codeStructField + case opStructFieldPtrAnonymousHeadInt16: + return codeStructField + case opStructFieldPtrAnonymousHeadInt32: + return codeStructField + case opStructFieldPtrAnonymousHeadInt64: + return codeStructField + case opStructFieldPtrAnonymousHeadUint: + return codeStructField + case opStructFieldPtrAnonymousHeadUint8: + return codeStructField + case opStructFieldPtrAnonymousHeadUint16: + return codeStructField + case opStructFieldPtrAnonymousHeadUint32: + return codeStructField + case opStructFieldPtrAnonymousHeadUint64: + return codeStructField + case opStructFieldPtrAnonymousHeadFloat32: + return codeStructField + case opStructFieldPtrAnonymousHeadFloat64: + return codeStructField + case opStructFieldPtrAnonymousHeadBool: + return codeStructField + case opStructFieldPtrAnonymousHeadString: + return codeStructField + case opStructFieldInt: + return codeStructField + case opStructFieldInt8: + return codeStructField + case opStructFieldInt16: + return codeStructField + case opStructFieldInt32: + return codeStructField + case opStructFieldInt64: + return codeStructField + case opStructFieldUint: + return codeStructField + case opStructFieldUint8: + return codeStructField + case opStructFieldUint16: + return codeStructField + case opStructFieldUint32: + return codeStructField + case opStructFieldUint64: + return codeStructField + case opStructFieldFloat32: + return codeStructField + case opStructFieldFloat64: + return codeStructField + case opStructFieldBool: + return codeStructField + case opStructFieldString: + return codeStructField + case opStructFieldOmitEmptyInt: + return codeStructField + case opStructFieldOmitEmptyInt8: + return codeStructField + case opStructFieldOmitEmptyInt16: + return codeStructField + case opStructFieldOmitEmptyInt32: + return codeStructField + case opStructFieldOmitEmptyInt64: + return codeStructField + case opStructFieldOmitEmptyUint: + return codeStructField + case opStructFieldOmitEmptyUint8: + return codeStructField + case opStructFieldOmitEmptyUint16: + return codeStructField + case opStructFieldOmitEmptyUint32: + return codeStructField + case opStructFieldOmitEmptyUint64: + return codeStructField + case opStructFieldOmitEmptyFloat32: + return codeStructField + case opStructFieldOmitEmptyFloat64: + return codeStructField + case opStructFieldOmitEmptyBool: + return codeStructField + case opStructFieldOmitEmptyString: + return codeStructField + case opEndIndent: + return codeOp + case opInterfaceIndent: + return codeOp + case opPtrIndent: + return codeOp + case opMarshalJSONIndent: + return codeOp + case opMarshalTextIndent: + return codeOp + case opSliceHeadIndent: + return codeSliceHead + case opRootSliceHeadIndent: + return codeSliceHead + case opSliceElemIndent: + return codeSliceElem + case opRootSliceElemIndent: + return codeSliceElem + case opSliceEndIndent: + return codeOp + case opArrayHeadIndent: + return codeArrayHead + case opArrayElemIndent: + return codeArrayElem + case opArrayEndIndent: + return codeOp + case opMapHeadIndent: + return codeMapHead + case opMapHeadLoadIndent: + return codeMapHead + case opRootMapHeadIndent: + return codeMapHead + case opMapKeyIndent: + return codeMapKey + case opRootMapKeyIndent: + return codeMapKey + case opMapValueIndent: + return codeMapValue + case opMapEndIndent: + return codeOp + case opStructFieldHeadIndent: + return codeStructField + case opStructFieldHeadOmitEmptyIndent: + return codeStructField + case opStructFieldAnonymousHeadIndent: + return codeStructField + case opStructFieldPtrHeadIndent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyIndent: + return codeStructField + case opStructFieldPtrAnonymousHeadIndent: + return codeStructField + case opStructFieldIndent: + return codeStructField + case opStructFieldOmitEmptyIndent: + return codeStructField + case opStructFieldRecursiveIndent: + return codeStructFieldRecursive + case opStructEndIndent: + return codeStructField + case opStructAnonymousEndIndent: + return codeStructField + case opIntIndent: + return codeOp + case opInt8Indent: + return codeOp + case opInt16Indent: + return codeOp + case opInt32Indent: + return codeOp + case opInt64Indent: + return codeOp + case opUintIndent: + return codeOp + case opUint8Indent: + return codeOp + case opUint16Indent: + return codeOp + case opUint32Indent: + return codeOp + case opUint64Indent: + return codeOp + case opFloat32Indent: + return codeOp + case opFloat64Indent: + return codeOp + case opBoolIndent: + return codeOp + case opStringIndent: + return codeOp + case opStructFieldHeadIntIndent: + return codeStructField + case opStructFieldHeadInt8Indent: + return codeStructField + case opStructFieldHeadInt16Indent: + return codeStructField + case opStructFieldHeadInt32Indent: + return codeStructField + case opStructFieldHeadInt64Indent: + return codeStructField + case opStructFieldHeadUintIndent: + return codeStructField + case opStructFieldHeadUint8Indent: + return codeStructField + case opStructFieldHeadUint16Indent: + return codeStructField + case opStructFieldHeadUint32Indent: + return codeStructField + case opStructFieldHeadUint64Indent: + return codeStructField + case opStructFieldHeadFloat32Indent: + return codeStructField + case opStructFieldHeadFloat64Indent: + return codeStructField + case opStructFieldHeadBoolIndent: + return codeStructField + case opStructFieldHeadStringIndent: + return codeStructField + case opStructFieldHeadOmitEmptyIntIndent: + return codeStructField + case opStructFieldHeadOmitEmptyInt8Indent: + return codeStructField + case opStructFieldHeadOmitEmptyInt16Indent: + return codeStructField + case opStructFieldHeadOmitEmptyInt32Indent: + return codeStructField + case opStructFieldHeadOmitEmptyInt64Indent: + return codeStructField + case opStructFieldHeadOmitEmptyUintIndent: + return codeStructField + case opStructFieldHeadOmitEmptyUint8Indent: + return codeStructField + case opStructFieldHeadOmitEmptyUint16Indent: + return codeStructField + case opStructFieldHeadOmitEmptyUint32Indent: + return codeStructField + case opStructFieldHeadOmitEmptyUint64Indent: + return codeStructField + case opStructFieldHeadOmitEmptyFloat32Indent: + return codeStructField + case opStructFieldHeadOmitEmptyFloat64Indent: + return codeStructField + case opStructFieldHeadOmitEmptyBoolIndent: + return codeStructField + case opStructFieldHeadOmitEmptyStringIndent: + return codeStructField + case opStructFieldAnonymousHeadIntIndent: + return codeStructField + case opStructFieldAnonymousHeadInt8Indent: + return codeStructField + case opStructFieldAnonymousHeadInt16Indent: + return codeStructField + case opStructFieldAnonymousHeadInt32Indent: + return codeStructField + case opStructFieldAnonymousHeadInt64Indent: + return codeStructField + case opStructFieldAnonymousHeadUintIndent: + return codeStructField + case opStructFieldAnonymousHeadUint8Indent: + return codeStructField + case opStructFieldAnonymousHeadUint16Indent: + return codeStructField + case opStructFieldAnonymousHeadUint32Indent: + return codeStructField + case opStructFieldAnonymousHeadUint64Indent: + return codeStructField + case opStructFieldAnonymousHeadFloat32Indent: + return codeStructField + case opStructFieldAnonymousHeadFloat64Indent: + return codeStructField + case opStructFieldAnonymousHeadBoolIndent: + return codeStructField + case opStructFieldAnonymousHeadStringIndent: + return codeStructField + case opStructFieldPtrHeadIntIndent: + return codeStructField + case opStructFieldPtrHeadInt8Indent: + return codeStructField + case opStructFieldPtrHeadInt16Indent: + return codeStructField + case opStructFieldPtrHeadInt32Indent: + return codeStructField + case opStructFieldPtrHeadInt64Indent: + return codeStructField + case opStructFieldPtrHeadUintIndent: + return codeStructField + case opStructFieldPtrHeadUint8Indent: + return codeStructField + case opStructFieldPtrHeadUint16Indent: + return codeStructField + case opStructFieldPtrHeadUint32Indent: + return codeStructField + case opStructFieldPtrHeadUint64Indent: + return codeStructField + case opStructFieldPtrHeadFloat32Indent: + return codeStructField + case opStructFieldPtrHeadFloat64Indent: + return codeStructField + case opStructFieldPtrHeadBoolIndent: + return codeStructField + case opStructFieldPtrHeadStringIndent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyIntIndent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt8Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt16Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt32Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyInt64Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUintIndent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint8Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint16Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint32Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyUint64Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyFloat32Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyFloat64Indent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyBoolIndent: + return codeStructField + case opStructFieldPtrHeadOmitEmptyStringIndent: + return codeStructField + case opStructFieldPtrAnonymousHeadIntIndent: + return codeStructField + case opStructFieldPtrAnonymousHeadInt8Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadInt16Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadInt32Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadInt64Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadUintIndent: + return codeStructField + case opStructFieldPtrAnonymousHeadUint8Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadUint16Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadUint32Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadUint64Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadFloat32Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadFloat64Indent: + return codeStructField + case opStructFieldPtrAnonymousHeadBoolIndent: + return codeStructField + case opStructFieldPtrAnonymousHeadStringIndent: + return codeStructField + case opStructFieldIntIndent: + return codeStructField + case opStructFieldInt8Indent: + return codeStructField + case opStructFieldInt16Indent: + return codeStructField + case opStructFieldInt32Indent: + return codeStructField + case opStructFieldInt64Indent: + return codeStructField + case opStructFieldUintIndent: + return codeStructField + case opStructFieldUint8Indent: + return codeStructField + case opStructFieldUint16Indent: + return codeStructField + case opStructFieldUint32Indent: + return codeStructField + case opStructFieldUint64Indent: + return codeStructField + case opStructFieldFloat32Indent: + return codeStructField + case opStructFieldFloat64Indent: + return codeStructField + case opStructFieldBoolIndent: + return codeStructField + case opStructFieldStringIndent: + return codeStructField + case opStructFieldOmitEmptyIntIndent: + return codeStructField + case opStructFieldOmitEmptyInt8Indent: + return codeStructField + case opStructFieldOmitEmptyInt16Indent: + return codeStructField + case opStructFieldOmitEmptyInt32Indent: + return codeStructField + case opStructFieldOmitEmptyInt64Indent: + return codeStructField + case opStructFieldOmitEmptyUintIndent: + return codeStructField + case opStructFieldOmitEmptyUint8Indent: + return codeStructField + case opStructFieldOmitEmptyUint16Indent: + return codeStructField + case opStructFieldOmitEmptyUint32Indent: + return codeStructField + case opStructFieldOmitEmptyUint64Indent: + return codeStructField + case opStructFieldOmitEmptyFloat32Indent: + return codeStructField + case opStructFieldOmitEmptyFloat64Indent: + return codeStructField + case opStructFieldOmitEmptyBoolIndent: + return codeStructField + case opStructFieldOmitEmptyStringIndent: + return codeStructField + } + return codeOp +} + +func (t opType) toIndent() opType { + switch t { + case opEnd: + return opEndIndent + case opInterface: + return opInterfaceIndent + case opPtr: + return opPtrIndent + case opMarshalJSON: + return opMarshalJSONIndent + case opMarshalText: + return opMarshalTextIndent + case opSliceHead: + return opSliceHeadIndent + case opRootSliceHead: + return opRootSliceHeadIndent + case opSliceElem: + return opSliceElemIndent + case opRootSliceElem: + return opRootSliceElemIndent + case opSliceEnd: + return opSliceEndIndent + case opArrayHead: + return opArrayHeadIndent + case opArrayElem: + return opArrayElemIndent + case opArrayEnd: + return opArrayEndIndent + case opMapHead: + return opMapHeadIndent + case opMapHeadLoad: + return opMapHeadLoadIndent + case opRootMapHead: + return opRootMapHeadIndent + case opMapKey: + return opMapKeyIndent + case opRootMapKey: + return opRootMapKeyIndent + case opMapValue: + return opMapValueIndent + case opMapEnd: + return opMapEndIndent + case opStructFieldHead: + return opStructFieldHeadIndent + case opStructFieldHeadOmitEmpty: + return opStructFieldHeadOmitEmptyIndent + case opStructFieldAnonymousHead: + return opStructFieldAnonymousHeadIndent + case opStructFieldPtrHead: + return opStructFieldPtrHeadIndent + case opStructFieldPtrHeadOmitEmpty: + return opStructFieldPtrHeadOmitEmptyIndent + case opStructFieldPtrAnonymousHead: + return opStructFieldPtrAnonymousHeadIndent + case opStructField: + return opStructFieldIndent + case opStructFieldOmitEmpty: + return opStructFieldOmitEmptyIndent + case opStructFieldRecursive: + return opStructFieldRecursiveIndent + case opStructEnd: + return opStructEndIndent + case opStructAnonymousEnd: + return opStructAnonymousEndIndent + case opInt: + return opIntIndent + case opInt8: + return opInt8Indent + case opInt16: + return opInt16Indent + case opInt32: + return opInt32Indent + case opInt64: + return opInt64Indent + case opUint: + return opUintIndent + case opUint8: + return opUint8Indent + case opUint16: + return opUint16Indent + case opUint32: + return opUint32Indent + case opUint64: + return opUint64Indent + case opFloat32: + return opFloat32Indent + case opFloat64: + return opFloat64Indent + case opBool: + return opBoolIndent + case opString: + return opStringIndent + case opStructFieldHeadInt: + return opStructFieldHeadIntIndent + case opStructFieldHeadInt8: + return opStructFieldHeadInt8Indent + case opStructFieldHeadInt16: + return opStructFieldHeadInt16Indent + case opStructFieldHeadInt32: + return opStructFieldHeadInt32Indent + case opStructFieldHeadInt64: + return opStructFieldHeadInt64Indent + case opStructFieldHeadUint: + return opStructFieldHeadUintIndent + case opStructFieldHeadUint8: + return opStructFieldHeadUint8Indent + case opStructFieldHeadUint16: + return opStructFieldHeadUint16Indent + case opStructFieldHeadUint32: + return opStructFieldHeadUint32Indent + case opStructFieldHeadUint64: + return opStructFieldHeadUint64Indent + case opStructFieldHeadFloat32: + return opStructFieldHeadFloat32Indent + case opStructFieldHeadFloat64: + return opStructFieldHeadFloat64Indent + case opStructFieldHeadBool: + return opStructFieldHeadBoolIndent + case opStructFieldHeadString: + return opStructFieldHeadStringIndent + case opStructFieldHeadOmitEmptyInt: + return opStructFieldHeadOmitEmptyIntIndent + case opStructFieldHeadOmitEmptyInt8: + return opStructFieldHeadOmitEmptyInt8Indent + case opStructFieldHeadOmitEmptyInt16: + return opStructFieldHeadOmitEmptyInt16Indent + case opStructFieldHeadOmitEmptyInt32: + return opStructFieldHeadOmitEmptyInt32Indent + case opStructFieldHeadOmitEmptyInt64: + return opStructFieldHeadOmitEmptyInt64Indent + case opStructFieldHeadOmitEmptyUint: + return opStructFieldHeadOmitEmptyUintIndent + case opStructFieldHeadOmitEmptyUint8: + return opStructFieldHeadOmitEmptyUint8Indent + case opStructFieldHeadOmitEmptyUint16: + return opStructFieldHeadOmitEmptyUint16Indent + case opStructFieldHeadOmitEmptyUint32: + return opStructFieldHeadOmitEmptyUint32Indent + case opStructFieldHeadOmitEmptyUint64: + return opStructFieldHeadOmitEmptyUint64Indent + case opStructFieldHeadOmitEmptyFloat32: + return opStructFieldHeadOmitEmptyFloat32Indent + case opStructFieldHeadOmitEmptyFloat64: + return opStructFieldHeadOmitEmptyFloat64Indent + case opStructFieldHeadOmitEmptyBool: + return opStructFieldHeadOmitEmptyBoolIndent + case opStructFieldHeadOmitEmptyString: + return opStructFieldHeadOmitEmptyStringIndent + case opStructFieldAnonymousHeadInt: + return opStructFieldAnonymousHeadIntIndent + case opStructFieldAnonymousHeadInt8: + return opStructFieldAnonymousHeadInt8Indent + case opStructFieldAnonymousHeadInt16: + return opStructFieldAnonymousHeadInt16Indent + case opStructFieldAnonymousHeadInt32: + return opStructFieldAnonymousHeadInt32Indent + case opStructFieldAnonymousHeadInt64: + return opStructFieldAnonymousHeadInt64Indent + case opStructFieldAnonymousHeadUint: + return opStructFieldAnonymousHeadUintIndent + case opStructFieldAnonymousHeadUint8: + return opStructFieldAnonymousHeadUint8Indent + case opStructFieldAnonymousHeadUint16: + return opStructFieldAnonymousHeadUint16Indent + case opStructFieldAnonymousHeadUint32: + return opStructFieldAnonymousHeadUint32Indent + case opStructFieldAnonymousHeadUint64: + return opStructFieldAnonymousHeadUint64Indent + case opStructFieldAnonymousHeadFloat32: + return opStructFieldAnonymousHeadFloat32Indent + case opStructFieldAnonymousHeadFloat64: + return opStructFieldAnonymousHeadFloat64Indent + case opStructFieldAnonymousHeadBool: + return opStructFieldAnonymousHeadBoolIndent + case opStructFieldAnonymousHeadString: + return opStructFieldAnonymousHeadStringIndent + case opStructFieldPtrHeadInt: + return opStructFieldPtrHeadIntIndent + case opStructFieldPtrHeadInt8: + return opStructFieldPtrHeadInt8Indent + case opStructFieldPtrHeadInt16: + return opStructFieldPtrHeadInt16Indent + case opStructFieldPtrHeadInt32: + return opStructFieldPtrHeadInt32Indent + case opStructFieldPtrHeadInt64: + return opStructFieldPtrHeadInt64Indent + case opStructFieldPtrHeadUint: + return opStructFieldPtrHeadUintIndent + case opStructFieldPtrHeadUint8: + return opStructFieldPtrHeadUint8Indent + case opStructFieldPtrHeadUint16: + return opStructFieldPtrHeadUint16Indent + case opStructFieldPtrHeadUint32: + return opStructFieldPtrHeadUint32Indent + case opStructFieldPtrHeadUint64: + return opStructFieldPtrHeadUint64Indent + case opStructFieldPtrHeadFloat32: + return opStructFieldPtrHeadFloat32Indent + case opStructFieldPtrHeadFloat64: + return opStructFieldPtrHeadFloat64Indent + case opStructFieldPtrHeadBool: + return opStructFieldPtrHeadBoolIndent + case opStructFieldPtrHeadString: + return opStructFieldPtrHeadStringIndent + case opStructFieldPtrHeadOmitEmptyInt: + return opStructFieldPtrHeadOmitEmptyIntIndent + case opStructFieldPtrHeadOmitEmptyInt8: + return opStructFieldPtrHeadOmitEmptyInt8Indent + case opStructFieldPtrHeadOmitEmptyInt16: + return opStructFieldPtrHeadOmitEmptyInt16Indent + case opStructFieldPtrHeadOmitEmptyInt32: + return opStructFieldPtrHeadOmitEmptyInt32Indent + case opStructFieldPtrHeadOmitEmptyInt64: + return opStructFieldPtrHeadOmitEmptyInt64Indent + case opStructFieldPtrHeadOmitEmptyUint: + return opStructFieldPtrHeadOmitEmptyUintIndent + case opStructFieldPtrHeadOmitEmptyUint8: + return opStructFieldPtrHeadOmitEmptyUint8Indent + case opStructFieldPtrHeadOmitEmptyUint16: + return opStructFieldPtrHeadOmitEmptyUint16Indent + case opStructFieldPtrHeadOmitEmptyUint32: + return opStructFieldPtrHeadOmitEmptyUint32Indent + case opStructFieldPtrHeadOmitEmptyUint64: + return opStructFieldPtrHeadOmitEmptyUint64Indent + case opStructFieldPtrHeadOmitEmptyFloat32: + return opStructFieldPtrHeadOmitEmptyFloat32Indent + case opStructFieldPtrHeadOmitEmptyFloat64: + return opStructFieldPtrHeadOmitEmptyFloat64Indent + case opStructFieldPtrHeadOmitEmptyBool: + return opStructFieldPtrHeadOmitEmptyBoolIndent + case opStructFieldPtrHeadOmitEmptyString: + return opStructFieldPtrHeadOmitEmptyStringIndent + case opStructFieldPtrAnonymousHeadInt: + return opStructFieldPtrAnonymousHeadIntIndent + case opStructFieldPtrAnonymousHeadInt8: + return opStructFieldPtrAnonymousHeadInt8Indent + case opStructFieldPtrAnonymousHeadInt16: + return opStructFieldPtrAnonymousHeadInt16Indent + case opStructFieldPtrAnonymousHeadInt32: + return opStructFieldPtrAnonymousHeadInt32Indent + case opStructFieldPtrAnonymousHeadInt64: + return opStructFieldPtrAnonymousHeadInt64Indent + case opStructFieldPtrAnonymousHeadUint: + return opStructFieldPtrAnonymousHeadUintIndent + case opStructFieldPtrAnonymousHeadUint8: + return opStructFieldPtrAnonymousHeadUint8Indent + case opStructFieldPtrAnonymousHeadUint16: + return opStructFieldPtrAnonymousHeadUint16Indent + case opStructFieldPtrAnonymousHeadUint32: + return opStructFieldPtrAnonymousHeadUint32Indent + case opStructFieldPtrAnonymousHeadUint64: + return opStructFieldPtrAnonymousHeadUint64Indent + case opStructFieldPtrAnonymousHeadFloat32: + return opStructFieldPtrAnonymousHeadFloat32Indent + case opStructFieldPtrAnonymousHeadFloat64: + return opStructFieldPtrAnonymousHeadFloat64Indent + case opStructFieldPtrAnonymousHeadBool: + return opStructFieldPtrAnonymousHeadBoolIndent + case opStructFieldPtrAnonymousHeadString: + return opStructFieldPtrAnonymousHeadStringIndent + case opStructFieldInt: + return opStructFieldIntIndent + case opStructFieldInt8: + return opStructFieldInt8Indent + case opStructFieldInt16: + return opStructFieldInt16Indent + case opStructFieldInt32: + return opStructFieldInt32Indent + case opStructFieldInt64: + return opStructFieldInt64Indent + case opStructFieldUint: + return opStructFieldUintIndent + case opStructFieldUint8: + return opStructFieldUint8Indent + case opStructFieldUint16: + return opStructFieldUint16Indent + case opStructFieldUint32: + return opStructFieldUint32Indent + case opStructFieldUint64: + return opStructFieldUint64Indent + case opStructFieldFloat32: + return opStructFieldFloat32Indent + case opStructFieldFloat64: + return opStructFieldFloat64Indent + case opStructFieldBool: + return opStructFieldBoolIndent + case opStructFieldString: + return opStructFieldStringIndent + case opStructFieldOmitEmptyInt: + return opStructFieldOmitEmptyIntIndent + case opStructFieldOmitEmptyInt8: + return opStructFieldOmitEmptyInt8Indent + case opStructFieldOmitEmptyInt16: + return opStructFieldOmitEmptyInt16Indent + case opStructFieldOmitEmptyInt32: + return opStructFieldOmitEmptyInt32Indent + case opStructFieldOmitEmptyInt64: + return opStructFieldOmitEmptyInt64Indent + case opStructFieldOmitEmptyUint: + return opStructFieldOmitEmptyUintIndent + case opStructFieldOmitEmptyUint8: + return opStructFieldOmitEmptyUint8Indent + case opStructFieldOmitEmptyUint16: + return opStructFieldOmitEmptyUint16Indent + case opStructFieldOmitEmptyUint32: + return opStructFieldOmitEmptyUint32Indent + case opStructFieldOmitEmptyUint64: + return opStructFieldOmitEmptyUint64Indent + case opStructFieldOmitEmptyFloat32: + return opStructFieldOmitEmptyFloat32Indent + case opStructFieldOmitEmptyFloat64: + return opStructFieldOmitEmptyFloat64Indent + case opStructFieldOmitEmptyBool: + return opStructFieldOmitEmptyBoolIndent + case opStructFieldOmitEmptyString: + return opStructFieldOmitEmptyStringIndent + case opEndIndent: + return opEndIndent + case opInterfaceIndent: + return opInterfaceIndent + case opPtrIndent: + return opPtrIndent + case opMarshalJSONIndent: + return opMarshalJSONIndent + case opMarshalTextIndent: + return opMarshalTextIndent + case opSliceHeadIndent: + return opSliceHeadIndent + case opRootSliceHeadIndent: + return opRootSliceHeadIndent + case opSliceElemIndent: + return opSliceElemIndent + case opRootSliceElemIndent: + return opRootSliceElemIndent + case opSliceEndIndent: + return opSliceEndIndent + case opArrayHeadIndent: + return opArrayHeadIndent + case opArrayElemIndent: + return opArrayElemIndent + case opArrayEndIndent: + return opArrayEndIndent + case opMapHeadIndent: + return opMapHeadIndent + case opMapHeadLoadIndent: + return opMapHeadLoadIndent + case opRootMapHeadIndent: + return opRootMapHeadIndent + case opMapKeyIndent: + return opMapKeyIndent + case opRootMapKeyIndent: + return opRootMapKeyIndent + case opMapValueIndent: + return opMapValueIndent + case opMapEndIndent: + return opMapEndIndent + case opStructFieldHeadIndent: + return opStructFieldHeadIndent + case opStructFieldHeadOmitEmptyIndent: + return opStructFieldHeadOmitEmptyIndent + case opStructFieldAnonymousHeadIndent: + return opStructFieldAnonymousHeadIndent + case opStructFieldPtrHeadIndent: + return opStructFieldPtrHeadIndent + case opStructFieldPtrHeadOmitEmptyIndent: + return opStructFieldPtrHeadOmitEmptyIndent + case opStructFieldPtrAnonymousHeadIndent: + return opStructFieldPtrAnonymousHeadIndent + case opStructFieldIndent: + return opStructFieldIndent + case opStructFieldOmitEmptyIndent: + return opStructFieldOmitEmptyIndent + case opStructFieldRecursiveIndent: + return opStructFieldRecursiveIndent + case opStructEndIndent: + return opStructEndIndent + case opStructAnonymousEndIndent: + return opStructAnonymousEndIndent + case opIntIndent: + return opIntIndent + case opInt8Indent: + return opInt8Indent + case opInt16Indent: + return opInt16Indent + case opInt32Indent: + return opInt32Indent + case opInt64Indent: + return opInt64Indent + case opUintIndent: + return opUintIndent + case opUint8Indent: + return opUint8Indent + case opUint16Indent: + return opUint16Indent + case opUint32Indent: + return opUint32Indent + case opUint64Indent: + return opUint64Indent + case opFloat32Indent: + return opFloat32Indent + case opFloat64Indent: + return opFloat64Indent + case opBoolIndent: + return opBoolIndent + case opStringIndent: + return opStringIndent + case opStructFieldHeadIntIndent: + return opStructFieldHeadIntIndent + case opStructFieldHeadInt8Indent: + return opStructFieldHeadInt8Indent + case opStructFieldHeadInt16Indent: + return opStructFieldHeadInt16Indent + case opStructFieldHeadInt32Indent: + return opStructFieldHeadInt32Indent + case opStructFieldHeadInt64Indent: + return opStructFieldHeadInt64Indent + case opStructFieldHeadUintIndent: + return opStructFieldHeadUintIndent + case opStructFieldHeadUint8Indent: + return opStructFieldHeadUint8Indent + case opStructFieldHeadUint16Indent: + return opStructFieldHeadUint16Indent + case opStructFieldHeadUint32Indent: + return opStructFieldHeadUint32Indent + case opStructFieldHeadUint64Indent: + return opStructFieldHeadUint64Indent + case opStructFieldHeadFloat32Indent: + return opStructFieldHeadFloat32Indent + case opStructFieldHeadFloat64Indent: + return opStructFieldHeadFloat64Indent + case opStructFieldHeadBoolIndent: + return opStructFieldHeadBoolIndent + case opStructFieldHeadStringIndent: + return opStructFieldHeadStringIndent + case opStructFieldHeadOmitEmptyIntIndent: + return opStructFieldHeadOmitEmptyIntIndent + case opStructFieldHeadOmitEmptyInt8Indent: + return opStructFieldHeadOmitEmptyInt8Indent + case opStructFieldHeadOmitEmptyInt16Indent: + return opStructFieldHeadOmitEmptyInt16Indent + case opStructFieldHeadOmitEmptyInt32Indent: + return opStructFieldHeadOmitEmptyInt32Indent + case opStructFieldHeadOmitEmptyInt64Indent: + return opStructFieldHeadOmitEmptyInt64Indent + case opStructFieldHeadOmitEmptyUintIndent: + return opStructFieldHeadOmitEmptyUintIndent + case opStructFieldHeadOmitEmptyUint8Indent: + return opStructFieldHeadOmitEmptyUint8Indent + case opStructFieldHeadOmitEmptyUint16Indent: + return opStructFieldHeadOmitEmptyUint16Indent + case opStructFieldHeadOmitEmptyUint32Indent: + return opStructFieldHeadOmitEmptyUint32Indent + case opStructFieldHeadOmitEmptyUint64Indent: + return opStructFieldHeadOmitEmptyUint64Indent + case opStructFieldHeadOmitEmptyFloat32Indent: + return opStructFieldHeadOmitEmptyFloat32Indent + case opStructFieldHeadOmitEmptyFloat64Indent: + return opStructFieldHeadOmitEmptyFloat64Indent + case opStructFieldHeadOmitEmptyBoolIndent: + return opStructFieldHeadOmitEmptyBoolIndent + case opStructFieldHeadOmitEmptyStringIndent: + return opStructFieldHeadOmitEmptyStringIndent + case opStructFieldAnonymousHeadIntIndent: + return opStructFieldAnonymousHeadIntIndent + case opStructFieldAnonymousHeadInt8Indent: + return opStructFieldAnonymousHeadInt8Indent + case opStructFieldAnonymousHeadInt16Indent: + return opStructFieldAnonymousHeadInt16Indent + case opStructFieldAnonymousHeadInt32Indent: + return opStructFieldAnonymousHeadInt32Indent + case opStructFieldAnonymousHeadInt64Indent: + return opStructFieldAnonymousHeadInt64Indent + case opStructFieldAnonymousHeadUintIndent: + return opStructFieldAnonymousHeadUintIndent + case opStructFieldAnonymousHeadUint8Indent: + return opStructFieldAnonymousHeadUint8Indent + case opStructFieldAnonymousHeadUint16Indent: + return opStructFieldAnonymousHeadUint16Indent + case opStructFieldAnonymousHeadUint32Indent: + return opStructFieldAnonymousHeadUint32Indent + case opStructFieldAnonymousHeadUint64Indent: + return opStructFieldAnonymousHeadUint64Indent + case opStructFieldAnonymousHeadFloat32Indent: + return opStructFieldAnonymousHeadFloat32Indent + case opStructFieldAnonymousHeadFloat64Indent: + return opStructFieldAnonymousHeadFloat64Indent + case opStructFieldAnonymousHeadBoolIndent: + return opStructFieldAnonymousHeadBoolIndent + case opStructFieldAnonymousHeadStringIndent: + return opStructFieldAnonymousHeadStringIndent + case opStructFieldPtrHeadIntIndent: + return opStructFieldPtrHeadIntIndent + case opStructFieldPtrHeadInt8Indent: + return opStructFieldPtrHeadInt8Indent + case opStructFieldPtrHeadInt16Indent: + return opStructFieldPtrHeadInt16Indent + case opStructFieldPtrHeadInt32Indent: + return opStructFieldPtrHeadInt32Indent + case opStructFieldPtrHeadInt64Indent: + return opStructFieldPtrHeadInt64Indent + case opStructFieldPtrHeadUintIndent: + return opStructFieldPtrHeadUintIndent + case opStructFieldPtrHeadUint8Indent: + return opStructFieldPtrHeadUint8Indent + case opStructFieldPtrHeadUint16Indent: + return opStructFieldPtrHeadUint16Indent + case opStructFieldPtrHeadUint32Indent: + return opStructFieldPtrHeadUint32Indent + case opStructFieldPtrHeadUint64Indent: + return opStructFieldPtrHeadUint64Indent + case opStructFieldPtrHeadFloat32Indent: + return opStructFieldPtrHeadFloat32Indent + case opStructFieldPtrHeadFloat64Indent: + return opStructFieldPtrHeadFloat64Indent + case opStructFieldPtrHeadBoolIndent: + return opStructFieldPtrHeadBoolIndent + case opStructFieldPtrHeadStringIndent: + return opStructFieldPtrHeadStringIndent + case opStructFieldPtrHeadOmitEmptyIntIndent: + return opStructFieldPtrHeadOmitEmptyIntIndent + case opStructFieldPtrHeadOmitEmptyInt8Indent: + return opStructFieldPtrHeadOmitEmptyInt8Indent + case opStructFieldPtrHeadOmitEmptyInt16Indent: + return opStructFieldPtrHeadOmitEmptyInt16Indent + case opStructFieldPtrHeadOmitEmptyInt32Indent: + return opStructFieldPtrHeadOmitEmptyInt32Indent + case opStructFieldPtrHeadOmitEmptyInt64Indent: + return opStructFieldPtrHeadOmitEmptyInt64Indent + case opStructFieldPtrHeadOmitEmptyUintIndent: + return opStructFieldPtrHeadOmitEmptyUintIndent + case opStructFieldPtrHeadOmitEmptyUint8Indent: + return opStructFieldPtrHeadOmitEmptyUint8Indent + case opStructFieldPtrHeadOmitEmptyUint16Indent: + return opStructFieldPtrHeadOmitEmptyUint16Indent + case opStructFieldPtrHeadOmitEmptyUint32Indent: + return opStructFieldPtrHeadOmitEmptyUint32Indent + case opStructFieldPtrHeadOmitEmptyUint64Indent: + return opStructFieldPtrHeadOmitEmptyUint64Indent + case opStructFieldPtrHeadOmitEmptyFloat32Indent: + return opStructFieldPtrHeadOmitEmptyFloat32Indent + case opStructFieldPtrHeadOmitEmptyFloat64Indent: + return opStructFieldPtrHeadOmitEmptyFloat64Indent + case opStructFieldPtrHeadOmitEmptyBoolIndent: + return opStructFieldPtrHeadOmitEmptyBoolIndent + case opStructFieldPtrHeadOmitEmptyStringIndent: + return opStructFieldPtrHeadOmitEmptyStringIndent + case opStructFieldPtrAnonymousHeadIntIndent: + return opStructFieldPtrAnonymousHeadIntIndent + case opStructFieldPtrAnonymousHeadInt8Indent: + return opStructFieldPtrAnonymousHeadInt8Indent + case opStructFieldPtrAnonymousHeadInt16Indent: + return opStructFieldPtrAnonymousHeadInt16Indent + case opStructFieldPtrAnonymousHeadInt32Indent: + return opStructFieldPtrAnonymousHeadInt32Indent + case opStructFieldPtrAnonymousHeadInt64Indent: + return opStructFieldPtrAnonymousHeadInt64Indent + case opStructFieldPtrAnonymousHeadUintIndent: + return opStructFieldPtrAnonymousHeadUintIndent + case opStructFieldPtrAnonymousHeadUint8Indent: + return opStructFieldPtrAnonymousHeadUint8Indent + case opStructFieldPtrAnonymousHeadUint16Indent: + return opStructFieldPtrAnonymousHeadUint16Indent + case opStructFieldPtrAnonymousHeadUint32Indent: + return opStructFieldPtrAnonymousHeadUint32Indent + case opStructFieldPtrAnonymousHeadUint64Indent: + return opStructFieldPtrAnonymousHeadUint64Indent + case opStructFieldPtrAnonymousHeadFloat32Indent: + return opStructFieldPtrAnonymousHeadFloat32Indent + case opStructFieldPtrAnonymousHeadFloat64Indent: + return opStructFieldPtrAnonymousHeadFloat64Indent + case opStructFieldPtrAnonymousHeadBoolIndent: + return opStructFieldPtrAnonymousHeadBoolIndent + case opStructFieldPtrAnonymousHeadStringIndent: + return opStructFieldPtrAnonymousHeadStringIndent + case opStructFieldIntIndent: + return opStructFieldIntIndent + case opStructFieldInt8Indent: + return opStructFieldInt8Indent + case opStructFieldInt16Indent: + return opStructFieldInt16Indent + case opStructFieldInt32Indent: + return opStructFieldInt32Indent + case opStructFieldInt64Indent: + return opStructFieldInt64Indent + case opStructFieldUintIndent: + return opStructFieldUintIndent + case opStructFieldUint8Indent: + return opStructFieldUint8Indent + case opStructFieldUint16Indent: + return opStructFieldUint16Indent + case opStructFieldUint32Indent: + return opStructFieldUint32Indent + case opStructFieldUint64Indent: + return opStructFieldUint64Indent + case opStructFieldFloat32Indent: + return opStructFieldFloat32Indent + case opStructFieldFloat64Indent: + return opStructFieldFloat64Indent + case opStructFieldBoolIndent: + return opStructFieldBoolIndent + case opStructFieldStringIndent: + return opStructFieldStringIndent + case opStructFieldOmitEmptyIntIndent: + return opStructFieldOmitEmptyIntIndent + case opStructFieldOmitEmptyInt8Indent: + return opStructFieldOmitEmptyInt8Indent + case opStructFieldOmitEmptyInt16Indent: + return opStructFieldOmitEmptyInt16Indent + case opStructFieldOmitEmptyInt32Indent: + return opStructFieldOmitEmptyInt32Indent + case opStructFieldOmitEmptyInt64Indent: + return opStructFieldOmitEmptyInt64Indent + case opStructFieldOmitEmptyUintIndent: + return opStructFieldOmitEmptyUintIndent + case opStructFieldOmitEmptyUint8Indent: + return opStructFieldOmitEmptyUint8Indent + case opStructFieldOmitEmptyUint16Indent: + return opStructFieldOmitEmptyUint16Indent + case opStructFieldOmitEmptyUint32Indent: + return opStructFieldOmitEmptyUint32Indent + case opStructFieldOmitEmptyUint64Indent: + return opStructFieldOmitEmptyUint64Indent + case opStructFieldOmitEmptyFloat32Indent: + return opStructFieldOmitEmptyFloat32Indent + case opStructFieldOmitEmptyFloat64Indent: + return opStructFieldOmitEmptyFloat64Indent + case opStructFieldOmitEmptyBoolIndent: + return opStructFieldOmitEmptyBoolIndent + case opStructFieldOmitEmptyStringIndent: + return opStructFieldOmitEmptyStringIndent + } + return t +} + +func (t opType) headToPtrHead() opType { + switch t { + case opStructFieldHead: + return opStructFieldPtrHead + case opStructFieldAnonymousHead: + return opStructFieldPtrAnonymousHead + case opStructFieldHeadOmitEmpty: + return opStructFieldPtrHeadOmitEmpty + case opStructFieldHeadInt: + return opStructFieldPtrHeadInt + case opStructFieldAnonymousHeadInt: + return opStructFieldPtrAnonymousHeadInt + case opStructFieldHeadOmitEmptyInt: + return opStructFieldPtrHeadOmitEmptyInt + case opStructFieldHeadInt8: + return opStructFieldPtrHeadInt8 + case opStructFieldAnonymousHeadInt8: + return opStructFieldPtrAnonymousHeadInt8 + case opStructFieldHeadOmitEmptyInt8: + return opStructFieldPtrHeadOmitEmptyInt8 + case opStructFieldHeadInt16: + return opStructFieldPtrHeadInt16 + case opStructFieldAnonymousHeadInt16: + return opStructFieldPtrAnonymousHeadInt16 + case opStructFieldHeadOmitEmptyInt16: + return opStructFieldPtrHeadOmitEmptyInt16 + case opStructFieldHeadInt32: + return opStructFieldPtrHeadInt32 + case opStructFieldAnonymousHeadInt32: + return opStructFieldPtrAnonymousHeadInt32 + case opStructFieldHeadOmitEmptyInt32: + return opStructFieldPtrHeadOmitEmptyInt32 + case opStructFieldHeadInt64: + return opStructFieldPtrHeadInt64 + case opStructFieldAnonymousHeadInt64: + return opStructFieldPtrAnonymousHeadInt64 + case opStructFieldHeadOmitEmptyInt64: + return opStructFieldPtrHeadOmitEmptyInt64 + case opStructFieldHeadUint: + return opStructFieldPtrHeadUint + case opStructFieldAnonymousHeadUint: + return opStructFieldPtrAnonymousHeadUint + case opStructFieldHeadOmitEmptyUint: + return opStructFieldPtrHeadOmitEmptyUint + case opStructFieldHeadUint8: + return opStructFieldPtrHeadUint8 + case opStructFieldAnonymousHeadUint8: + return opStructFieldPtrAnonymousHeadUint8 + case opStructFieldHeadOmitEmptyUint8: + return opStructFieldPtrHeadOmitEmptyUint8 + case opStructFieldHeadUint16: + return opStructFieldPtrHeadUint16 + case opStructFieldAnonymousHeadUint16: + return opStructFieldPtrAnonymousHeadUint16 + case opStructFieldHeadOmitEmptyUint16: + return opStructFieldPtrHeadOmitEmptyUint16 + case opStructFieldHeadUint32: + return opStructFieldPtrHeadUint32 + case opStructFieldAnonymousHeadUint32: + return opStructFieldPtrAnonymousHeadUint32 + case opStructFieldHeadOmitEmptyUint32: + return opStructFieldPtrHeadOmitEmptyUint32 + case opStructFieldHeadUint64: + return opStructFieldPtrHeadUint64 + case opStructFieldAnonymousHeadUint64: + return opStructFieldPtrAnonymousHeadUint64 + case opStructFieldHeadOmitEmptyUint64: + return opStructFieldPtrHeadOmitEmptyUint64 + case opStructFieldHeadFloat32: + return opStructFieldPtrHeadFloat32 + case opStructFieldAnonymousHeadFloat32: + return opStructFieldPtrAnonymousHeadFloat32 + case opStructFieldHeadOmitEmptyFloat32: + return opStructFieldPtrHeadOmitEmptyFloat32 + case opStructFieldHeadFloat64: + return opStructFieldPtrHeadFloat64 + case opStructFieldAnonymousHeadFloat64: + return opStructFieldPtrAnonymousHeadFloat64 + case opStructFieldHeadOmitEmptyFloat64: + return opStructFieldPtrHeadOmitEmptyFloat64 + case opStructFieldHeadBool: + return opStructFieldPtrHeadBool + case opStructFieldAnonymousHeadBool: + return opStructFieldPtrAnonymousHeadBool + case opStructFieldHeadOmitEmptyBool: + return opStructFieldPtrHeadOmitEmptyBool + case opStructFieldHeadString: + return opStructFieldPtrHeadString + case opStructFieldAnonymousHeadString: + return opStructFieldPtrAnonymousHeadString + case opStructFieldHeadOmitEmptyString: + return opStructFieldPtrHeadOmitEmptyString + case opStructFieldHeadIndent: + return opStructFieldPtrHeadIndent + case opStructFieldAnonymousHeadIndent: + return opStructFieldPtrAnonymousHeadIndent + case opStructFieldHeadOmitEmptyIndent: + return opStructFieldPtrHeadOmitEmptyIndent + case opStructFieldHeadIntIndent: + return opStructFieldPtrHeadIntIndent + case opStructFieldAnonymousHeadIntIndent: + return opStructFieldPtrAnonymousHeadIntIndent + case opStructFieldHeadOmitEmptyIntIndent: + return opStructFieldPtrHeadOmitEmptyIntIndent + case opStructFieldHeadInt8Indent: + return opStructFieldPtrHeadInt8Indent + case opStructFieldAnonymousHeadInt8Indent: + return opStructFieldPtrAnonymousHeadInt8Indent + case opStructFieldHeadOmitEmptyInt8Indent: + return opStructFieldPtrHeadOmitEmptyInt8Indent + case opStructFieldHeadInt16Indent: + return opStructFieldPtrHeadInt16Indent + case opStructFieldAnonymousHeadInt16Indent: + return opStructFieldPtrAnonymousHeadInt16Indent + case opStructFieldHeadOmitEmptyInt16Indent: + return opStructFieldPtrHeadOmitEmptyInt16Indent + case opStructFieldHeadInt32Indent: + return opStructFieldPtrHeadInt32Indent + case opStructFieldAnonymousHeadInt32Indent: + return opStructFieldPtrAnonymousHeadInt32Indent + case opStructFieldHeadOmitEmptyInt32Indent: + return opStructFieldPtrHeadOmitEmptyInt32Indent + case opStructFieldHeadInt64Indent: + return opStructFieldPtrHeadInt64Indent + case opStructFieldAnonymousHeadInt64Indent: + return opStructFieldPtrAnonymousHeadInt64Indent + case opStructFieldHeadOmitEmptyInt64Indent: + return opStructFieldPtrHeadOmitEmptyInt64Indent + case opStructFieldHeadUintIndent: + return opStructFieldPtrHeadUintIndent + case opStructFieldAnonymousHeadUintIndent: + return opStructFieldPtrAnonymousHeadUintIndent + case opStructFieldHeadOmitEmptyUintIndent: + return opStructFieldPtrHeadOmitEmptyUintIndent + case opStructFieldHeadUint8Indent: + return opStructFieldPtrHeadUint8Indent + case opStructFieldAnonymousHeadUint8Indent: + return opStructFieldPtrAnonymousHeadUint8Indent + case opStructFieldHeadOmitEmptyUint8Indent: + return opStructFieldPtrHeadOmitEmptyUint8Indent + case opStructFieldHeadUint16Indent: + return opStructFieldPtrHeadUint16Indent + case opStructFieldAnonymousHeadUint16Indent: + return opStructFieldPtrAnonymousHeadUint16Indent + case opStructFieldHeadOmitEmptyUint16Indent: + return opStructFieldPtrHeadOmitEmptyUint16Indent + case opStructFieldHeadUint32Indent: + return opStructFieldPtrHeadUint32Indent + case opStructFieldAnonymousHeadUint32Indent: + return opStructFieldPtrAnonymousHeadUint32Indent + case opStructFieldHeadOmitEmptyUint32Indent: + return opStructFieldPtrHeadOmitEmptyUint32Indent + case opStructFieldHeadUint64Indent: + return opStructFieldPtrHeadUint64Indent + case opStructFieldAnonymousHeadUint64Indent: + return opStructFieldPtrAnonymousHeadUint64Indent + case opStructFieldHeadOmitEmptyUint64Indent: + return opStructFieldPtrHeadOmitEmptyUint64Indent + case opStructFieldHeadFloat32Indent: + return opStructFieldPtrHeadFloat32Indent + case opStructFieldAnonymousHeadFloat32Indent: + return opStructFieldPtrAnonymousHeadFloat32Indent + case opStructFieldHeadOmitEmptyFloat32Indent: + return opStructFieldPtrHeadOmitEmptyFloat32Indent + case opStructFieldHeadFloat64Indent: + return opStructFieldPtrHeadFloat64Indent + case opStructFieldAnonymousHeadFloat64Indent: + return opStructFieldPtrAnonymousHeadFloat64Indent + case opStructFieldHeadOmitEmptyFloat64Indent: + return opStructFieldPtrHeadOmitEmptyFloat64Indent + case opStructFieldHeadBoolIndent: + return opStructFieldPtrHeadBoolIndent + case opStructFieldAnonymousHeadBoolIndent: + return opStructFieldPtrAnonymousHeadBoolIndent + case opStructFieldHeadOmitEmptyBoolIndent: + return opStructFieldPtrHeadOmitEmptyBoolIndent + case opStructFieldHeadStringIndent: + return opStructFieldPtrHeadStringIndent + case opStructFieldAnonymousHeadStringIndent: + return opStructFieldPtrAnonymousHeadStringIndent + case opStructFieldHeadOmitEmptyStringIndent: + return opStructFieldPtrHeadOmitEmptyStringIndent + } + return t +} + +func (t opType) headToAnonymousHead() opType { + switch t { + case opStructFieldHead: + return opStructFieldAnonymousHead + case opStructFieldPtrHead: + return opStructFieldPtrAnonymousHead + case opStructFieldHeadInt: + return opStructFieldAnonymousHeadInt + case opStructFieldPtrHeadInt: + return opStructFieldPtrAnonymousHeadInt + case opStructFieldHeadInt8: + return opStructFieldAnonymousHeadInt8 + case opStructFieldPtrHeadInt8: + return opStructFieldPtrAnonymousHeadInt8 + case opStructFieldHeadInt16: + return opStructFieldAnonymousHeadInt16 + case opStructFieldPtrHeadInt16: + return opStructFieldPtrAnonymousHeadInt16 + case opStructFieldHeadInt32: + return opStructFieldAnonymousHeadInt32 + case opStructFieldPtrHeadInt32: + return opStructFieldPtrAnonymousHeadInt32 + case opStructFieldHeadInt64: + return opStructFieldAnonymousHeadInt64 + case opStructFieldPtrHeadInt64: + return opStructFieldPtrAnonymousHeadInt64 + case opStructFieldHeadUint: + return opStructFieldAnonymousHeadUint + case opStructFieldPtrHeadUint: + return opStructFieldPtrAnonymousHeadUint + case opStructFieldHeadUint8: + return opStructFieldAnonymousHeadUint8 + case opStructFieldPtrHeadUint8: + return opStructFieldPtrAnonymousHeadUint8 + case opStructFieldHeadUint16: + return opStructFieldAnonymousHeadUint16 + case opStructFieldPtrHeadUint16: + return opStructFieldPtrAnonymousHeadUint16 + case opStructFieldHeadUint32: + return opStructFieldAnonymousHeadUint32 + case opStructFieldPtrHeadUint32: + return opStructFieldPtrAnonymousHeadUint32 + case opStructFieldHeadUint64: + return opStructFieldAnonymousHeadUint64 + case opStructFieldPtrHeadUint64: + return opStructFieldPtrAnonymousHeadUint64 + case opStructFieldHeadFloat32: + return opStructFieldAnonymousHeadFloat32 + case opStructFieldPtrHeadFloat32: + return opStructFieldPtrAnonymousHeadFloat32 + case opStructFieldHeadFloat64: + return opStructFieldAnonymousHeadFloat64 + case opStructFieldPtrHeadFloat64: + return opStructFieldPtrAnonymousHeadFloat64 + case opStructFieldHeadBool: + return opStructFieldAnonymousHeadBool + case opStructFieldPtrHeadBool: + return opStructFieldPtrAnonymousHeadBool + case opStructFieldHeadString: + return opStructFieldAnonymousHeadString + case opStructFieldPtrHeadString: + return opStructFieldPtrAnonymousHeadString + case opStructFieldHeadIndent: + return opStructFieldAnonymousHeadIndent + case opStructFieldPtrHeadIndent: + return opStructFieldPtrAnonymousHeadIndent + case opStructFieldHeadIntIndent: + return opStructFieldAnonymousHeadIntIndent + case opStructFieldPtrHeadIntIndent: + return opStructFieldPtrAnonymousHeadIntIndent + case opStructFieldHeadInt8Indent: + return opStructFieldAnonymousHeadInt8Indent + case opStructFieldPtrHeadInt8Indent: + return opStructFieldPtrAnonymousHeadInt8Indent + case opStructFieldHeadInt16Indent: + return opStructFieldAnonymousHeadInt16Indent + case opStructFieldPtrHeadInt16Indent: + return opStructFieldPtrAnonymousHeadInt16Indent + case opStructFieldHeadInt32Indent: + return opStructFieldAnonymousHeadInt32Indent + case opStructFieldPtrHeadInt32Indent: + return opStructFieldPtrAnonymousHeadInt32Indent + case opStructFieldHeadInt64Indent: + return opStructFieldAnonymousHeadInt64Indent + case opStructFieldPtrHeadInt64Indent: + return opStructFieldPtrAnonymousHeadInt64Indent + case opStructFieldHeadUintIndent: + return opStructFieldAnonymousHeadUintIndent + case opStructFieldPtrHeadUintIndent: + return opStructFieldPtrAnonymousHeadUintIndent + case opStructFieldHeadUint8Indent: + return opStructFieldAnonymousHeadUint8Indent + case opStructFieldPtrHeadUint8Indent: + return opStructFieldPtrAnonymousHeadUint8Indent + case opStructFieldHeadUint16Indent: + return opStructFieldAnonymousHeadUint16Indent + case opStructFieldPtrHeadUint16Indent: + return opStructFieldPtrAnonymousHeadUint16Indent + case opStructFieldHeadUint32Indent: + return opStructFieldAnonymousHeadUint32Indent + case opStructFieldPtrHeadUint32Indent: + return opStructFieldPtrAnonymousHeadUint32Indent + case opStructFieldHeadUint64Indent: + return opStructFieldAnonymousHeadUint64Indent + case opStructFieldPtrHeadUint64Indent: + return opStructFieldPtrAnonymousHeadUint64Indent + case opStructFieldHeadFloat32Indent: + return opStructFieldAnonymousHeadFloat32Indent + case opStructFieldPtrHeadFloat32Indent: + return opStructFieldPtrAnonymousHeadFloat32Indent + case opStructFieldHeadFloat64Indent: + return opStructFieldAnonymousHeadFloat64Indent + case opStructFieldPtrHeadFloat64Indent: + return opStructFieldPtrAnonymousHeadFloat64Indent + case opStructFieldHeadBoolIndent: + return opStructFieldAnonymousHeadBoolIndent + case opStructFieldPtrHeadBoolIndent: + return opStructFieldPtrAnonymousHeadBoolIndent + case opStructFieldHeadStringIndent: + return opStructFieldAnonymousHeadStringIndent + case opStructFieldPtrHeadStringIndent: + return opStructFieldPtrAnonymousHeadStringIndent + } + return t +} + +func (t opType) headToOmitEmptyHead() opType { + switch t { + case opStructFieldHead: + return opStructFieldHeadOmitEmpty + case opStructFieldPtrHead: + return opStructFieldPtrHeadOmitEmpty + case opStructFieldHeadInt: + return opStructFieldHeadOmitEmptyInt + case opStructFieldPtrHeadInt: + return opStructFieldPtrHeadOmitEmptyInt + case opStructFieldHeadInt8: + return opStructFieldHeadOmitEmptyInt8 + case opStructFieldPtrHeadInt8: + return opStructFieldPtrHeadOmitEmptyInt8 + case opStructFieldHeadInt16: + return opStructFieldHeadOmitEmptyInt16 + case opStructFieldPtrHeadInt16: + return opStructFieldPtrHeadOmitEmptyInt16 + case opStructFieldHeadInt32: + return opStructFieldHeadOmitEmptyInt32 + case opStructFieldPtrHeadInt32: + return opStructFieldPtrHeadOmitEmptyInt32 + case opStructFieldHeadInt64: + return opStructFieldHeadOmitEmptyInt64 + case opStructFieldPtrHeadInt64: + return opStructFieldPtrHeadOmitEmptyInt64 + case opStructFieldHeadUint: + return opStructFieldHeadOmitEmptyUint + case opStructFieldPtrHeadUint: + return opStructFieldPtrHeadOmitEmptyUint + case opStructFieldHeadUint8: + return opStructFieldHeadOmitEmptyUint8 + case opStructFieldPtrHeadUint8: + return opStructFieldPtrHeadOmitEmptyUint8 + case opStructFieldHeadUint16: + return opStructFieldHeadOmitEmptyUint16 + case opStructFieldPtrHeadUint16: + return opStructFieldPtrHeadOmitEmptyUint16 + case opStructFieldHeadUint32: + return opStructFieldHeadOmitEmptyUint32 + case opStructFieldPtrHeadUint32: + return opStructFieldPtrHeadOmitEmptyUint32 + case opStructFieldHeadUint64: + return opStructFieldHeadOmitEmptyUint64 + case opStructFieldPtrHeadUint64: + return opStructFieldPtrHeadOmitEmptyUint64 + case opStructFieldHeadFloat32: + return opStructFieldHeadOmitEmptyFloat32 + case opStructFieldPtrHeadFloat32: + return opStructFieldPtrHeadOmitEmptyFloat32 + case opStructFieldHeadFloat64: + return opStructFieldHeadOmitEmptyFloat64 + case opStructFieldPtrHeadFloat64: + return opStructFieldPtrHeadOmitEmptyFloat64 + case opStructFieldHeadBool: + return opStructFieldHeadOmitEmptyBool + case opStructFieldPtrHeadBool: + return opStructFieldPtrHeadOmitEmptyBool + case opStructFieldHeadString: + return opStructFieldHeadOmitEmptyString + case opStructFieldPtrHeadString: + return opStructFieldPtrHeadOmitEmptyString + case opStructFieldHeadIndent: + return opStructFieldHeadOmitEmptyIndent + case opStructFieldPtrHeadIndent: + return opStructFieldPtrHeadOmitEmptyIndent + case opStructFieldHeadIntIndent: + return opStructFieldHeadOmitEmptyIntIndent + case opStructFieldPtrHeadIntIndent: + return opStructFieldPtrHeadOmitEmptyIntIndent + case opStructFieldHeadInt8Indent: + return opStructFieldHeadOmitEmptyInt8Indent + case opStructFieldPtrHeadInt8Indent: + return opStructFieldPtrHeadOmitEmptyInt8Indent + case opStructFieldHeadInt16Indent: + return opStructFieldHeadOmitEmptyInt16Indent + case opStructFieldPtrHeadInt16Indent: + return opStructFieldPtrHeadOmitEmptyInt16Indent + case opStructFieldHeadInt32Indent: + return opStructFieldHeadOmitEmptyInt32Indent + case opStructFieldPtrHeadInt32Indent: + return opStructFieldPtrHeadOmitEmptyInt32Indent + case opStructFieldHeadInt64Indent: + return opStructFieldHeadOmitEmptyInt64Indent + case opStructFieldPtrHeadInt64Indent: + return opStructFieldPtrHeadOmitEmptyInt64Indent + case opStructFieldHeadUintIndent: + return opStructFieldHeadOmitEmptyUintIndent + case opStructFieldPtrHeadUintIndent: + return opStructFieldPtrHeadOmitEmptyUintIndent + case opStructFieldHeadUint8Indent: + return opStructFieldHeadOmitEmptyUint8Indent + case opStructFieldPtrHeadUint8Indent: + return opStructFieldPtrHeadOmitEmptyUint8Indent + case opStructFieldHeadUint16Indent: + return opStructFieldHeadOmitEmptyUint16Indent + case opStructFieldPtrHeadUint16Indent: + return opStructFieldPtrHeadOmitEmptyUint16Indent + case opStructFieldHeadUint32Indent: + return opStructFieldHeadOmitEmptyUint32Indent + case opStructFieldPtrHeadUint32Indent: + return opStructFieldPtrHeadOmitEmptyUint32Indent + case opStructFieldHeadUint64Indent: + return opStructFieldHeadOmitEmptyUint64Indent + case opStructFieldPtrHeadUint64Indent: + return opStructFieldPtrHeadOmitEmptyUint64Indent + case opStructFieldHeadFloat32Indent: + return opStructFieldHeadOmitEmptyFloat32Indent + case opStructFieldPtrHeadFloat32Indent: + return opStructFieldPtrHeadOmitEmptyFloat32Indent + case opStructFieldHeadFloat64Indent: + return opStructFieldHeadOmitEmptyFloat64Indent + case opStructFieldPtrHeadFloat64Indent: + return opStructFieldPtrHeadOmitEmptyFloat64Indent + case opStructFieldHeadBoolIndent: + return opStructFieldHeadOmitEmptyBoolIndent + case opStructFieldPtrHeadBoolIndent: + return opStructFieldPtrHeadOmitEmptyBoolIndent + case opStructFieldHeadStringIndent: + return opStructFieldHeadOmitEmptyStringIndent + case opStructFieldPtrHeadStringIndent: + return opStructFieldPtrHeadOmitEmptyStringIndent + } + return t +} + +func (t opType) ptrHeadToHead() opType { + switch t { + case opStructFieldPtrHead: + return opStructFieldHead + case opStructFieldPtrAnonymousHead: + return opStructFieldAnonymousHead + case opStructFieldPtrHeadOmitEmpty: + return opStructFieldHeadOmitEmpty + case opStructFieldPtrHeadInt: + return opStructFieldHeadInt + case opStructFieldPtrAnonymousHeadInt: + return opStructFieldAnonymousHeadInt + case opStructFieldPtrHeadOmitEmptyInt: + return opStructFieldHeadOmitEmptyInt + case opStructFieldPtrHeadInt8: + return opStructFieldHeadInt8 + case opStructFieldPtrAnonymousHeadInt8: + return opStructFieldAnonymousHeadInt8 + case opStructFieldPtrHeadOmitEmptyInt8: + return opStructFieldHeadOmitEmptyInt8 + case opStructFieldPtrHeadInt16: + return opStructFieldHeadInt16 + case opStructFieldPtrAnonymousHeadInt16: + return opStructFieldAnonymousHeadInt16 + case opStructFieldPtrHeadOmitEmptyInt16: + return opStructFieldHeadOmitEmptyInt16 + case opStructFieldPtrHeadInt32: + return opStructFieldHeadInt32 + case opStructFieldPtrAnonymousHeadInt32: + return opStructFieldAnonymousHeadInt32 + case opStructFieldPtrHeadOmitEmptyInt32: + return opStructFieldHeadOmitEmptyInt32 + case opStructFieldPtrHeadInt64: + return opStructFieldHeadInt64 + case opStructFieldPtrAnonymousHeadInt64: + return opStructFieldAnonymousHeadInt64 + case opStructFieldPtrHeadOmitEmptyInt64: + return opStructFieldHeadOmitEmptyInt64 + case opStructFieldPtrHeadUint: + return opStructFieldHeadUint + case opStructFieldPtrAnonymousHeadUint: + return opStructFieldAnonymousHeadUint + case opStructFieldPtrHeadOmitEmptyUint: + return opStructFieldHeadOmitEmptyUint + case opStructFieldPtrHeadUint8: + return opStructFieldHeadUint8 + case opStructFieldPtrAnonymousHeadUint8: + return opStructFieldAnonymousHeadUint8 + case opStructFieldPtrHeadOmitEmptyUint8: + return opStructFieldHeadOmitEmptyUint8 + case opStructFieldPtrHeadUint16: + return opStructFieldHeadUint16 + case opStructFieldPtrAnonymousHeadUint16: + return opStructFieldAnonymousHeadUint16 + case opStructFieldPtrHeadOmitEmptyUint16: + return opStructFieldHeadOmitEmptyUint16 + case opStructFieldPtrHeadUint32: + return opStructFieldHeadUint32 + case opStructFieldPtrAnonymousHeadUint32: + return opStructFieldAnonymousHeadUint32 + case opStructFieldPtrHeadOmitEmptyUint32: + return opStructFieldHeadOmitEmptyUint32 + case opStructFieldPtrHeadUint64: + return opStructFieldHeadUint64 + case opStructFieldPtrAnonymousHeadUint64: + return opStructFieldAnonymousHeadUint64 + case opStructFieldPtrHeadOmitEmptyUint64: + return opStructFieldHeadOmitEmptyUint64 + case opStructFieldPtrHeadFloat32: + return opStructFieldHeadFloat32 + case opStructFieldPtrAnonymousHeadFloat32: + return opStructFieldAnonymousHeadFloat32 + case opStructFieldPtrHeadOmitEmptyFloat32: + return opStructFieldHeadOmitEmptyFloat32 + case opStructFieldPtrHeadFloat64: + return opStructFieldHeadFloat64 + case opStructFieldPtrAnonymousHeadFloat64: + return opStructFieldAnonymousHeadFloat64 + case opStructFieldPtrHeadOmitEmptyFloat64: + return opStructFieldHeadOmitEmptyFloat64 + case opStructFieldPtrHeadBool: + return opStructFieldHeadBool + case opStructFieldPtrAnonymousHeadBool: + return opStructFieldAnonymousHeadBool + case opStructFieldPtrHeadOmitEmptyBool: + return opStructFieldHeadOmitEmptyBool + case opStructFieldPtrHeadString: + return opStructFieldHeadString + case opStructFieldPtrAnonymousHeadString: + return opStructFieldAnonymousHeadString + case opStructFieldPtrHeadOmitEmptyString: + return opStructFieldHeadOmitEmptyString + case opStructFieldPtrHeadIndent: + return opStructFieldHeadIndent + case opStructFieldPtrAnonymousHeadIndent: + return opStructFieldAnonymousHeadIndent + case opStructFieldPtrHeadOmitEmptyIndent: + return opStructFieldHeadOmitEmptyIndent + case opStructFieldPtrHeadIntIndent: + return opStructFieldHeadIntIndent + case opStructFieldPtrAnonymousHeadIntIndent: + return opStructFieldAnonymousHeadIntIndent + case opStructFieldPtrHeadOmitEmptyIntIndent: + return opStructFieldHeadOmitEmptyIntIndent + case opStructFieldPtrHeadInt8Indent: + return opStructFieldHeadInt8Indent + case opStructFieldPtrAnonymousHeadInt8Indent: + return opStructFieldAnonymousHeadInt8Indent + case opStructFieldPtrHeadOmitEmptyInt8Indent: + return opStructFieldHeadOmitEmptyInt8Indent + case opStructFieldPtrHeadInt16Indent: + return opStructFieldHeadInt16Indent + case opStructFieldPtrAnonymousHeadInt16Indent: + return opStructFieldAnonymousHeadInt16Indent + case opStructFieldPtrHeadOmitEmptyInt16Indent: + return opStructFieldHeadOmitEmptyInt16Indent + case opStructFieldPtrHeadInt32Indent: + return opStructFieldHeadInt32Indent + case opStructFieldPtrAnonymousHeadInt32Indent: + return opStructFieldAnonymousHeadInt32Indent + case opStructFieldPtrHeadOmitEmptyInt32Indent: + return opStructFieldHeadOmitEmptyInt32Indent + case opStructFieldPtrHeadInt64Indent: + return opStructFieldHeadInt64Indent + case opStructFieldPtrAnonymousHeadInt64Indent: + return opStructFieldAnonymousHeadInt64Indent + case opStructFieldPtrHeadOmitEmptyInt64Indent: + return opStructFieldHeadOmitEmptyInt64Indent + case opStructFieldPtrHeadUintIndent: + return opStructFieldHeadUintIndent + case opStructFieldPtrAnonymousHeadUintIndent: + return opStructFieldAnonymousHeadUintIndent + case opStructFieldPtrHeadOmitEmptyUintIndent: + return opStructFieldHeadOmitEmptyUintIndent + case opStructFieldPtrHeadUint8Indent: + return opStructFieldHeadUint8Indent + case opStructFieldPtrAnonymousHeadUint8Indent: + return opStructFieldAnonymousHeadUint8Indent + case opStructFieldPtrHeadOmitEmptyUint8Indent: + return opStructFieldHeadOmitEmptyUint8Indent + case opStructFieldPtrHeadUint16Indent: + return opStructFieldHeadUint16Indent + case opStructFieldPtrAnonymousHeadUint16Indent: + return opStructFieldAnonymousHeadUint16Indent + case opStructFieldPtrHeadOmitEmptyUint16Indent: + return opStructFieldHeadOmitEmptyUint16Indent + case opStructFieldPtrHeadUint32Indent: + return opStructFieldHeadUint32Indent + case opStructFieldPtrAnonymousHeadUint32Indent: + return opStructFieldAnonymousHeadUint32Indent + case opStructFieldPtrHeadOmitEmptyUint32Indent: + return opStructFieldHeadOmitEmptyUint32Indent + case opStructFieldPtrHeadUint64Indent: + return opStructFieldHeadUint64Indent + case opStructFieldPtrAnonymousHeadUint64Indent: + return opStructFieldAnonymousHeadUint64Indent + case opStructFieldPtrHeadOmitEmptyUint64Indent: + return opStructFieldHeadOmitEmptyUint64Indent + case opStructFieldPtrHeadFloat32Indent: + return opStructFieldHeadFloat32Indent + case opStructFieldPtrAnonymousHeadFloat32Indent: + return opStructFieldAnonymousHeadFloat32Indent + case opStructFieldPtrHeadOmitEmptyFloat32Indent: + return opStructFieldHeadOmitEmptyFloat32Indent + case opStructFieldPtrHeadFloat64Indent: + return opStructFieldHeadFloat64Indent + case opStructFieldPtrAnonymousHeadFloat64Indent: + return opStructFieldAnonymousHeadFloat64Indent + case opStructFieldPtrHeadOmitEmptyFloat64Indent: + return opStructFieldHeadOmitEmptyFloat64Indent + case opStructFieldPtrHeadBoolIndent: + return opStructFieldHeadBoolIndent + case opStructFieldPtrAnonymousHeadBoolIndent: + return opStructFieldAnonymousHeadBoolIndent + case opStructFieldPtrHeadOmitEmptyBoolIndent: + return opStructFieldHeadOmitEmptyBoolIndent + case opStructFieldPtrHeadStringIndent: + return opStructFieldHeadStringIndent + case opStructFieldPtrAnonymousHeadStringIndent: + return opStructFieldAnonymousHeadStringIndent + case opStructFieldPtrHeadOmitEmptyStringIndent: + return opStructFieldHeadOmitEmptyStringIndent + } + return t +} + +func (t opType) fieldToOmitEmptyField() opType { + switch t { + case opStructField: + return opStructFieldOmitEmpty + case opStructFieldInt: + return opStructFieldOmitEmptyInt + case opStructFieldInt8: + return opStructFieldOmitEmptyInt8 + case opStructFieldInt16: + return opStructFieldOmitEmptyInt16 + case opStructFieldInt32: + return opStructFieldOmitEmptyInt32 + case opStructFieldInt64: + return opStructFieldOmitEmptyInt64 + case opStructFieldUint: + return opStructFieldOmitEmptyUint + case opStructFieldUint8: + return opStructFieldOmitEmptyUint8 + case opStructFieldUint16: + return opStructFieldOmitEmptyUint16 + case opStructFieldUint32: + return opStructFieldOmitEmptyUint32 + case opStructFieldUint64: + return opStructFieldOmitEmptyUint64 + case opStructFieldFloat32: + return opStructFieldOmitEmptyFloat32 + case opStructFieldFloat64: + return opStructFieldOmitEmptyFloat64 + case opStructFieldBool: + return opStructFieldOmitEmptyBool + case opStructFieldString: + return opStructFieldOmitEmptyString + case opStructFieldIndent: + return opStructFieldOmitEmptyIndent + case opStructFieldIntIndent: + return opStructFieldOmitEmptyIntIndent + case opStructFieldInt8Indent: + return opStructFieldOmitEmptyInt8Indent + case opStructFieldInt16Indent: + return opStructFieldOmitEmptyInt16Indent + case opStructFieldInt32Indent: + return opStructFieldOmitEmptyInt32Indent + case opStructFieldInt64Indent: + return opStructFieldOmitEmptyInt64Indent + case opStructFieldUintIndent: + return opStructFieldOmitEmptyUintIndent + case opStructFieldUint8Indent: + return opStructFieldOmitEmptyUint8Indent + case opStructFieldUint16Indent: + return opStructFieldOmitEmptyUint16Indent + case opStructFieldUint32Indent: + return opStructFieldOmitEmptyUint32Indent + case opStructFieldUint64Indent: + return opStructFieldOmitEmptyUint64Indent + case opStructFieldFloat32Indent: + return opStructFieldOmitEmptyFloat32Indent + case opStructFieldFloat64Indent: + return opStructFieldOmitEmptyFloat64Indent + case opStructFieldBoolIndent: + return opStructFieldOmitEmptyBoolIndent + case opStructFieldStringIndent: + return opStructFieldOmitEmptyStringIndent + } + return t +} + diff --git a/encode_test.go b/encode_test.go index b1d0137..ead802d 100644 --- a/encode_test.go +++ b/encode_test.go @@ -140,16 +140,23 @@ func Test_Marshal(t *testing.T) { *T B string `json:"b"` } - v := &U{ - T: &T{ - A: "aaa", - }, - B: "bbb", - } - fmt.Printf("v.T = %p v.T.A = %p\n", v.T, &v.T.A) - bytes, err := json.Marshal(v) - assertErr(t, err) - assertEq(t, "embedded", `{"a":"aaa","b":"bbb"}`, string(bytes)) + t.Run("exists field", func(t *testing.T) { + bytes, err := json.Marshal(&U{ + T: &T{ + A: "aaa", + }, + B: "bbb", + }) + assertErr(t, err) + assertEq(t, "embedded", `{"a":"aaa","b":"bbb"}`, string(bytes)) + }) + t.Run("none field", func(t *testing.T) { + bytes, err := json.Marshal(&U{ + B: "bbb", + }) + assertErr(t, err) + assertEq(t, "embedded", `{"b":"bbb"}`, string(bytes)) + }) }) t.Run("omitempty", func(t *testing.T) { type T struct { diff --git a/encode_vm.go b/encode_vm.go index a591a8d..9991877 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -477,7 +477,9 @@ func (e *Encoder) run(code *opcode) error { code = field.end.next } else { e.encodeByte('{') - e.encodeBytes(field.key) + if !field.anonymousKey { + e.encodeBytes(field.key) + } code = field.next code.ptr = field.ptr + field.offset field.nextField.ptr = field.ptr @@ -494,8 +496,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeInt(e.ptrToInt(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeInt(e.ptrToInt(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadInt: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadInt: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeInt(e.ptrToInt(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadInt8: @@ -510,8 +526,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeInt8(e.ptrToInt8(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeInt8(e.ptrToInt8(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadInt8: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadInt8: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeInt8(e.ptrToInt8(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadInt16: @@ -526,8 +556,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeInt16(e.ptrToInt16(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeInt16(e.ptrToInt16(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadInt16: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadInt16: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeInt16(e.ptrToInt16(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadInt32: @@ -542,8 +586,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeInt32(e.ptrToInt32(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeInt32(e.ptrToInt32(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadInt32: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadInt32: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeInt32(e.ptrToInt32(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadInt64: @@ -558,8 +616,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeInt64(e.ptrToInt64(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeInt64(e.ptrToInt64(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadInt64: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadInt64: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeInt64(e.ptrToInt64(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadUint: @@ -574,8 +646,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeUint(e.ptrToUint(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeUint(e.ptrToUint(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadUint: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadUint: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeUint(e.ptrToUint(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadUint8: @@ -590,8 +676,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeUint8(e.ptrToUint8(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeUint8(e.ptrToUint8(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadUint8: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadUint8: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeUint8(e.ptrToUint8(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadUint16: @@ -606,8 +706,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeUint16(e.ptrToUint16(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeUint16(e.ptrToUint16(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadUint16: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadUint16: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeUint16(e.ptrToUint16(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadUint32: @@ -622,8 +736,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeUint32(e.ptrToUint32(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeUint32(e.ptrToUint32(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadUint32: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadUint32: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeUint32(e.ptrToUint32(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadUint64: @@ -638,8 +766,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeUint64(e.ptrToUint64(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeUint64(e.ptrToUint64(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadUint64: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadUint64: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeUint64(e.ptrToUint64(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadFloat32: @@ -654,8 +796,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeFloat32(e.ptrToFloat32(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeFloat32(e.ptrToFloat32(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadFloat32: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadFloat32: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeFloat32(e.ptrToFloat32(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadFloat64: @@ -668,7 +824,7 @@ func (e *Encoder) run(code *opcode) error { e.encodeNull() code = field.end } else { - v := e.ptrToFloat64(field.ptr + field.offset) + v := e.ptrToFloat64(ptr + field.offset) if math.IsInf(v, 0) || math.IsNaN(v) { return &UnsupportedValueError{ Value: reflect.ValueOf(v), @@ -678,7 +834,28 @@ func (e *Encoder) run(code *opcode) error { e.encodeByte('{') e.encodeBytes(field.key) e.encodeFloat64(v) - field.nextField.ptr = field.ptr + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadFloat64: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadFloat64: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + v := e.ptrToFloat64(ptr + field.offset) + if math.IsInf(v, 0) || math.IsNaN(v) { + return &UnsupportedValueError{ + Value: reflect.ValueOf(v), + Str: strconv.FormatFloat(v, 'g', -1, 64), + } + } + e.encodeBytes(field.key) + e.encodeFloat64(v) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadString: @@ -693,8 +870,22 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeString(e.ptrToString(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeString(e.ptrToString(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadString: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadString: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeString(e.ptrToString(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } case opStructFieldPtrHeadBool: @@ -709,11 +900,24 @@ func (e *Encoder) run(code *opcode) error { } else { e.encodeByte('{') e.encodeBytes(field.key) - e.encodeBool(e.ptrToBool(field.ptr + field.offset)) - field.nextField.ptr = field.ptr + e.encodeBool(e.ptrToBool(ptr + field.offset)) + field.nextField.ptr = ptr + code = field.next + } + case opStructFieldPtrAnonymousHeadBool: + code.ptr = e.ptrToPtr(code.ptr) + fallthrough + case opStructFieldAnonymousHeadBool: + field := code.toStructFieldCode() + ptr := field.ptr + if ptr == 0 { + code = field.end + } else { + e.encodeBytes(field.key) + e.encodeBool(e.ptrToBool(ptr + field.offset)) + field.nextField.ptr = ptr code = field.next } - case opStructFieldPtrHeadIndent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) @@ -1046,12 +1250,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadIntOmitEmpty: + case opStructFieldPtrHeadOmitEmptyInt: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadIntOmitEmpty: + case opStructFieldHeadOmitEmptyInt: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1071,12 +1275,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt8OmitEmpty: + case opStructFieldPtrHeadOmitEmptyInt8: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt8OmitEmpty: + case opStructFieldHeadOmitEmptyInt8: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1096,12 +1300,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt16OmitEmpty: + case opStructFieldPtrHeadOmitEmptyInt16: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt16OmitEmpty: + case opStructFieldHeadOmitEmptyInt16: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1121,12 +1325,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt32OmitEmpty: + case opStructFieldPtrHeadOmitEmptyInt32: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt32OmitEmpty: + case opStructFieldHeadOmitEmptyInt32: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1146,12 +1350,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt64OmitEmpty: + case opStructFieldPtrHeadOmitEmptyInt64: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt64OmitEmpty: + case opStructFieldHeadOmitEmptyInt64: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1171,12 +1375,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUintOmitEmpty: + case opStructFieldPtrHeadOmitEmptyUint: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUintOmitEmpty: + case opStructFieldHeadOmitEmptyUint: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1196,12 +1400,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint8OmitEmpty: + case opStructFieldPtrHeadOmitEmptyUint8: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint8OmitEmpty: + case opStructFieldHeadOmitEmptyUint8: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1221,12 +1425,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint16OmitEmpty: + case opStructFieldPtrHeadOmitEmptyUint16: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint16OmitEmpty: + case opStructFieldHeadOmitEmptyUint16: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1246,12 +1450,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint32OmitEmpty: + case opStructFieldPtrHeadOmitEmptyUint32: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint32OmitEmpty: + case opStructFieldHeadOmitEmptyUint32: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1271,12 +1475,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint64OmitEmpty: + case opStructFieldPtrHeadOmitEmptyUint64: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint64OmitEmpty: + case opStructFieldHeadOmitEmptyUint64: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1296,12 +1500,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadFloat32OmitEmpty: + case opStructFieldPtrHeadOmitEmptyFloat32: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadFloat32OmitEmpty: + case opStructFieldHeadOmitEmptyFloat32: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1321,12 +1525,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadFloat64OmitEmpty: + case opStructFieldPtrHeadOmitEmptyFloat64: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadFloat64OmitEmpty: + case opStructFieldHeadOmitEmptyFloat64: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1352,12 +1556,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadStringOmitEmpty: + case opStructFieldPtrHeadOmitEmptyString: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadStringOmitEmpty: + case opStructFieldHeadOmitEmptyString: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1377,12 +1581,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadBoolOmitEmpty: + case opStructFieldPtrHeadOmitEmptyBool: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadBoolOmitEmpty: + case opStructFieldHeadOmitEmptyBool: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1430,12 +1634,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadIntOmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyIntIndent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadIntOmitEmptyIndent: + case opStructFieldHeadOmitEmptyIntIndent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1457,12 +1661,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt8OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyInt8Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt8OmitEmptyIndent: + case opStructFieldHeadOmitEmptyInt8Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1484,12 +1688,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt16OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyInt16Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt16OmitEmptyIndent: + case opStructFieldHeadOmitEmptyInt16Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1511,12 +1715,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt32OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyInt32Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt32OmitEmptyIndent: + case opStructFieldHeadOmitEmptyInt32Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1538,12 +1742,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadInt64OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyInt64Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadInt64OmitEmptyIndent: + case opStructFieldHeadOmitEmptyInt64Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1565,12 +1769,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUintOmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyUintIndent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUintOmitEmptyIndent: + case opStructFieldHeadOmitEmptyUintIndent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1592,12 +1796,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint8OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyUint8Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint8OmitEmptyIndent: + case opStructFieldHeadOmitEmptyUint8Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1619,12 +1823,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint16OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyUint16Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint16OmitEmptyIndent: + case opStructFieldHeadOmitEmptyUint16Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1646,12 +1850,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint32OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyUint32Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint32OmitEmptyIndent: + case opStructFieldHeadOmitEmptyUint32Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1673,12 +1877,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadUint64OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyUint64Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadUint64OmitEmptyIndent: + case opStructFieldHeadOmitEmptyUint64Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1700,12 +1904,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadFloat32OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyFloat32Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadFloat32OmitEmptyIndent: + case opStructFieldHeadOmitEmptyFloat32Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1727,12 +1931,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadFloat64OmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyFloat64Indent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadFloat64OmitEmptyIndent: + case opStructFieldHeadOmitEmptyFloat64Indent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1760,12 +1964,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadStringOmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyStringIndent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadStringOmitEmptyIndent: + case opStructFieldHeadOmitEmptyStringIndent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -1787,12 +1991,12 @@ func (e *Encoder) run(code *opcode) error { } field.nextField.ptr = field.ptr } - case opStructFieldPtrHeadBoolOmitEmptyIndent: + case opStructFieldPtrHeadOmitEmptyBoolIndent: if code.ptr != 0 { code.ptr = e.ptrToPtr(code.ptr) } fallthrough - case opStructFieldHeadBoolOmitEmptyIndent: + case opStructFieldHeadOmitEmptyBoolIndent: field := code.toStructFieldCode() ptr := field.ptr if ptr == 0 { @@ -2143,7 +2347,7 @@ func (e *Encoder) run(code *opcode) error { code.ptr = p } c.nextField.ptr = c.ptr - case opStructFieldIntOmitEmpty: + case opStructFieldOmitEmptyInt: c := code.toStructFieldCode() v := e.ptrToInt(c.ptr + c.offset) if v != 0 { @@ -2155,7 +2359,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt8OmitEmpty: + case opStructFieldOmitEmptyInt8: c := code.toStructFieldCode() v := e.ptrToInt8(c.ptr + c.offset) if v != 0 { @@ -2167,7 +2371,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt16OmitEmpty: + case opStructFieldOmitEmptyInt16: c := code.toStructFieldCode() v := e.ptrToInt16(c.ptr + c.offset) if v != 0 { @@ -2179,7 +2383,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt32OmitEmpty: + case opStructFieldOmitEmptyInt32: c := code.toStructFieldCode() v := e.ptrToInt32(c.ptr + c.offset) if v != 0 { @@ -2191,7 +2395,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt64OmitEmpty: + case opStructFieldOmitEmptyInt64: c := code.toStructFieldCode() v := e.ptrToInt64(c.ptr + c.offset) if v != 0 { @@ -2203,7 +2407,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUintOmitEmpty: + case opStructFieldOmitEmptyUint: c := code.toStructFieldCode() v := e.ptrToUint(c.ptr + c.offset) if v != 0 { @@ -2215,7 +2419,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint8OmitEmpty: + case opStructFieldOmitEmptyUint8: c := code.toStructFieldCode() v := e.ptrToUint8(c.ptr + c.offset) if v != 0 { @@ -2227,7 +2431,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint16OmitEmpty: + case opStructFieldOmitEmptyUint16: c := code.toStructFieldCode() v := e.ptrToUint16(c.ptr + c.offset) if v != 0 { @@ -2239,7 +2443,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint32OmitEmpty: + case opStructFieldOmitEmptyUint32: c := code.toStructFieldCode() v := e.ptrToUint32(c.ptr + c.offset) if v != 0 { @@ -2251,7 +2455,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint64OmitEmpty: + case opStructFieldOmitEmptyUint64: c := code.toStructFieldCode() v := e.ptrToUint64(c.ptr + c.offset) if v != 0 { @@ -2263,7 +2467,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldFloat32OmitEmpty: + case opStructFieldOmitEmptyFloat32: c := code.toStructFieldCode() v := e.ptrToFloat32(c.ptr + c.offset) if v != 0 { @@ -2275,7 +2479,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldFloat64OmitEmpty: + case opStructFieldOmitEmptyFloat64: c := code.toStructFieldCode() v := e.ptrToFloat64(c.ptr + c.offset) if v != 0 { @@ -2293,7 +2497,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldStringOmitEmpty: + case opStructFieldOmitEmptyString: c := code.toStructFieldCode() v := e.ptrToString(c.ptr + c.offset) if v != "" { @@ -2305,7 +2509,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldBoolOmitEmpty: + case opStructFieldOmitEmptyBool: c := code.toStructFieldCode() v := e.ptrToBool(c.ptr + c.offset) if v { @@ -2334,7 +2538,7 @@ func (e *Encoder) run(code *opcode) error { code.ptr = p } c.nextField.ptr = c.ptr - case opStructFieldIntOmitEmptyIndent: + case opStructFieldOmitEmptyIntIndent: c := code.toStructFieldCode() v := e.ptrToInt(c.ptr + c.offset) if v != 0 { @@ -2348,7 +2552,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt8OmitEmptyIndent: + case opStructFieldOmitEmptyInt8Indent: c := code.toStructFieldCode() v := e.ptrToInt8(c.ptr + c.offset) if v != 0 { @@ -2362,7 +2566,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt16OmitEmptyIndent: + case opStructFieldOmitEmptyInt16Indent: c := code.toStructFieldCode() v := e.ptrToInt16(c.ptr + c.offset) if v != 0 { @@ -2376,7 +2580,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt32OmitEmptyIndent: + case opStructFieldOmitEmptyInt32Indent: c := code.toStructFieldCode() v := e.ptrToInt32(c.ptr + c.offset) if v != 0 { @@ -2390,7 +2594,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldInt64OmitEmptyIndent: + case opStructFieldOmitEmptyInt64Indent: c := code.toStructFieldCode() v := e.ptrToInt64(c.ptr + c.offset) if v != 0 { @@ -2404,7 +2608,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUintOmitEmptyIndent: + case opStructFieldOmitEmptyUintIndent: c := code.toStructFieldCode() v := e.ptrToUint(c.ptr + c.offset) if v != 0 { @@ -2418,7 +2622,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint8OmitEmptyIndent: + case opStructFieldOmitEmptyUint8Indent: c := code.toStructFieldCode() v := e.ptrToUint8(c.ptr + c.offset) if v != 0 { @@ -2432,7 +2636,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint16OmitEmptyIndent: + case opStructFieldOmitEmptyUint16Indent: c := code.toStructFieldCode() v := e.ptrToUint16(c.ptr + c.offset) if v != 0 { @@ -2446,7 +2650,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint32OmitEmptyIndent: + case opStructFieldOmitEmptyUint32Indent: c := code.toStructFieldCode() v := e.ptrToUint32(c.ptr + c.offset) if v != 0 { @@ -2460,7 +2664,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldUint64OmitEmptyIndent: + case opStructFieldOmitEmptyUint64Indent: c := code.toStructFieldCode() v := e.ptrToUint64(c.ptr + c.offset) if v != 0 { @@ -2474,7 +2678,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldFloat32OmitEmptyIndent: + case opStructFieldOmitEmptyFloat32Indent: c := code.toStructFieldCode() v := e.ptrToFloat32(c.ptr + c.offset) if v != 0 { @@ -2488,7 +2692,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldFloat64OmitEmptyIndent: + case opStructFieldOmitEmptyFloat64Indent: c := code.toStructFieldCode() v := e.ptrToFloat64(c.ptr + c.offset) if v != 0 { @@ -2508,7 +2712,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldStringOmitEmptyIndent: + case opStructFieldOmitEmptyStringIndent: c := code.toStructFieldCode() v := e.ptrToString(c.ptr + c.offset) if v != "" { @@ -2522,7 +2726,7 @@ func (e *Encoder) run(code *opcode) error { } code = code.next code.ptr = c.ptr - case opStructFieldBoolOmitEmptyIndent: + case opStructFieldOmitEmptyBoolIndent: c := code.toStructFieldCode() v := e.ptrToBool(c.ptr + c.offset) if v { @@ -2539,6 +2743,8 @@ func (e *Encoder) run(code *opcode) error { case opStructEnd: e.encodeByte('}') code = code.next + case opStructAnonymousEnd: + code = code.next case opStructEndIndent: e.encodeByte('\n') e.encodeIndent(code.indent)