// Code generated by internal/cmd/generator. DO NOT EDIT.
package vm_indent import ( ) func ( *encoder.RuntimeContext, []byte, *encoder.OpcodeSet) ([]byte, error) { := .Ptr() := .KeyCodes[.Option.Flag&encoder.KeyEscapeOptions] for { switch .Op { default: return , errUnimplementedOp(.Op) // The opcodes of a value of interface{} and of a map are first: the position of a case in the switch // changes the layout of the code of the VM, and these were the ones to suffer from it. case encoder.OpInterfacePtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpInterface: := load(, .Idx) // An interface value which holds nothing is null: its first word, the type or the itab, is nil. // It is decided here, as a call costs more than the check: the fields of interface{} of a struct // are nil in many a value. if == nil || (*(*unsafe.Pointer)() == nil && .Flags&encoder.StaticTypeFlags == 0) { = appendNullComma(, ) = .Next break } , , , := .EnterInterface(, ) if != nil { return , } if == nil { = appendNullComma(, ) = .Next break } if { , := appendScalar(, , , ) if != nil { return , } = = .Next break } = = case encoder.OpInterfaceEnd: , = .LeaveFrame() case encoder.OpStructFieldInterface: // The field of a value of interface{}: the key, and then what OpInterface does for the value. A field // of interface{} is nil in many a value, and it is null then, without a call. The cases are here, with // the ones of a value of interface{}, not with the other fields: there they cost the small structs 3%. := unsafe.Add(load(, .Idx), .Offset) = appendStructKey(, , ) if *(*unsafe.Pointer)() == nil && .Flags&encoder.StaticTypeFlags == 0 { = appendNullComma(, ) = .Next break } , , , := .EnterInterface(, ) if != nil { return , } if == nil { = appendNullComma(, ) = .Next break } if { , := appendScalar(, , , ) if != nil { return , } = = .Next break } = = case encoder.OpStructFieldOmitEmptyInterface: := unsafe.Add(load(, .Idx), .Offset) if *(*unsafe.Pointer)() == nil { = .NextField break } = appendStructKey(, , ) , , , := .EnterInterface(, ) if != nil { return , } if == nil { = appendNullComma(, ) = .Next break } if { , := appendScalar(, , , ) if != nil { return , } = = .Next break } = = case encoder.OpMapPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { if encoder.NilMapIsEmpty() { = appendEmptyObject(, ) } else { = appendNullComma(, ) } = .End.Next break } store(, .Idx, ) fallthrough case encoder.OpMap: := load(, .Idx) if == nil { if encoder.NilMapIsEmpty() { = appendEmptyObject(, ) } else { = appendNullComma(, ) } = .End.Next break } // The entries are read from the map into the context first ( encoder.MapLayout ), and encoded from // there: in the order of the map, or sorted by their keys when they are strings. The keys of a sorted // map which are not strings are encoded first, and the entries are written in the order of their names. := encoder.NewMapContext() if .RecursiveLevel > encoder.StartDetectingMapCyclesAfter && .Map.Cyclic { if := .RecordMap(, , ); != nil { return , } } if .Flags&encoder.MapStringKeyFlags != 0 && (.Map.ScalarValue || .Map.InterfaceValue) && .Option.Flag&encoder.UnorderedMapOption != 0 { // the entries are written as the map is read: all of them when the values are scalars, and the // ones which hold a scalar when the values are of interface{}, and the context gets the others. if encoder.MapLen() == 0 { encoder.ReleaseMapContext(, ) = appendEmptyObject(, ) = .End.Next break } , := appendMapAsRead(, , appendStructHead(, ), , ) if != nil { // the entries written before the error, which tell where it is. return , } = } else if .Map.Collect(, ) == 0 { encoder.ReleaseMapContext(, ) = appendEmptyObject(, ) = .End.Next break } else { = appendStructHead(, ) if (.Option.Flag & encoder.UnorderedMapOption) == 0 { if .Flags&encoder.MapStringKeyFlags != 0 { .SortKeys() .Sorted = true .DirectEntries = .Map.ScalarValue || .Map.InterfaceValue } else { .SortByEncodedKeys() .First = len() } } } store(, .Idx, unsafe.Pointer()) // the first entry is begun as the others are, by the header: it has the next opcode and the flags // of the key opcode. .Idx = -1 fallthrough case encoder.OpMapKey: // After an entry, or at the start with Idx -1: the next entry is begun, or the map is ended. // A key of a string is written here, and the value of the entry is given to the opcode of the // value: that saves the opcodes of the key and of the value for every entry. The key of another // kind is given to its opcode, which OpMapValue follows. // // The keys of a sorted map which are not strings are encoded first, each by its opcodes and // OpMapValue, which keeps it, and sorted by their names: the entries are written in that order then, // by the opcodes of the values. So the values are encoded in the order of the output, as // encoding/json encodes them, which a method of a value sees ( its place in the output ), and which // tells the value whose error is reported. := (*encoder.MapContext)(load(, .Idx)) := .Slice.Items != nil := .Idx + 1 if && !.Sorted { if < .Len { .Idx = store(, .Next.Idx, .KeyAt()) = .Next break } = .SortEncodedKeys(, , mapKeyFooterLen(, .Next)) = 0 } if .DirectEntries && < .Len { // the entries from here are written by one call, up to one whose value is left to its opcodes. , , := appendSortedMapEntries(, , , , ) if != nil { // the entries written before the error, which tell where it is. return , } , = , } if == .Len { = appendObjectEnd(, , ) encoder.ReleaseMapContext(, ) = .End.Next break } .Idx = if { // the entry of the key at idx in the order of the names, whose value is given to the opcodes of // the value, which OpMapValue ( NextField ) is followed by. := &.Slice.Items[] if > 0 && .End.Op == encoder.OpMapEndMayRepeatNames && encoder.SameMapName(, .Key, .Slice.Items[-1].Key) { // the output before the name, which tells where it is. := encoder.DuplicateMapNameError(.Key, ) encoder.ReleaseMapContext(, ) return , } = appendSortedMapKey(, , , .Key) = .NextField.Next store(, .Idx, .ValueAt(.Entry)) break } = appendMapKeyIndent(, , ) if .Flags&encoder.MapStringKeyFlags == 0 { store(, .Next.Idx, .KeyAt()) = .Next break } if .Sorted { = int(.Order[]) } , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , .Keys[]) = appendComma(, ) = appendColon(, ) store(, .Next.Idx, .ValueAt()) = .Next case encoder.OpMapValue: := (*encoder.MapContext)(load(, .Idx)) if .Slice.Items != nil { // a key of a sorted map, which follows the keys before it from First, to be written with its entry // when every key is encoded ( see encoder.MapContext.SortEncodedKeys ): the item has the keys up to // the end of this one, which tells where it ends. The next key is given to its opcodes, which follow // the key opcode ( NextField ), and the key opcode sorts the keys after the last one. .Slice.Items[.Idx] = encoder.MapItem{Key: [.First:], Entry: .Idx} = .NextField if := .Idx + 1; < .Len { .Idx = = .Next store(, .Idx, .KeyAt()) } break } = appendColon(, ) store(, .Next.Idx, .ValueAt(.Idx)) = .Next case encoder.OpIntPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpInt: = appendInt(, , load(, .Idx), ) = appendComma(, ) = .Next case encoder.OpUintPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpUint: = appendUint(, , load(, .Idx), ) = appendComma(, ) = .Next // The values as strings, for the keys of a map and for the string option of a field whose key is longer // than a chunk: such a field is encoded by the generic field opcode and the opcode of its value. case encoder.OpIntPtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { if .Flags&encoder.MapKeyFlags != 0 { return , encoder.ErrNilMapKey() } = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpIntString: = append(, '"') = appendInt(, , load(, .Idx), ) = append(, '"') = appendComma(, ) = .Next case encoder.OpUintPtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { if .Flags&encoder.MapKeyFlags != 0 { return , encoder.ErrNilMapKey() } = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpUintString: = append(, '"') = appendUint(, , load(, .Idx), ) = append(, '"') = appendComma(, ) = .Next case encoder.OpFloat32PtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpFloat32String: = append(, '"') , := appendFloat32(, , , ptrToFloat32(load(, .Idx))) if != nil { return , } = = append(, '"') = appendComma(, ) = .Next case encoder.OpFloat64PtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpFloat64String: := ptrToFloat64(load(, .Idx)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = append(, '"') = appendFloat64(, , ) = append(, '"') = appendComma(, ) = .Next case encoder.OpBoolPtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpBoolString: = append(, '"') = appendBool(, , ptrToBool(load(, .Idx))) = append(, '"') = appendComma(, ) = .Next case encoder.OpStringPtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpStringString: , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ptrToString(load(, .Idx))) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendComma(, ) = .Next case encoder.OpNumberPtrString: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpNumberString: = append(, '"') , := appendNumberString(, , ptrToNumber(load(, .Idx))) if != nil { return , } = append(, '"') = appendComma(, ) = .Next case encoder.OpFloat32Ptr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNull(, ) = appendComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpFloat32: , := appendFloat32(, , , ptrToFloat32(load(, .Idx))) if != nil { return , } = = appendComma(, ) = .Next case encoder.OpFloat64Ptr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpFloat64: := ptrToFloat64(load(, .Idx)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next case encoder.OpStringPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { if .Flags&encoder.MapKeyFlags != 0 { return , encoder.ErrNilMapKey() } = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpString: , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString(load(, .Idx))) = appendComma(, ) = .Next case encoder.OpBoolPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpBool: = appendBool(, , ptrToBool(load(, .Idx))) = appendComma(, ) = .Next case encoder.OpBytesPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpBytes: = appendByteSlice(, , ptrToBytes(load(, .Idx))) = appendComma(, ) = .Next case encoder.OpNumberPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ) fallthrough case encoder.OpNumber: , := appendNumber(, , ptrToNumber(load(, .Idx))) if != nil { return , } = appendComma(, ) = .Next case encoder.OpMarshalJSONPtr: := load(, .Idx) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ptrToNPtr(, .PtrNum)) fallthrough case encoder.OpMarshalJSON: := load(, .Idx) if == nil { = appendNullComma(, ) = .Next break } if (.Flags&encoder.IsNilableTypeFlags) != 0 && (.Flags&encoder.IndirectFlags) != 0 { = ptrToPtr() } , := appendMarshalJSON(, , , ) if != nil { return , } = appendComma(, ) = .Next case encoder.OpMarshalTextPtr: := load(, .Idx) if == nil { = appendNullComma(, ) = .Next break } store(, .Idx, ptrToNPtr(, .PtrNum)) fallthrough case encoder.OpMarshalText: := load(, .Idx) if == nil { if (.Flags & encoder.InterfaceMapKeyFlags) != 0 { // a key whose pointers end at nil has no name, as encoding/json of Go 1.27 names it return , encoder.NilMapKeyError() } if (.Flags & encoder.MapKeyFlags) != 0 { // the name of a key which is a nil pointer is "", as encoding/json names it = appendComma(, append(, `""`...)) } else { // a nil pointer value is null, as with encoding/json and as OpMarshalJSON writes it = appendNullComma(, ) } = .Next break } if (.Flags&encoder.IsNilableTypeFlags) != 0 && (.Flags&encoder.IndirectFlags) != 0 { = ptrToPtr() } , := appendMarshalText(, , , ) if != nil { return , } = appendComma(, ) = .Next case encoder.OpSlicePtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .End.Next break } store(, .Idx, ) fallthrough case encoder.OpSlice: := load(, .Idx) := ptrToSlice() if == nil || .Data == nil { if != nil && encoder.NilSliceIsEmpty() { = appendEmptyArray(, ) } else { = appendNullComma(, ) } = .End.Next break } storeInt(, .ElemIdx, 0) storeInt(, .Length, uintptr(.Len)) store(, .Idx, .Data) if .Len > 0 { = appendArrayHead(, , ) = .Next store(, .Idx, .Data) } else { = appendEmptyArray(, ) = .End.Next } case encoder.OpSliceElem: := loadInt(, .ElemIdx) := loadInt(, .Length) ++ if < { = appendArrayElemIndent(, , ) storeInt(, .ElemIdx, ) := load(, .Idx) := uintptr(.Size) = .Next store(, .Idx, unsafe.Add(, *)) } else { = appendArrayEnd(, , ) = .End.Next } case encoder.OpArrayPtr: := ptrToNPtr(load(, .Idx), .PtrNum) if == nil { = appendNullComma(, ) = .End.Next break } store(, .Idx, ) fallthrough case encoder.OpArray: := load(, .Idx) if == nil { = appendNullComma(, ) = .End.Next break } if .Length > 0 { = appendArrayHead(, , ) storeInt(, .ElemIdx, 0) = .Next store(, .Idx, ) } else { = appendEmptyArray(, ) = .End.Next } case encoder.OpArrayElem: := loadInt(, .ElemIdx) ++ if < uintptr(.Length) { = appendArrayElemIndent(, , ) storeInt(, .ElemIdx, ) := load(, .Idx) := uintptr(.Size) = .Next store(, .Idx, unsafe.Add(, *)) } else { = appendArrayEnd(, , ) = .End.Next } case encoder.OpRecursivePtr: := load(, .Idx) if == nil { = .Next break } store(, .Idx, ptrToNPtr(, .PtrNum)) fallthrough case encoder.OpRecursive: if .Flags&encoder.TailRecursiveFlags != 0 { // a value of a list, the last field of a value of the same type: encoded in this frame, with // the braces of the value it is the field of closed at OpRecursiveEnd. := load(, .Idx) if .RecursiveLevel > encoder.StartDetectingCyclesAfter { if := .RecordSeen(, ); != nil { return , } } := .Jmp.Code store(, .Idx, ) // the end of the struct is next, then OpRecursiveEnd, which has what the indent is deeper by. .BaseIndent += .Next.Next.Indent if .BaseIndent+.Jmp.Levels > encoder.MaxDepth && != nil { return , encoder.ErrMaxDepth() } .TailLevels++ .RecursiveLevel++ = break } , , := .EnterRecursive(, load(, .Idx)) if != nil { return , } = = case encoder.OpStructFieldOmitEmptyStringPtrOrEmpty: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { if := ptrToString(); != "" { = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ) = appendComma(, ) } } = .Next case encoder.OpUnwriteEmpty: = encoder.UnwriteEmptyMember(, , len(.Key)) = .Next case encoder.OpRecursiveEnd: // the braces of the values of a list this value was the last field of, from the innermost. for ; .TailLevels > 0; .TailLevels-- { .RecursiveLevel-- if .RecursiveLevel > encoder.StartDetectingCyclesAfter { .SeenPtr = .SeenPtr[:len(.SeenPtr)-1] } .BaseIndent -= .Indent = appendStructEndSkipLast(, .Next, ) } , = .LeaveFrame() case encoder.OpStructPtrHead: := load(, .Idx) if == nil { if .Flags&encoder.AnonymousHeadFlags == 0 { = appendNullComma(, ) } = .End.Next break } store(, .Idx, ptrToNPtr(, .PtrNum)) fallthrough case encoder.OpStructHead: := load(, .Idx) if == nil && ((.Flags&encoder.IndirectFlags) != 0 || .Next.Op == encoder.OpStructEnd) { if .Flags&encoder.AnonymousHeadFlags == 0 { = appendNullComma(, ) } = .End.Next break } if .Flags&encoder.AnonymousHeadFlags == 0 { = appendStructHead(, ) } = .Next case encoder.OpStructField: // the generic field: the value is encoded by its own opcode, and the key may be longer than a chunk. if .Flags&encoder.IsTaggedKeyFlags != 0 || .Flags&encoder.AnonymousKeyFlags == 0 { if len(.Key) <= encoder.KeyChunkSize { = appendStructKey(, , ) } else { = appendLongStructKey(, , ) } } := unsafe.Add(load(, .Idx), .Offset) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmpty: := load(, .Idx) = unsafe.Add(, .Offset) if encoder.IsEmptyField(.EmptyKind, .NumBitSize, ) || (.ZeroKind != encoder.ZeroNever && encoder.IsZeroField(, )) { = .NextField } else { if len(.Key) <= encoder.KeyChunkSize { = appendStructKey(, , ) } else { = appendLongStructKey(, , ) } = .Next store(, .Idx, ) } case encoder.OpStructFieldInt3: // Three fields of the kind in a row, then two: the fields after the first are encoded without // a dispatch, by falling through to the case of the field. The same for the other kinds below. := load(, .Idx) = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldInt2: := load(, .Idx) = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldInt: := load(, .Idx) = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyInt: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendComma(, ) } = .Next case encoder.OpStructFieldIntString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendInt(, , unsafe.Add(, .Offset), ) = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyIntString: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = append(, '"') = appendInt(, , unsafe.Add(, .Offset), ) = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldIntPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = appendInt(, , , ) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyIntPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendInt(, , , ) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldIntPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = append(, '"') = appendInt(, , , ) = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyIntPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendInt(, , , ) = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldUint3: := load(, .Idx) = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldUint2: := load(, .Idx) = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldUint: := load(, .Idx) = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyUint: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendComma(, ) } = .Next case encoder.OpStructFieldUintString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendUint(, , unsafe.Add(, .Offset), ) = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyUintString: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = append(, '"') = appendUint(, , unsafe.Add(, .Offset), ) = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldUintPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = appendUint(, , , ) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyUintPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendUint(, , , ) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldUintPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = append(, '"') = appendUint(, , , ) = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyUintPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendUint(, , , ) = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldFloat32: := load(, .Idx) = appendStructKey(, , ) , := appendFloat32(, , , ptrToFloat32(unsafe.Add(, .Offset))) if != nil { return , } = = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat32: := load(, .Idx) := ptrToFloat32(unsafe.Add(, .Offset)) if != 0 { = appendStructKey(, , ) , := appendFloat32(, , , ) if != nil { return , } = = appendComma(, ) } = .Next case encoder.OpStructFieldFloat32String: := load(, .Idx) = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ptrToFloat32(unsafe.Add(, .Offset))) if != nil { return , } = = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat32String: := load(, .Idx) := ptrToFloat32(unsafe.Add(, .Offset)) if != 0 { = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ) if != nil { return , } = = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldFloat32Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat32Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldFloat32PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = append(, '"') , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat32PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldFloat643: := load(, .Idx) = appendStructKey(, , ) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldFloat642: := load(, .Idx) = appendStructKey(, , ) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldFloat64: := load(, .Idx) = appendStructKey(, , ) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat64: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if != 0 { if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = appendFloat64(, , ) = appendComma(, ) } = .Next case encoder.OpStructFieldFloat64String: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = append(, '"') = appendFloat64(, , ) = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat64String: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if != 0 { if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = append(, '"') = appendFloat64(, , ) = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldFloat64Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNullComma(, ) = .Next break } := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat64Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldFloat64PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = append(, '"') = appendFloat64(, , ) = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyFloat64PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldString3: := load(, .Idx) = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString(unsafe.Add(, .Offset))) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldString2: := load(, .Idx) = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString(unsafe.Add(, .Offset))) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldString: := load(, .Idx) = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString(unsafe.Add(, .Offset))) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyString: := load(, .Idx) := ptrToString(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ) = appendComma(, ) } = .Next case encoder.OpStructFieldStringString: := load(, .Idx) := ptrToString(unsafe.Add(, .Offset)) = appendStructKey(, , ) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyStringString: := load(, .Idx) := ptrToString(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendComma(, ) } = .Next case encoder.OpStructFieldStringPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString()) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyStringPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString()) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldStringPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ptrToString()) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyStringPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ptrToString()) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldBool3: := load(, .Idx) = appendStructKey(, , ) = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldBool2: := load(, .Idx) = appendStructKey(, , ) = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = appendComma(, ) = .Next fallthrough case encoder.OpStructFieldBool: := load(, .Idx) = appendStructKey(, , ) = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBool: := load(, .Idx) := ptrToBool(unsafe.Add(, .Offset)) if { = appendStructKey(, , ) = appendBool(, , ) = appendComma(, ) } = .Next case encoder.OpStructFieldBoolString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBoolString: := load(, .Idx) := ptrToBool(unsafe.Add(, .Offset)) if { = appendStructKey(, , ) = append(, '"') = appendBool(, , ) = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldBoolPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = appendBool(, , ptrToBool()) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBoolPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendBool(, , ptrToBool()) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldBoolPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = append(, '"') = appendBool(, , ptrToBool()) = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBoolPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendBool(, , ptrToBool()) = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldBytes: := load(, .Idx) = appendStructKey(, , ) = appendByteSlice(, , ptrToBytes(unsafe.Add(, .Offset))) = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBytes: := load(, .Idx) := ptrToBytes(unsafe.Add(, .Offset)) if len() > 0 { = appendStructKey(, , ) = appendByteSlice(, , ) = appendComma(, ) } = .Next case encoder.OpStructFieldBytesPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = appendByteSlice(, , ptrToBytes()) } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyBytesPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendByteSlice(, , ptrToBytes()) = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldNumber: := load(, .Idx) = appendStructKey(, , ) , := appendNumber(, , ptrToNumber(unsafe.Add(, .Offset))) if != nil { return , } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyNumber: := load(, .Idx) := ptrToNumber(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , := appendNumber(, , ) if != nil { return , } = appendComma(, ) } = .Next case encoder.OpStructFieldNumberString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ptrToNumber(unsafe.Add(, .Offset))) if != nil { return , } = append(, '"') = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyNumberString: := load(, .Idx) := ptrToNumber(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ) if != nil { return , } = append(, '"') = appendComma(, ) } = .Next case encoder.OpStructFieldNumberPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { , := appendNumber(, , ptrToNumber()) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyNumberPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendNumber(, , ptrToNumber()) if != nil { return , } = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldNumberPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = appendStructKey(, , ) if == nil { = appendNull(, ) } else { = append(, '"') , := appendNumberString(, , ptrToNumber()) if != nil { return , } = append(, '"') } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyNumberPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ptrToNumber()) if != nil { return , } = append(, '"') = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldMarshalJSON: := load(, .Idx) = appendStructKey(, , ) = unsafe.Add(, .Offset) if (.Flags & encoder.IsNilableTypeFlags) != 0 { = ptrToPtr() } if == nil && (.Flags&encoder.NilCheckFlags) != 0 { = appendNull(, ) } else { , := appendMarshalJSON(, , , ) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyMarshalJSON: := load(, .Idx) = unsafe.Add(, .Offset) // empty by the kind of the field, as encoding/json decides it: a nil func or chan is not. if encoder.IsEmptyField(.EmptyKind, .NumBitSize, ) { = .NextField break } if (.Flags & encoder.IsNilableTypeFlags) != 0 { = ptrToPtr() } = appendStructKey(, , ) , := appendMarshalJSON(, , , ) if != nil { return , } = appendComma(, ) = .Next case encoder.OpStructFieldMarshalJSONPtr: := load(, .Idx) = appendStructKey(, , ) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , := appendMarshalJSON(, , , ) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendMarshalJSON(, , , ) if != nil { return , } = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldMarshalText: := load(, .Idx) = appendStructKey(, , ) = unsafe.Add(, .Offset) if (.Flags & encoder.IsNilableTypeFlags) != 0 { = ptrToPtr() } if == nil && (.Flags&encoder.NilCheckFlags) != 0 { = appendNull(, ) } else { , := appendMarshalText(, , , ) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyMarshalText: := load(, .Idx) = unsafe.Add(, .Offset) // empty by the kind of the field, as encoding/json decides it: a nil func or chan is not. if encoder.IsEmptyField(.EmptyKind, .NumBitSize, ) { = .NextField break } if (.Flags & encoder.IsNilableTypeFlags) != 0 { = ptrToPtr() } = appendStructKey(, , ) , := appendMarshalText(, , , ) if != nil { return , } = appendComma(, ) = .Next case encoder.OpStructFieldMarshalTextPtr: := load(, .Idx) = appendStructKey(, , ) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , := appendMarshalText(, , , ) if != nil { return , } = } = appendComma(, ) = .Next case encoder.OpStructFieldOmitEmptyMarshalTextPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendMarshalText(, , , ) if != nil { return , } = appendComma(, ) = .Next } else { // omitted: the opcodes after the value of the field, if any, are skipped as well. = .NextField } case encoder.OpStructFieldArray: = appendStructKey(, , ) := load(, .Idx) = unsafe.Add(, .Offset) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmptyArray: = appendStructKey(, , ) := load(, .Idx) = unsafe.Add(, .Offset) = .Next store(, .Idx, ) case encoder.OpStructFieldArrayPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmptyArrayPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = .Next store(, .Idx, ) } else { = .NextField } case encoder.OpStructFieldSlice: = appendStructKey(, , ) := load(, .Idx) = unsafe.Add(, .Offset) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmptySlice: := load(, .Idx) = unsafe.Add(, .Offset) := ptrToSlice() if .Len == 0 { = .NextField } else { = appendStructKey(, , ) = .Next store(, .Idx, ) } case encoder.OpStructFieldSlicePtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmptySlicePtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = .Next store(, .Idx, ) } else { = .NextField } case encoder.OpStructFieldMap: = appendStructKey(, , ) := load(, .Idx) = ptrToPtr(unsafe.Add(, .Offset)) = .Next store(, .Idx, ) case encoder.OpStructFieldOmitEmptyMap: := load(, .Idx) = ptrToPtr(unsafe.Add(, .Offset)) if == nil || encoder.MapLen() == 0 { = .NextField } else { = appendStructKey(, , ) = .Next store(, .Idx, ) } case encoder.OpStructFieldMapPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToPtr(unsafe.Add(, .Offset)) if != nil { = ptrToNPtr(, .PtrNum) } = .Next store(, .Idx, ) case encoder.OpStructEnd: = appendStructEndSkipLast(, , ) = .Next case encoder.OpStructEndInt: := load(, .Idx) = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyInt: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = appendInt(, , unsafe.Add(, .Offset), ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndIntString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendInt(, , unsafe.Add(, .Offset), ) = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyIntString: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = append(, '"') = appendInt(, , unsafe.Add(, .Offset), ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndIntPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = appendInt(, , , ) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyIntPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendInt(, , , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndIntPtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') = appendInt(, , , ) = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyIntPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendInt(, , , ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndUint: := load(, .Idx) = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyUint: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = appendUint(, , unsafe.Add(, .Offset), ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndUintString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendUint(, , unsafe.Add(, .Offset), ) = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyUintString: := load(, .Idx) := ptrToUint64(unsafe.Add(, .Offset), .NumBitSize) := & ((1 << .NumBitSize) - 1) if != 0 { = appendStructKey(, , ) = append(, '"') = appendUint(, , unsafe.Add(, .Offset), ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndUintPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = appendUint(, , , ) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyUintPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendUint(, , , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndUintPtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') = appendUint(, , , ) = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyUintPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendUint(, , , ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat32: := load(, .Idx) = appendStructKey(, , ) , := appendFloat32(, , , ptrToFloat32(unsafe.Add(, .Offset))) if != nil { return , } = = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat32: := load(, .Idx) := ptrToFloat32(unsafe.Add(, .Offset)) if != 0 { = appendStructKey(, , ) , := appendFloat32(, , , ) if != nil { return , } = = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat32String: := load(, .Idx) = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ptrToFloat32(unsafe.Add(, .Offset))) if != nil { return , } = = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat32String: := load(, .Idx) := ptrToFloat32(unsafe.Add(, .Offset)) if != 0 { = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ) if != nil { return , } = = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat32Ptr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat32Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat32PtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat32PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') , := appendFloat32(, , , ptrToFloat32()) if != nil { return , } = = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat64: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = appendFloat64(, , ) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat64: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if != 0 { if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = appendFloat64(, , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat64String: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = append(, '"') = appendFloat64(, , ) = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat64String: := load(, .Idx) := ptrToFloat64(unsafe.Add(, .Offset)) if != 0 { if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendStructKey(, , ) = append(, '"') = appendFloat64(, , ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat64Ptr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) = appendStructEnd(, , ) = .Next break } := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat64Ptr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndFloat64PtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = appendFloat64(, , ) = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyFloat64PtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) := ptrToFloat64() if isInfOrNaN() { return , errUnsupportedFloat(, , ) } = append(, '"') = appendFloat64(, , ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndString: := load(, .Idx) = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString(unsafe.Add(, .Offset))) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyString: := load(, .Idx) := ptrToString(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndStringString: := load(, .Idx) = appendStructKey(, , ) := ptrToString(unsafe.Add(, .Offset)) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyStringString: := load(, .Idx) := ptrToString(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndStringPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString()) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyStringPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ptrToString()) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndStringPtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ptrToString()) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyStringPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := jsonstring.AppendQuoted(encoder.StringEscaper(), []byte{}, ptrToString()) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , string()) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBool: := load(, .Idx) = appendStructKey(, , ) = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBool: := load(, .Idx) := ptrToBool(unsafe.Add(, .Offset)) if { = appendStructKey(, , ) = appendBool(, , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBoolString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') = appendBool(, , ptrToBool(unsafe.Add(, .Offset))) = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBoolString: := load(, .Idx) := ptrToBool(unsafe.Add(, .Offset)) if { = appendStructKey(, , ) = append(, '"') = appendBool(, , ) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBoolPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = appendBool(, , ptrToBool()) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBoolPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendBool(, , ptrToBool()) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBoolPtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') = appendBool(, , ptrToBool()) = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBoolPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') = appendBool(, , ptrToBool()) = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBytes: := load(, .Idx) = appendStructKey(, , ) = appendByteSlice(, , ptrToBytes(unsafe.Add(, .Offset))) = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBytes: := load(, .Idx) := ptrToBytes(unsafe.Add(, .Offset)) if len() > 0 { = appendStructKey(, , ) = appendByteSlice(, , ) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndBytesPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = appendByteSlice(, , ptrToBytes()) } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyBytesPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = appendByteSlice(, , ptrToBytes()) = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndNumber: := load(, .Idx) = appendStructKey(, , ) , := appendNumber(, , ptrToNumber(unsafe.Add(, .Offset))) if != nil { return , } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyNumber: := load(, .Idx) := ptrToNumber(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) , := appendNumber(, , ) if != nil { return , } = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndNumberString: := load(, .Idx) = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ptrToNumber(unsafe.Add(, .Offset))) if != nil { return , } = append(, '"') = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyNumberString: := load(, .Idx) := ptrToNumber(unsafe.Add(, .Offset)) if != "" { = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ) if != nil { return , } = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndNumberPtr: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { , := appendNumber(, , ptrToNumber()) if != nil { return , } = } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyNumberPtr: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) , := appendNumber(, , ptrToNumber()) if != nil { return , } = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpStructEndNumberPtrString: = appendStructKey(, , ) := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if == nil { = appendNull(, ) } else { = append(, '"') , := appendNumberString(, , ptrToNumber()) if != nil { return , } = append(, '"') } = appendStructEnd(, , ) = .Next case encoder.OpStructEndOmitEmptyNumberPtrString: := load(, .Idx) = ptrToNPtr(unsafe.Add(, .Offset), .PtrNum) if != nil { = appendStructKey(, , ) = append(, '"') , := appendNumberString(, , ptrToNumber()) if != nil { return , } = append(, '"') = appendStructEnd(, , ) } else { = appendStructEndSkipLast(, , ) } = .Next case encoder.OpEnd: goto } } : return , nil } // appendMapAsRead writes the entries of the map at p, whose keys are of a string kind, as the map is read: the // map is not sorted, so the order of its entries is not specified, and an entry written here costs neither a // copy to the context nor the opcodes of an entry. When the values are written by one opcode of a scalar, // every entry is written. When the values are of interface{}, the ones which hold a scalar or nothing are // written, and the others are given to the context, to be encoded by the opcodes of their values from // OpMapKey on: they come after the scalars, which are most of the entries of a JSON object held by a value of // interface{}. // //go:noinline func appendMapAsRead( *encoder.RuntimeContext, *encoder.Opcode, []byte, unsafe.Pointer, *encoder.MapContext) ([]byte, error) { .Map.Reset() if .Map.ScalarValue { .Len = 0 return mapScalarValueWriters[.Map.ValueKind](, , , ) } for , := range *(*map[string]any)(unsafe.Pointer(&)) { := (*emptyInterface)(unsafe.Pointer(&)) var *encoder.Opcode // A value of interface{} which holds nothing is null. What holds a value whose data word is nil, such // as a nil pointer, is left to OpInterface, which knows what is null and what is not. if .typ != nil && .ptr != nil { := .RecentCodeSet(uintptr(.typ)) if == nil { if .Option.Flag&encoder.UncachedOption == 0 { = .SharedCodeSets().LoadFirst(uintptr(.typ)) } if != nil { .RememberCodeSet(uintptr(.typ), ) } else { var error , = encoder.CompileToGetCodeSet(, uintptr(.typ)) if != nil { return , } } } = .Scalar } if .typ != nil && == nil { .Keys = append(.Keys, ) .Values = append(.Values, unsafe.Slice((*byte)(unsafe.Pointer(&)), unsafe.Sizeof())...) continue } = appendMapKey(, , , ) if == nil { = appendNullComma(, ) continue } // the data word of the interface value is the address of the scalar, or the pointer to it. , := appendScalar(, , , .ptr) if != nil { return , } = } .Len = len(.Keys) return , nil } // appendSortedMapEntries writes the entries of a sorted map with keys of a string kind directly, as // appendMapAsRead does for a map which is not sorted, from the one at idx in the order of the keys, as the // opcodes of the entries would: every value when the values are written by one opcode of a scalar // ( MapLayout.ScalarValue ), and a value of interface{} which holds a scalar or nothing // ( MapLayout.InterfaceValue ). It returns the index of the first entry it doesn't write, whose value is left to // its opcodes, or the number of the entries. code is the opcode of the keys, followed by the one of the values. // //go:noinline func appendSortedMapEntries( *encoder.RuntimeContext, *encoder.Opcode, []byte, *encoder.MapContext, int) ([]byte, int, error) { := .ScalarValue() for ; < .Len; ++ { := int(.Order[]) := .ValueAt() := .Next if ! { // as appendMapAsRead does for a value of interface{}. := (*emptyInterface)() if .typ == nil { = appendMapKey(, , , .Keys[]) = appendNullComma(, ) continue } if .ptr == nil { return , , nil } := .RecentCodeSet(uintptr(.typ)) if == nil { if .Option.Flag&encoder.UncachedOption == 0 { = .SharedCodeSets().LoadFirst(uintptr(.typ)) } if != nil { .RememberCodeSet(uintptr(.typ), ) } else { var error , = encoder.CompileToGetCodeSet(, uintptr(.typ)) if != nil { return , 0, } } } if .Scalar == nil { return , , nil } = .Scalar = .ptr } = appendMapKey(, , , .Keys[]) , := appendScalar(, , , ) if != nil { return , 0, } = } return , , nil } // appendMapKey writes the key of an entry of a map, as OpMapKey does. func appendMapKey( *encoder.RuntimeContext, *encoder.Opcode, []byte, string) []byte { = appendMapKeyIndent(, , ) , _ = jsonstring.AppendQuoted(encoder.StringEscaper(), , ) = appendComma(, ) return appendColon(, ) } // appendMapScalarValues writes the entries of the map at p, whose values are written by the opcode of a // scalar which follows the header, as the map is ranged over as a map of values of V, the basic type of the // kind of the values: the layout of a map depends only on the sizes of the key and of the value // ( encoder.MapLayout ). func appendMapScalarValues[ any]( *encoder.RuntimeContext, *encoder.Opcode, []byte, unsafe.Pointer) ([]byte, error) { := .Next // v is declared out of the loop: its address is given to appendScalar, so it lives on the heap, and a // variable of the loop would be allocated for each entry. var ( string ) for , = range *(*map[string])(unsafe.Pointer(&)) { = appendMapKey(, , , ) , := appendScalar(, , , unsafe.Pointer(&)) if != nil { return , } = } return , nil } // mapScalarValueWriters are appendMapScalarValues by the kind of the values written by one opcode of a scalar // ( encoder.MapLayout.ValueKind ): a slice is a slice of bytes. A string and a slice are ranged over as their // words, which hold no pointer: the copy is not a pointer which the GC follows, and the map keeps the values. var mapScalarValueWriters = [...]func(*encoder.RuntimeContext, *encoder.Opcode, []byte, unsafe.Pointer) ([]byte, error){ reflect.Bool: appendMapScalarValues[bool], reflect.Int: appendMapScalarValues[int], reflect.Int8: appendMapScalarValues[int8], reflect.Int16: appendMapScalarValues[int16], reflect.Int32: appendMapScalarValues[int32], reflect.Int64: appendMapScalarValues[int64], reflect.Uint: appendMapScalarValues[uint], reflect.Uint8: appendMapScalarValues[uint8], reflect.Uint16: appendMapScalarValues[uint16], reflect.Uint32: appendMapScalarValues[uint32], reflect.Uint64: appendMapScalarValues[uint64], reflect.Uintptr: appendMapScalarValues[uintptr], reflect.Float32: appendMapScalarValues[float32], reflect.Float64: appendMapScalarValues[float64], reflect.String: appendMapScalarValues[[2]uintptr], reflect.Slice: appendMapScalarValues[[3]uintptr], }