1
2 package vm_color
3
4 import (
5 "math"
6 "reflect"
7 "sort"
8 "unsafe"
9
10 "github.com/goccy/go-json/internal/encoder"
11 "github.com/goccy/go-json/internal/runtime"
12 )
13
14 func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) {
15 recursiveLevel := 0
16 ptrOffset := uintptr(0)
17 ctxptr := ctx.Ptr()
18 var code *encoder.Opcode
19 if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 {
20 code = codeSet.EscapeKeyCode
21 } else {
22 code = codeSet.NoescapeKeyCode
23 }
24
25 for {
26 switch code.Op {
27 default:
28 return nil, errUnimplementedOp(code.Op)
29 case encoder.OpPtr:
30 p := load(ctxptr, code.Idx)
31 code = code.Next
32 store(ctxptr, code.Idx, ptrToPtr(p))
33 case encoder.OpIntPtr:
34 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
35 if p == 0 {
36 b = appendNullComma(ctx, b)
37 code = code.Next
38 break
39 }
40 store(ctxptr, code.Idx, p)
41 fallthrough
42 case encoder.OpInt:
43 b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
44 b = appendComma(ctx, b)
45 code = code.Next
46 case encoder.OpUintPtr:
47 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
48 if p == 0 {
49 b = appendNullComma(ctx, b)
50 code = code.Next
51 break
52 }
53 store(ctxptr, code.Idx, p)
54 fallthrough
55 case encoder.OpUint:
56 b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
57 b = appendComma(ctx, b)
58 code = code.Next
59 case encoder.OpIntString:
60 b = append(b, '"')
61 b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
62 b = append(b, '"')
63 b = appendComma(ctx, b)
64 code = code.Next
65 case encoder.OpUintString:
66 b = append(b, '"')
67 b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
68 b = append(b, '"')
69 b = appendComma(ctx, b)
70 code = code.Next
71 case encoder.OpFloat32Ptr:
72 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
73 if p == 0 {
74 b = appendNull(ctx, b)
75 b = appendComma(ctx, b)
76 code = code.Next
77 break
78 }
79 store(ctxptr, code.Idx, p)
80 fallthrough
81 case encoder.OpFloat32:
82 b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx)))
83 b = appendComma(ctx, b)
84 code = code.Next
85 case encoder.OpFloat64Ptr:
86 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
87 if p == 0 {
88 b = appendNullComma(ctx, b)
89 code = code.Next
90 break
91 }
92 store(ctxptr, code.Idx, p)
93 fallthrough
94 case encoder.OpFloat64:
95 v := ptrToFloat64(load(ctxptr, code.Idx))
96 if math.IsInf(v, 0) || math.IsNaN(v) {
97 return nil, errUnsupportedFloat(v)
98 }
99 b = appendFloat64(ctx, b, v)
100 b = appendComma(ctx, b)
101 code = code.Next
102 case encoder.OpStringPtr:
103 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
104 if p == 0 {
105 b = appendNullComma(ctx, b)
106 code = code.Next
107 break
108 }
109 store(ctxptr, code.Idx, p)
110 fallthrough
111 case encoder.OpString:
112 b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx)))
113 b = appendComma(ctx, b)
114 code = code.Next
115 case encoder.OpBoolPtr:
116 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
117 if p == 0 {
118 b = appendNullComma(ctx, b)
119 code = code.Next
120 break
121 }
122 store(ctxptr, code.Idx, p)
123 fallthrough
124 case encoder.OpBool:
125 b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx)))
126 b = appendComma(ctx, b)
127 code = code.Next
128 case encoder.OpBytesPtr:
129 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
130 if p == 0 {
131 b = appendNullComma(ctx, b)
132 code = code.Next
133 break
134 }
135 store(ctxptr, code.Idx, p)
136 fallthrough
137 case encoder.OpBytes:
138 b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx)))
139 b = appendComma(ctx, b)
140 code = code.Next
141 case encoder.OpNumberPtr:
142 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
143 if p == 0 {
144 b = appendNullComma(ctx, b)
145 code = code.Next
146 break
147 }
148 store(ctxptr, code.Idx, p)
149 fallthrough
150 case encoder.OpNumber:
151 bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx)))
152 if err != nil {
153 return nil, err
154 }
155 b = appendComma(ctx, bb)
156 code = code.Next
157 case encoder.OpInterfacePtr:
158 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
159 if p == 0 {
160 b = appendNullComma(ctx, b)
161 code = code.Next
162 break
163 }
164 store(ctxptr, code.Idx, p)
165 fallthrough
166 case encoder.OpInterface:
167 p := load(ctxptr, code.Idx)
168 if p == 0 {
169 b = appendNullComma(ctx, b)
170 code = code.Next
171 break
172 }
173 if recursiveLevel > encoder.StartDetectingCyclesAfter {
174 for _, seen := range ctx.SeenPtr {
175 if p == seen {
176 return nil, errUnsupportedValue(code, p)
177 }
178 }
179 }
180 ctx.SeenPtr = append(ctx.SeenPtr, p)
181 var (
182 typ *runtime.Type
183 ifacePtr unsafe.Pointer
184 )
185 up := ptrToUnsafePtr(p)
186 if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
187 iface := (*nonEmptyInterface)(up)
188 ifacePtr = iface.ptr
189 if iface.itab != nil {
190 typ = iface.itab.typ
191 }
192 } else {
193 iface := (*emptyInterface)(up)
194 ifacePtr = iface.ptr
195 typ = iface.typ
196 }
197 if ifacePtr == nil {
198 isDirectedNil := typ != nil && typ.Kind() == reflect.Struct && !runtime.IfaceIndir(typ)
199 if !isDirectedNil {
200 b = appendNullComma(ctx, b)
201 code = code.Next
202 break
203 }
204 }
205 ctx.KeepRefs = append(ctx.KeepRefs, up)
206 ifaceCodeSet, err := encoder.CompileToGetCodeSet(ctx, uintptr(unsafe.Pointer(typ)))
207 if err != nil {
208 return nil, err
209 }
210
211 totalLength := uintptr(code.Length) + 3
212 nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3
213
214 var c *encoder.Opcode
215 if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 {
216 c = ifaceCodeSet.InterfaceEscapeKeyCode
217 } else {
218 c = ifaceCodeSet.InterfaceNoescapeKeyCode
219 }
220 curlen := uintptr(len(ctx.Ptrs))
221 offsetNum := ptrOffset / uintptrSize
222 oldOffset := ptrOffset
223 ptrOffset += totalLength * uintptrSize
224 oldBaseIndent := ctx.BaseIndent
225 ctx.BaseIndent += code.Indent
226
227 newLen := offsetNum + totalLength + nextTotalLength
228 if curlen < newLen {
229 ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...)
230 }
231 ctxptr = ctx.Ptr() + ptrOffset
232
233 end := ifaceCodeSet.EndCode
234 store(ctxptr, c.Idx, uintptr(ifacePtr))
235 store(ctxptr, end.Idx, oldOffset)
236 store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next)))
237 storeIndent(ctxptr, end, uintptr(oldBaseIndent))
238 code = c
239 recursiveLevel++
240 case encoder.OpInterfaceEnd:
241 recursiveLevel--
242
243
244 offset := load(ctxptr, code.Idx)
245 restoreIndent(ctx, code, ctxptr)
246 ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1]
247
248 codePtr := load(ctxptr, code.ElemIdx)
249 code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr))
250 ctxptr = ctx.Ptr() + offset
251 ptrOffset = offset
252 case encoder.OpMarshalJSONPtr:
253 p := load(ctxptr, code.Idx)
254 if p == 0 {
255 b = appendNullComma(ctx, b)
256 code = code.Next
257 break
258 }
259 store(ctxptr, code.Idx, ptrToPtr(p))
260 fallthrough
261 case encoder.OpMarshalJSON:
262 p := load(ctxptr, code.Idx)
263 if p == 0 {
264 b = appendNullComma(ctx, b)
265 code = code.Next
266 break
267 }
268 if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
269 p = ptrToPtr(p)
270 }
271 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
272 if err != nil {
273 return nil, err
274 }
275 b = appendComma(ctx, bb)
276 code = code.Next
277 case encoder.OpMarshalTextPtr:
278 p := load(ctxptr, code.Idx)
279 if p == 0 {
280 b = appendNullComma(ctx, b)
281 code = code.Next
282 break
283 }
284 store(ctxptr, code.Idx, ptrToPtr(p))
285 fallthrough
286 case encoder.OpMarshalText:
287 p := load(ctxptr, code.Idx)
288 if p == 0 {
289 b = append(b, `""`...)
290 b = appendComma(ctx, b)
291 code = code.Next
292 break
293 }
294 if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
295 p = ptrToPtr(p)
296 }
297 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
298 if err != nil {
299 return nil, err
300 }
301 b = appendComma(ctx, bb)
302 code = code.Next
303 case encoder.OpSlicePtr:
304 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
305 if p == 0 {
306 b = appendNullComma(ctx, b)
307 code = code.End.Next
308 break
309 }
310 store(ctxptr, code.Idx, p)
311 fallthrough
312 case encoder.OpSlice:
313 p := load(ctxptr, code.Idx)
314 slice := ptrToSlice(p)
315 if p == 0 || slice.Data == nil {
316 b = appendNullComma(ctx, b)
317 code = code.End.Next
318 break
319 }
320 store(ctxptr, code.ElemIdx, 0)
321 store(ctxptr, code.Length, uintptr(slice.Len))
322 store(ctxptr, code.Idx, uintptr(slice.Data))
323 if slice.Len > 0 {
324 b = appendArrayHead(ctx, code, b)
325 code = code.Next
326 store(ctxptr, code.Idx, uintptr(slice.Data))
327 } else {
328 b = appendEmptyArray(ctx, b)
329 code = code.End.Next
330 }
331 case encoder.OpSliceElem:
332 idx := load(ctxptr, code.ElemIdx)
333 length := load(ctxptr, code.Length)
334 idx++
335 if idx < length {
336 b = appendArrayElemIndent(ctx, code, b)
337 store(ctxptr, code.ElemIdx, idx)
338 data := load(ctxptr, code.Idx)
339 size := uintptr(code.Size)
340 code = code.Next
341 store(ctxptr, code.Idx, data+idx*size)
342 } else {
343 b = appendArrayEnd(ctx, code, b)
344 code = code.End.Next
345 }
346 case encoder.OpArrayPtr:
347 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
348 if p == 0 {
349 b = appendNullComma(ctx, b)
350 code = code.End.Next
351 break
352 }
353 store(ctxptr, code.Idx, p)
354 fallthrough
355 case encoder.OpArray:
356 p := load(ctxptr, code.Idx)
357 if p == 0 {
358 b = appendNullComma(ctx, b)
359 code = code.End.Next
360 break
361 }
362 if code.Length > 0 {
363 b = appendArrayHead(ctx, code, b)
364 store(ctxptr, code.ElemIdx, 0)
365 code = code.Next
366 store(ctxptr, code.Idx, p)
367 } else {
368 b = appendEmptyArray(ctx, b)
369 code = code.End.Next
370 }
371 case encoder.OpArrayElem:
372 idx := load(ctxptr, code.ElemIdx)
373 idx++
374 if idx < uintptr(code.Length) {
375 b = appendArrayElemIndent(ctx, code, b)
376 store(ctxptr, code.ElemIdx, idx)
377 p := load(ctxptr, code.Idx)
378 size := uintptr(code.Size)
379 code = code.Next
380 store(ctxptr, code.Idx, p+idx*size)
381 } else {
382 b = appendArrayEnd(ctx, code, b)
383 code = code.End.Next
384 }
385 case encoder.OpMapPtr:
386 p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
387 if p == 0 {
388 b = appendNullComma(ctx, b)
389 code = code.End.Next
390 break
391 }
392 store(ctxptr, code.Idx, p)
393 fallthrough
394 case encoder.OpMap:
395 p := load(ctxptr, code.Idx)
396 if p == 0 {
397 b = appendNullComma(ctx, b)
398 code = code.End.Next
399 break
400 }
401 uptr := ptrToUnsafePtr(p)
402 mlen := maplen(uptr)
403 if mlen <= 0 {
404 b = appendEmptyObject(ctx, b)
405 code = code.End.Next
406 break
407 }
408 b = appendStructHead(ctx, b)
409 unorderedMap := (ctx.Option.Flag & encoder.UnorderedMapOption) != 0
410 mapCtx := encoder.NewMapContext(mlen, unorderedMap)
411 mapiterinit(code.Type, uptr, &mapCtx.Iter)
412 store(ctxptr, code.Idx, uintptr(unsafe.Pointer(mapCtx)))
413 ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
414 if unorderedMap {
415 b = appendMapKeyIndent(ctx, code.Next, b)
416 } else {
417 mapCtx.Start = len(b)
418 mapCtx.First = len(b)
419 }
420 key := mapiterkey(&mapCtx.Iter)
421 store(ctxptr, code.Next.Idx, uintptr(key))
422 code = code.Next
423 case encoder.OpMapKey:
424 mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
425 idx := mapCtx.Idx
426 idx++
427 if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
428 if idx < mapCtx.Len {
429 b = appendMapKeyIndent(ctx, code, b)
430 mapCtx.Idx = int(idx)
431 key := mapiterkey(&mapCtx.Iter)
432 store(ctxptr, code.Next.Idx, uintptr(key))
433 code = code.Next
434 } else {
435 b = appendObjectEnd(ctx, code, b)
436 encoder.ReleaseMapContext(mapCtx)
437 code = code.End.Next
438 }
439 } else {
440 mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
441 if idx < mapCtx.Len {
442 mapCtx.Idx = int(idx)
443 mapCtx.Start = len(b)
444 key := mapiterkey(&mapCtx.Iter)
445 store(ctxptr, code.Next.Idx, uintptr(key))
446 code = code.Next
447 } else {
448 code = code.End
449 }
450 }
451 case encoder.OpMapValue:
452 mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
453 if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
454 b = appendColon(ctx, b)
455 } else {
456 mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
457 mapCtx.Start = len(b)
458 }
459 value := mapitervalue(&mapCtx.Iter)
460 store(ctxptr, code.Next.Idx, uintptr(value))
461 mapiternext(&mapCtx.Iter)
462 code = code.Next
463 case encoder.OpMapEnd:
464
465 mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.Idx)))
466 sort.Sort(mapCtx.Slice)
467 buf := mapCtx.Buf
468 for _, item := range mapCtx.Slice.Items {
469 buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
470 }
471 buf = appendMapEnd(ctx, code, buf)
472 b = b[:mapCtx.First]
473 b = append(b, buf...)
474 mapCtx.Buf = buf
475 encoder.ReleaseMapContext(mapCtx)
476 code = code.Next
477 case encoder.OpRecursivePtr:
478 p := load(ctxptr, code.Idx)
479 if p == 0 {
480 code = code.Next
481 break
482 }
483 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
484 fallthrough
485 case encoder.OpRecursive:
486 ptr := load(ctxptr, code.Idx)
487 if ptr != 0 {
488 if recursiveLevel > encoder.StartDetectingCyclesAfter {
489 for _, seen := range ctx.SeenPtr {
490 if ptr == seen {
491 return nil, errUnsupportedValue(code, ptr)
492 }
493 }
494 }
495 }
496 ctx.SeenPtr = append(ctx.SeenPtr, ptr)
497 c := code.Jmp.Code
498 curlen := uintptr(len(ctx.Ptrs))
499 offsetNum := ptrOffset / uintptrSize
500 oldOffset := ptrOffset
501 ptrOffset += code.Jmp.CurLen * uintptrSize
502 oldBaseIndent := ctx.BaseIndent
503 indentDiffFromTop := c.Indent - 1
504 ctx.BaseIndent += code.Indent - indentDiffFromTop
505
506 newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen
507 if curlen < newLen {
508 ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...)
509 }
510 ctxptr = ctx.Ptr() + ptrOffset
511
512 store(ctxptr, c.Idx, ptr)
513 store(ctxptr, c.End.Next.Idx, oldOffset)
514 store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next)))
515 storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent))
516 code = c
517 recursiveLevel++
518 case encoder.OpRecursiveEnd:
519 recursiveLevel--
520
521
522 restoreIndent(ctx, code, ctxptr)
523 offset := load(ctxptr, code.Idx)
524 ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1]
525
526 codePtr := load(ctxptr, code.ElemIdx)
527 code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr))
528 ctxptr = ctx.Ptr() + offset
529 ptrOffset = offset
530 case encoder.OpStructPtrHead:
531 p := load(ctxptr, code.Idx)
532 if p == 0 {
533 if code.Flags&encoder.AnonymousHeadFlags == 0 {
534 b = appendNullComma(ctx, b)
535 }
536 code = code.End.Next
537 break
538 }
539 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
540 fallthrough
541 case encoder.OpStructHead:
542 p := load(ctxptr, code.Idx)
543 if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
544 if code.Flags&encoder.AnonymousHeadFlags == 0 {
545 b = appendNullComma(ctx, b)
546 }
547 code = code.End.Next
548 break
549 }
550 if code.Flags&encoder.AnonymousHeadFlags == 0 {
551 b = appendStructHead(ctx, b)
552 }
553 if len(code.Key) > 0 {
554 if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 {
555 b = appendStructKey(ctx, code, b)
556 }
557 }
558 p += uintptr(code.Offset)
559 code = code.Next
560 store(ctxptr, code.Idx, p)
561 case encoder.OpStructPtrHeadOmitEmpty:
562 p := load(ctxptr, code.Idx)
563 if p == 0 {
564 if code.Flags&encoder.AnonymousHeadFlags == 0 {
565 b = appendNullComma(ctx, b)
566 }
567 code = code.End.Next
568 break
569 }
570 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
571 fallthrough
572 case encoder.OpStructHeadOmitEmpty:
573 p := load(ctxptr, code.Idx)
574 if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
575 if code.Flags&encoder.AnonymousHeadFlags == 0 {
576 b = appendNullComma(ctx, b)
577 }
578 code = code.End.Next
579 break
580 }
581 if code.Flags&encoder.AnonymousHeadFlags == 0 {
582 b = appendStructHead(ctx, b)
583 }
584 p += uintptr(code.Offset)
585 if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) {
586 code = code.NextField
587 } else {
588 b = appendStructKey(ctx, code, b)
589 code = code.Next
590 store(ctxptr, code.Idx, p)
591 }
592 case encoder.OpStructPtrHeadInt:
593 if (code.Flags & encoder.IndirectFlags) != 0 {
594 p := load(ctxptr, code.Idx)
595 if p == 0 {
596 if code.Flags&encoder.AnonymousHeadFlags == 0 {
597 b = appendNullComma(ctx, b)
598 }
599 code = code.End.Next
600 break
601 }
602 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
603 }
604 fallthrough
605 case encoder.OpStructHeadInt:
606 p := load(ctxptr, code.Idx)
607 if p == 0 {
608 if code.Flags&encoder.AnonymousHeadFlags == 0 {
609 b = appendNullComma(ctx, b)
610 }
611 code = code.End.Next
612 break
613 }
614 if code.Flags&encoder.AnonymousHeadFlags == 0 {
615 b = appendStructHead(ctx, b)
616 }
617 b = appendStructKey(ctx, code, b)
618 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
619 b = appendComma(ctx, b)
620 code = code.Next
621 case encoder.OpStructPtrHeadOmitEmptyInt:
622 if (code.Flags & encoder.IndirectFlags) != 0 {
623 p := load(ctxptr, code.Idx)
624 if p == 0 {
625 if code.Flags&encoder.AnonymousHeadFlags == 0 {
626 b = appendNullComma(ctx, b)
627 }
628 code = code.End.Next
629 break
630 }
631 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
632 }
633 fallthrough
634 case encoder.OpStructHeadOmitEmptyInt:
635 p := load(ctxptr, code.Idx)
636 if p == 0 {
637 if code.Flags&encoder.AnonymousHeadFlags == 0 {
638 b = appendNullComma(ctx, b)
639 }
640 code = code.End.Next
641 break
642 }
643 if code.Flags&encoder.AnonymousHeadFlags == 0 {
644 b = appendStructHead(ctx, b)
645 }
646 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
647 v := u64 & ((1 << code.NumBitSize) - 1)
648 if v == 0 {
649 code = code.NextField
650 } else {
651 b = appendStructKey(ctx, code, b)
652 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
653 b = appendComma(ctx, b)
654 code = code.Next
655 }
656 case encoder.OpStructPtrHeadIntString:
657 if (code.Flags & encoder.IndirectFlags) != 0 {
658 p := load(ctxptr, code.Idx)
659 if p == 0 {
660 if code.Flags&encoder.AnonymousHeadFlags == 0 {
661 b = appendNullComma(ctx, b)
662 }
663 code = code.End.Next
664 break
665 }
666 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
667 }
668 fallthrough
669 case encoder.OpStructHeadIntString:
670 p := load(ctxptr, code.Idx)
671 if p == 0 {
672 if code.Flags&encoder.AnonymousHeadFlags == 0 {
673 b = appendNullComma(ctx, b)
674 }
675 code = code.End.Next
676 break
677 }
678 if code.Flags&encoder.AnonymousHeadFlags == 0 {
679 b = appendStructHead(ctx, b)
680 }
681 b = appendStructKey(ctx, code, b)
682 b = append(b, '"')
683 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
684 b = append(b, '"')
685 b = appendComma(ctx, b)
686 code = code.Next
687 case encoder.OpStructPtrHeadOmitEmptyIntString:
688 if (code.Flags & encoder.IndirectFlags) != 0 {
689 p := load(ctxptr, code.Idx)
690 if p == 0 {
691 if code.Flags&encoder.AnonymousHeadFlags == 0 {
692 b = appendNullComma(ctx, b)
693 }
694 code = code.End.Next
695 break
696 }
697 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
698 }
699 fallthrough
700 case encoder.OpStructHeadOmitEmptyIntString:
701 p := load(ctxptr, code.Idx)
702 if p == 0 {
703 if code.Flags&encoder.AnonymousHeadFlags == 0 {
704 b = appendNullComma(ctx, b)
705 }
706 code = code.End.Next
707 break
708 }
709 if code.Flags&encoder.AnonymousHeadFlags == 0 {
710 b = appendStructHead(ctx, b)
711 }
712 p += uintptr(code.Offset)
713 u64 := ptrToUint64(p, code.NumBitSize)
714 v := u64 & ((1 << code.NumBitSize) - 1)
715 if v == 0 {
716 code = code.NextField
717 } else {
718 b = appendStructKey(ctx, code, b)
719 b = append(b, '"')
720 b = appendInt(ctx, b, p, code)
721 b = append(b, '"')
722 b = appendComma(ctx, b)
723 code = code.Next
724 }
725 case encoder.OpStructPtrHeadIntPtr:
726 p := load(ctxptr, code.Idx)
727 if p == 0 {
728 if code.Flags&encoder.AnonymousHeadFlags == 0 {
729 b = appendNullComma(ctx, b)
730 }
731 code = code.End.Next
732 break
733 }
734 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
735 fallthrough
736 case encoder.OpStructHeadIntPtr:
737 p := load(ctxptr, code.Idx)
738 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
739 if code.Flags&encoder.AnonymousHeadFlags == 0 {
740 b = appendNullComma(ctx, b)
741 }
742 code = code.End.Next
743 break
744 }
745 if code.Flags&encoder.AnonymousHeadFlags == 0 {
746 b = appendStructHead(ctx, b)
747 }
748 b = appendStructKey(ctx, code, b)
749 if (code.Flags & encoder.IndirectFlags) != 0 {
750 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
751 }
752 if p == 0 {
753 b = appendNull(ctx, b)
754 } else {
755 b = appendInt(ctx, b, p, code)
756 }
757 b = appendComma(ctx, b)
758 code = code.Next
759 case encoder.OpStructPtrHeadOmitEmptyIntPtr:
760 p := load(ctxptr, code.Idx)
761 if p == 0 {
762 if code.Flags&encoder.AnonymousHeadFlags == 0 {
763 b = appendNullComma(ctx, b)
764 }
765 code = code.End.Next
766 break
767 }
768 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
769 fallthrough
770 case encoder.OpStructHeadOmitEmptyIntPtr:
771 p := load(ctxptr, code.Idx)
772 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
773 if code.Flags&encoder.AnonymousHeadFlags == 0 {
774 b = appendNullComma(ctx, b)
775 }
776 code = code.End.Next
777 break
778 }
779 if code.Flags&encoder.AnonymousHeadFlags == 0 {
780 b = appendStructHead(ctx, b)
781 }
782 if (code.Flags & encoder.IndirectFlags) != 0 {
783 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
784 }
785 if p != 0 {
786 b = appendStructKey(ctx, code, b)
787 b = appendInt(ctx, b, p, code)
788 b = appendComma(ctx, b)
789 }
790 code = code.Next
791 case encoder.OpStructPtrHeadIntPtrString:
792 p := load(ctxptr, code.Idx)
793 if p == 0 {
794 if code.Flags&encoder.AnonymousHeadFlags == 0 {
795 b = appendNullComma(ctx, b)
796 }
797 code = code.End.Next
798 break
799 }
800 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
801 fallthrough
802 case encoder.OpStructHeadIntPtrString:
803 p := load(ctxptr, code.Idx)
804 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
805 if code.Flags&encoder.AnonymousHeadFlags == 0 {
806 b = appendNullComma(ctx, b)
807 }
808 code = code.End.Next
809 break
810 }
811 if code.Flags&encoder.AnonymousHeadFlags == 0 {
812 b = appendStructHead(ctx, b)
813 }
814 b = appendStructKey(ctx, code, b)
815 if (code.Flags & encoder.IndirectFlags) != 0 {
816 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
817 }
818 if p == 0 {
819 b = appendNull(ctx, b)
820 } else {
821 b = append(b, '"')
822 b = appendInt(ctx, b, p, code)
823 b = append(b, '"')
824 }
825 b = appendComma(ctx, b)
826 code = code.Next
827 case encoder.OpStructPtrHeadOmitEmptyIntPtrString:
828 p := load(ctxptr, code.Idx)
829 if p == 0 {
830 if code.Flags&encoder.AnonymousHeadFlags == 0 {
831 b = appendNullComma(ctx, b)
832 }
833 code = code.End.Next
834 break
835 }
836 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
837 fallthrough
838 case encoder.OpStructHeadOmitEmptyIntPtrString:
839 p := load(ctxptr, code.Idx)
840 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
841 if code.Flags&encoder.AnonymousHeadFlags == 0 {
842 b = appendNullComma(ctx, b)
843 }
844 code = code.End.Next
845 break
846 }
847 if code.Flags&encoder.AnonymousHeadFlags == 0 {
848 b = appendStructHead(ctx, b)
849 }
850 if (code.Flags & encoder.IndirectFlags) != 0 {
851 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
852 }
853 if p != 0 {
854 b = appendStructKey(ctx, code, b)
855 b = append(b, '"')
856 b = appendInt(ctx, b, p, code)
857 b = append(b, '"')
858 b = appendComma(ctx, b)
859 }
860 code = code.Next
861 case encoder.OpStructPtrHeadUint:
862 if (code.Flags & encoder.IndirectFlags) != 0 {
863 p := load(ctxptr, code.Idx)
864 if p == 0 {
865 if code.Flags&encoder.AnonymousHeadFlags == 0 {
866 b = appendNullComma(ctx, b)
867 }
868 code = code.End.Next
869 break
870 }
871 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
872 }
873 fallthrough
874 case encoder.OpStructHeadUint:
875 p := load(ctxptr, code.Idx)
876 if p == 0 {
877 if code.Flags&encoder.AnonymousHeadFlags == 0 {
878 b = appendNullComma(ctx, b)
879 }
880 code = code.End.Next
881 break
882 }
883 if code.Flags&encoder.AnonymousHeadFlags == 0 {
884 b = appendStructHead(ctx, b)
885 }
886 b = appendStructKey(ctx, code, b)
887 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
888 b = appendComma(ctx, b)
889 code = code.Next
890 case encoder.OpStructPtrHeadOmitEmptyUint:
891 if (code.Flags & encoder.IndirectFlags) != 0 {
892 p := load(ctxptr, code.Idx)
893 if p == 0 {
894 if code.Flags&encoder.AnonymousHeadFlags == 0 {
895 b = appendNullComma(ctx, b)
896 }
897 code = code.End.Next
898 break
899 }
900 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
901 }
902 fallthrough
903 case encoder.OpStructHeadOmitEmptyUint:
904 p := load(ctxptr, code.Idx)
905 if p == 0 {
906 if code.Flags&encoder.AnonymousHeadFlags == 0 {
907 b = appendNullComma(ctx, b)
908 }
909 code = code.End.Next
910 break
911 }
912 if code.Flags&encoder.AnonymousHeadFlags == 0 {
913 b = appendStructHead(ctx, b)
914 }
915 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
916 v := u64 & ((1 << code.NumBitSize) - 1)
917 if v == 0 {
918 code = code.NextField
919 } else {
920 b = appendStructKey(ctx, code, b)
921 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
922 b = appendComma(ctx, b)
923 code = code.Next
924 }
925 case encoder.OpStructPtrHeadUintString:
926 if (code.Flags & encoder.IndirectFlags) != 0 {
927 p := load(ctxptr, code.Idx)
928 if p == 0 {
929 if code.Flags&encoder.AnonymousHeadFlags == 0 {
930 b = appendNullComma(ctx, b)
931 }
932 code = code.End.Next
933 break
934 }
935 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
936 }
937 fallthrough
938 case encoder.OpStructHeadUintString:
939 p := load(ctxptr, code.Idx)
940 if p == 0 {
941 if code.Flags&encoder.AnonymousHeadFlags == 0 {
942 b = appendNullComma(ctx, b)
943 }
944 code = code.End.Next
945 break
946 }
947 if code.Flags&encoder.AnonymousHeadFlags == 0 {
948 b = appendStructHead(ctx, b)
949 }
950 b = appendStructKey(ctx, code, b)
951 b = append(b, '"')
952 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
953 b = append(b, '"')
954 b = appendComma(ctx, b)
955 code = code.Next
956 case encoder.OpStructPtrHeadOmitEmptyUintString:
957 if (code.Flags & encoder.IndirectFlags) != 0 {
958 p := load(ctxptr, code.Idx)
959 if p == 0 {
960 if code.Flags&encoder.AnonymousHeadFlags == 0 {
961 b = appendNullComma(ctx, b)
962 }
963 code = code.End.Next
964 break
965 }
966 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
967 }
968 fallthrough
969 case encoder.OpStructHeadOmitEmptyUintString:
970 p := load(ctxptr, code.Idx)
971 if p == 0 {
972 if code.Flags&encoder.AnonymousHeadFlags == 0 {
973 b = appendNullComma(ctx, b)
974 }
975 code = code.End.Next
976 break
977 }
978 if code.Flags&encoder.AnonymousHeadFlags == 0 {
979 b = appendStructHead(ctx, b)
980 }
981 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
982 v := u64 & ((1 << code.NumBitSize) - 1)
983 if v == 0 {
984 code = code.NextField
985 } else {
986 b = appendStructKey(ctx, code, b)
987 b = append(b, '"')
988 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
989 b = append(b, '"')
990 b = appendComma(ctx, b)
991 code = code.Next
992 }
993 case encoder.OpStructPtrHeadUintPtr:
994 p := load(ctxptr, code.Idx)
995 if p == 0 {
996 if code.Flags&encoder.AnonymousHeadFlags == 0 {
997 b = appendNullComma(ctx, b)
998 }
999 code = code.End.Next
1000 break
1001 }
1002 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1003 fallthrough
1004 case encoder.OpStructHeadUintPtr:
1005 p := load(ctxptr, code.Idx)
1006 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1007 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1008 b = appendNullComma(ctx, b)
1009 }
1010 code = code.End.Next
1011 break
1012 }
1013 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1014 b = appendStructHead(ctx, b)
1015 }
1016 b = appendStructKey(ctx, code, b)
1017 if (code.Flags & encoder.IndirectFlags) != 0 {
1018 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1019 }
1020 if p == 0 {
1021 b = appendNull(ctx, b)
1022 } else {
1023 b = appendUint(ctx, b, p, code)
1024 }
1025 b = appendComma(ctx, b)
1026 code = code.Next
1027 case encoder.OpStructPtrHeadOmitEmptyUintPtr:
1028 p := load(ctxptr, code.Idx)
1029 if p == 0 {
1030 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1031 b = appendNullComma(ctx, b)
1032 }
1033 code = code.End.Next
1034 break
1035 }
1036 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1037 fallthrough
1038 case encoder.OpStructHeadOmitEmptyUintPtr:
1039 p := load(ctxptr, code.Idx)
1040 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1041 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1042 b = appendNullComma(ctx, b)
1043 }
1044 code = code.End.Next
1045 break
1046 }
1047 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1048 b = appendStructHead(ctx, b)
1049 }
1050 if (code.Flags & encoder.IndirectFlags) != 0 {
1051 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1052 }
1053 if p != 0 {
1054 b = appendStructKey(ctx, code, b)
1055 b = appendUint(ctx, b, p, code)
1056 b = appendComma(ctx, b)
1057 }
1058 code = code.Next
1059 case encoder.OpStructPtrHeadUintPtrString:
1060 p := load(ctxptr, code.Idx)
1061 if p == 0 {
1062 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1063 b = appendNullComma(ctx, b)
1064 }
1065 code = code.End.Next
1066 break
1067 }
1068 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1069 fallthrough
1070 case encoder.OpStructHeadUintPtrString:
1071 p := load(ctxptr, code.Idx)
1072 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1073 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1074 b = appendNullComma(ctx, b)
1075 }
1076 code = code.End.Next
1077 break
1078 }
1079 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1080 b = appendStructHead(ctx, b)
1081 }
1082 b = appendStructKey(ctx, code, b)
1083 if (code.Flags & encoder.IndirectFlags) != 0 {
1084 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1085 }
1086 if p == 0 {
1087 b = appendNull(ctx, b)
1088 } else {
1089 b = append(b, '"')
1090 b = appendUint(ctx, b, p, code)
1091 b = append(b, '"')
1092 }
1093 b = appendComma(ctx, b)
1094 code = code.Next
1095 case encoder.OpStructPtrHeadOmitEmptyUintPtrString:
1096 p := load(ctxptr, code.Idx)
1097 if p == 0 {
1098 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1099 b = appendNullComma(ctx, b)
1100 }
1101 code = code.End.Next
1102 break
1103 }
1104 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1105 fallthrough
1106 case encoder.OpStructHeadOmitEmptyUintPtrString:
1107 p := load(ctxptr, code.Idx)
1108 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1109 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1110 b = appendNullComma(ctx, b)
1111 }
1112 code = code.End.Next
1113 break
1114 }
1115 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1116 b = appendStructHead(ctx, b)
1117 }
1118 if (code.Flags & encoder.IndirectFlags) != 0 {
1119 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1120 }
1121 if p != 0 {
1122 b = appendStructKey(ctx, code, b)
1123 b = append(b, '"')
1124 b = appendUint(ctx, b, p, code)
1125 b = append(b, '"')
1126 b = appendComma(ctx, b)
1127 }
1128 code = code.Next
1129 case encoder.OpStructPtrHeadFloat32:
1130 if (code.Flags & encoder.IndirectFlags) != 0 {
1131 p := load(ctxptr, code.Idx)
1132 if p == 0 {
1133 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1134 b = appendNullComma(ctx, b)
1135 }
1136 code = code.End.Next
1137 break
1138 }
1139 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1140 }
1141 fallthrough
1142 case encoder.OpStructHeadFloat32:
1143 p := load(ctxptr, code.Idx)
1144 if p == 0 {
1145 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1146 b = appendNullComma(ctx, b)
1147 }
1148 code = code.End.Next
1149 break
1150 }
1151 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1152 b = appendStructHead(ctx, b)
1153 }
1154 b = appendStructKey(ctx, code, b)
1155 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
1156 b = appendComma(ctx, b)
1157 code = code.Next
1158 case encoder.OpStructPtrHeadOmitEmptyFloat32:
1159 if (code.Flags & encoder.IndirectFlags) != 0 {
1160 p := load(ctxptr, code.Idx)
1161 if p == 0 {
1162 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1163 b = appendNullComma(ctx, b)
1164 }
1165 code = code.End.Next
1166 break
1167 }
1168 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1169 }
1170 fallthrough
1171 case encoder.OpStructHeadOmitEmptyFloat32:
1172 p := load(ctxptr, code.Idx)
1173 if p == 0 {
1174 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1175 b = appendNullComma(ctx, b)
1176 }
1177 code = code.End.Next
1178 break
1179 }
1180 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1181 b = appendStructHead(ctx, b)
1182 }
1183 v := ptrToFloat32(p + uintptr(code.Offset))
1184 if v == 0 {
1185 code = code.NextField
1186 } else {
1187 b = appendStructKey(ctx, code, b)
1188 b = appendFloat32(ctx, b, v)
1189 b = appendComma(ctx, b)
1190 code = code.Next
1191 }
1192 case encoder.OpStructPtrHeadFloat32String:
1193 if (code.Flags & encoder.IndirectFlags) != 0 {
1194 p := load(ctxptr, code.Idx)
1195 if p == 0 {
1196 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1197 b = appendNullComma(ctx, b)
1198 }
1199 code = code.End.Next
1200 break
1201 }
1202 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1203 }
1204 fallthrough
1205 case encoder.OpStructHeadFloat32String:
1206 p := load(ctxptr, code.Idx)
1207 if p == 0 {
1208 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1209 b = appendNullComma(ctx, b)
1210 }
1211 code = code.End.Next
1212 break
1213 }
1214 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1215 b = appendStructHead(ctx, b)
1216 }
1217 b = appendStructKey(ctx, code, b)
1218 b = append(b, '"')
1219 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
1220 b = append(b, '"')
1221 b = appendComma(ctx, b)
1222 code = code.Next
1223 case encoder.OpStructPtrHeadOmitEmptyFloat32String:
1224 if (code.Flags & encoder.IndirectFlags) != 0 {
1225 p := load(ctxptr, code.Idx)
1226 if p == 0 {
1227 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1228 b = appendNullComma(ctx, b)
1229 }
1230 code = code.End.Next
1231 break
1232 }
1233 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1234 }
1235 fallthrough
1236 case encoder.OpStructHeadOmitEmptyFloat32String:
1237 p := load(ctxptr, code.Idx)
1238 if p == 0 {
1239 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1240 b = appendNullComma(ctx, b)
1241 }
1242 code = code.End.Next
1243 break
1244 }
1245 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1246 b = appendStructHead(ctx, b)
1247 }
1248 v := ptrToFloat32(p + uintptr(code.Offset))
1249 if v == 0 {
1250 code = code.NextField
1251 } else {
1252 b = appendStructKey(ctx, code, b)
1253 b = append(b, '"')
1254 b = appendFloat32(ctx, b, v)
1255 b = append(b, '"')
1256 b = appendComma(ctx, b)
1257 code = code.Next
1258 }
1259 case encoder.OpStructPtrHeadFloat32Ptr:
1260 p := load(ctxptr, code.Idx)
1261 if p == 0 {
1262 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1263 b = appendNullComma(ctx, b)
1264 }
1265 code = code.End.Next
1266 break
1267 }
1268 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1269 fallthrough
1270 case encoder.OpStructHeadFloat32Ptr:
1271 p := load(ctxptr, code.Idx)
1272 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1273 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1274 b = appendNullComma(ctx, b)
1275 }
1276 code = code.End.Next
1277 break
1278 }
1279 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1280 b = appendStructHead(ctx, b)
1281 }
1282 b = appendStructKey(ctx, code, b)
1283 if (code.Flags & encoder.IndirectFlags) != 0 {
1284 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1285 }
1286 if p == 0 {
1287 b = appendNull(ctx, b)
1288 } else {
1289 b = appendFloat32(ctx, b, ptrToFloat32(p))
1290 }
1291 b = appendComma(ctx, b)
1292 code = code.Next
1293 case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr:
1294 p := load(ctxptr, code.Idx)
1295 if p == 0 {
1296 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1297 b = appendNullComma(ctx, b)
1298 }
1299 code = code.End.Next
1300 break
1301 }
1302 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1303 fallthrough
1304 case encoder.OpStructHeadOmitEmptyFloat32Ptr:
1305 p := load(ctxptr, code.Idx)
1306 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1307 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1308 b = appendNullComma(ctx, b)
1309 }
1310 code = code.End.Next
1311 break
1312 }
1313 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1314 b = appendStructHead(ctx, b)
1315 }
1316 if (code.Flags & encoder.IndirectFlags) != 0 {
1317 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1318 }
1319 if p != 0 {
1320 b = appendStructKey(ctx, code, b)
1321 b = appendFloat32(ctx, b, ptrToFloat32(p))
1322 b = appendComma(ctx, b)
1323 }
1324 code = code.Next
1325 case encoder.OpStructPtrHeadFloat32PtrString:
1326 p := load(ctxptr, code.Idx)
1327 if p == 0 {
1328 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1329 b = appendNullComma(ctx, b)
1330 }
1331 code = code.End.Next
1332 break
1333 }
1334 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1335 fallthrough
1336 case encoder.OpStructHeadFloat32PtrString:
1337 p := load(ctxptr, code.Idx)
1338 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1339 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1340 b = appendNullComma(ctx, b)
1341 }
1342 code = code.End.Next
1343 break
1344 }
1345 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1346 b = appendStructHead(ctx, b)
1347 }
1348 b = appendStructKey(ctx, code, b)
1349 if (code.Flags & encoder.IndirectFlags) != 0 {
1350 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1351 }
1352 if p == 0 {
1353 b = appendNull(ctx, b)
1354 } else {
1355 b = append(b, '"')
1356 b = appendFloat32(ctx, b, ptrToFloat32(p))
1357 b = append(b, '"')
1358 }
1359 b = appendComma(ctx, b)
1360 code = code.Next
1361 case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString:
1362 p := load(ctxptr, code.Idx)
1363 if p == 0 {
1364 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1365 b = appendNullComma(ctx, b)
1366 }
1367 code = code.End.Next
1368 break
1369 }
1370 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1371 fallthrough
1372 case encoder.OpStructHeadOmitEmptyFloat32PtrString:
1373 p := load(ctxptr, code.Idx)
1374 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1375 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1376 b = appendNullComma(ctx, b)
1377 }
1378 code = code.End.Next
1379 break
1380 }
1381 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1382 b = appendStructHead(ctx, b)
1383 }
1384 if (code.Flags & encoder.IndirectFlags) != 0 {
1385 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1386 }
1387 if p != 0 {
1388 b = appendStructKey(ctx, code, b)
1389 b = append(b, '"')
1390 b = appendFloat32(ctx, b, ptrToFloat32(p))
1391 b = append(b, '"')
1392 b = appendComma(ctx, b)
1393 }
1394 code = code.Next
1395 case encoder.OpStructPtrHeadFloat64:
1396 if (code.Flags & encoder.IndirectFlags) != 0 {
1397 p := load(ctxptr, code.Idx)
1398 if p == 0 {
1399 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1400 b = appendNullComma(ctx, b)
1401 }
1402 code = code.End.Next
1403 break
1404 }
1405 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1406 }
1407 fallthrough
1408 case encoder.OpStructHeadFloat64:
1409 p := load(ctxptr, code.Idx)
1410 if p == 0 {
1411 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1412 b = appendNullComma(ctx, b)
1413 }
1414 code = code.End.Next
1415 break
1416 }
1417 v := ptrToFloat64(p + uintptr(code.Offset))
1418 if math.IsInf(v, 0) || math.IsNaN(v) {
1419 return nil, errUnsupportedFloat(v)
1420 }
1421 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1422 b = appendStructHead(ctx, b)
1423 }
1424 b = appendStructKey(ctx, code, b)
1425 b = appendFloat64(ctx, b, v)
1426 b = appendComma(ctx, b)
1427 code = code.Next
1428 case encoder.OpStructPtrHeadOmitEmptyFloat64:
1429 if (code.Flags & encoder.IndirectFlags) != 0 {
1430 p := load(ctxptr, code.Idx)
1431 if p == 0 {
1432 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1433 b = appendNullComma(ctx, b)
1434 }
1435 code = code.End.Next
1436 break
1437 }
1438 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1439 }
1440 fallthrough
1441 case encoder.OpStructHeadOmitEmptyFloat64:
1442 p := load(ctxptr, code.Idx)
1443 if p == 0 {
1444 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1445 b = appendNullComma(ctx, b)
1446 }
1447 code = code.End.Next
1448 break
1449 }
1450 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1451 b = appendStructHead(ctx, b)
1452 }
1453 v := ptrToFloat64(p + uintptr(code.Offset))
1454 if v == 0 {
1455 code = code.NextField
1456 } else {
1457 if math.IsInf(v, 0) || math.IsNaN(v) {
1458 return nil, errUnsupportedFloat(v)
1459 }
1460 b = appendStructKey(ctx, code, b)
1461 b = appendFloat64(ctx, b, v)
1462 b = appendComma(ctx, b)
1463 code = code.Next
1464 }
1465 case encoder.OpStructPtrHeadFloat64String:
1466 if (code.Flags & encoder.IndirectFlags) != 0 {
1467 p := load(ctxptr, code.Idx)
1468 if p == 0 {
1469 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1470 b = appendNullComma(ctx, b)
1471 }
1472 code = code.End.Next
1473 break
1474 }
1475 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1476 }
1477 fallthrough
1478 case encoder.OpStructHeadFloat64String:
1479 p := load(ctxptr, code.Idx)
1480 if p == 0 {
1481 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1482 b = appendNullComma(ctx, b)
1483 }
1484 code = code.End.Next
1485 break
1486 }
1487 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1488 b = appendStructHead(ctx, b)
1489 }
1490 v := ptrToFloat64(p + uintptr(code.Offset))
1491 if math.IsInf(v, 0) || math.IsNaN(v) {
1492 return nil, errUnsupportedFloat(v)
1493 }
1494 b = appendStructKey(ctx, code, b)
1495 b = append(b, '"')
1496 b = appendFloat64(ctx, b, v)
1497 b = append(b, '"')
1498 b = appendComma(ctx, b)
1499 code = code.Next
1500 case encoder.OpStructPtrHeadOmitEmptyFloat64String:
1501 if (code.Flags & encoder.IndirectFlags) != 0 {
1502 p := load(ctxptr, code.Idx)
1503 if p == 0 {
1504 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1505 b = appendNullComma(ctx, b)
1506 }
1507 code = code.End.Next
1508 break
1509 }
1510 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1511 }
1512 fallthrough
1513 case encoder.OpStructHeadOmitEmptyFloat64String:
1514 p := load(ctxptr, code.Idx)
1515 if p == 0 {
1516 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1517 b = appendNullComma(ctx, b)
1518 }
1519 code = code.End.Next
1520 break
1521 }
1522 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1523 b = appendStructHead(ctx, b)
1524 }
1525 v := ptrToFloat64(p + uintptr(code.Offset))
1526 if v == 0 {
1527 code = code.NextField
1528 } else {
1529 if math.IsInf(v, 0) || math.IsNaN(v) {
1530 return nil, errUnsupportedFloat(v)
1531 }
1532 b = appendStructKey(ctx, code, b)
1533 b = append(b, '"')
1534 b = appendFloat64(ctx, b, v)
1535 b = append(b, '"')
1536 b = appendComma(ctx, b)
1537 code = code.Next
1538 }
1539 case encoder.OpStructPtrHeadFloat64Ptr:
1540 p := load(ctxptr, code.Idx)
1541 if p == 0 {
1542 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1543 b = appendNullComma(ctx, b)
1544 }
1545 code = code.End.Next
1546 break
1547 }
1548 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1549 fallthrough
1550 case encoder.OpStructHeadFloat64Ptr:
1551 p := load(ctxptr, code.Idx)
1552 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1553 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1554 b = appendNullComma(ctx, b)
1555 }
1556 code = code.End.Next
1557 break
1558 }
1559 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1560 b = appendStructHead(ctx, b)
1561 }
1562 b = appendStructKey(ctx, code, b)
1563 if (code.Flags & encoder.IndirectFlags) != 0 {
1564 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1565 }
1566 if p == 0 {
1567 b = appendNull(ctx, b)
1568 } else {
1569 v := ptrToFloat64(p)
1570 if math.IsInf(v, 0) || math.IsNaN(v) {
1571 return nil, errUnsupportedFloat(v)
1572 }
1573 b = appendFloat64(ctx, b, v)
1574 }
1575 b = appendComma(ctx, b)
1576 code = code.Next
1577 case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr:
1578 p := load(ctxptr, code.Idx)
1579 if p == 0 {
1580 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1581 b = appendNullComma(ctx, b)
1582 }
1583 code = code.End.Next
1584 break
1585 }
1586 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1587 fallthrough
1588 case encoder.OpStructHeadOmitEmptyFloat64Ptr:
1589 p := load(ctxptr, code.Idx)
1590 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1591 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1592 b = appendNullComma(ctx, b)
1593 }
1594 code = code.End.Next
1595 break
1596 }
1597 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1598 b = appendStructHead(ctx, b)
1599 }
1600 if (code.Flags & encoder.IndirectFlags) != 0 {
1601 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1602 }
1603 if p != 0 {
1604 b = appendStructKey(ctx, code, b)
1605 v := ptrToFloat64(p)
1606 if math.IsInf(v, 0) || math.IsNaN(v) {
1607 return nil, errUnsupportedFloat(v)
1608 }
1609 b = appendFloat64(ctx, b, v)
1610 b = appendComma(ctx, b)
1611 }
1612 code = code.Next
1613 case encoder.OpStructPtrHeadFloat64PtrString:
1614 p := load(ctxptr, code.Idx)
1615 if p == 0 {
1616 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1617 b = appendNullComma(ctx, b)
1618 }
1619 code = code.End.Next
1620 break
1621 }
1622 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1623 fallthrough
1624 case encoder.OpStructHeadFloat64PtrString:
1625 p := load(ctxptr, code.Idx)
1626 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1627 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1628 b = appendNullComma(ctx, b)
1629 }
1630 code = code.End.Next
1631 break
1632 }
1633 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1634 b = appendStructHead(ctx, b)
1635 }
1636 b = appendStructKey(ctx, code, b)
1637 if (code.Flags & encoder.IndirectFlags) != 0 {
1638 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1639 }
1640 if p == 0 {
1641 b = appendNull(ctx, b)
1642 } else {
1643 b = append(b, '"')
1644 v := ptrToFloat64(p)
1645 if math.IsInf(v, 0) || math.IsNaN(v) {
1646 return nil, errUnsupportedFloat(v)
1647 }
1648 b = appendFloat64(ctx, b, v)
1649 b = append(b, '"')
1650 }
1651 b = appendComma(ctx, b)
1652 code = code.Next
1653 case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString:
1654 p := load(ctxptr, code.Idx)
1655 if p == 0 {
1656 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1657 b = appendNullComma(ctx, b)
1658 }
1659 code = code.End.Next
1660 break
1661 }
1662 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1663 fallthrough
1664 case encoder.OpStructHeadOmitEmptyFloat64PtrString:
1665 p := load(ctxptr, code.Idx)
1666 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1667 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1668 b = appendNullComma(ctx, b)
1669 }
1670 code = code.End.Next
1671 break
1672 }
1673 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1674 b = appendStructHead(ctx, b)
1675 }
1676 if (code.Flags & encoder.IndirectFlags) != 0 {
1677 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1678 }
1679 if p != 0 {
1680 b = appendStructKey(ctx, code, b)
1681 b = append(b, '"')
1682 v := ptrToFloat64(p)
1683 if math.IsInf(v, 0) || math.IsNaN(v) {
1684 return nil, errUnsupportedFloat(v)
1685 }
1686 b = appendFloat64(ctx, b, v)
1687 b = append(b, '"')
1688 b = appendComma(ctx, b)
1689 }
1690 code = code.Next
1691 case encoder.OpStructPtrHeadString:
1692 if (code.Flags & encoder.IndirectFlags) != 0 {
1693 p := load(ctxptr, code.Idx)
1694 if p == 0 {
1695 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1696 b = appendNullComma(ctx, b)
1697 }
1698 code = code.End.Next
1699 break
1700 }
1701 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1702 }
1703 fallthrough
1704 case encoder.OpStructHeadString:
1705 p := load(ctxptr, code.Idx)
1706 if p == 0 {
1707 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1708 b = appendNull(ctx, b)
1709 b = appendComma(ctx, b)
1710 }
1711 code = code.End.Next
1712 break
1713 }
1714 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1715 b = appendStructHead(ctx, b)
1716 }
1717 b = appendStructKey(ctx, code, b)
1718 b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
1719 b = appendComma(ctx, b)
1720 code = code.Next
1721 case encoder.OpStructPtrHeadOmitEmptyString:
1722 if (code.Flags & encoder.IndirectFlags) != 0 {
1723 p := load(ctxptr, code.Idx)
1724 if p == 0 {
1725 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1726 b = appendNullComma(ctx, b)
1727 }
1728 code = code.End.Next
1729 break
1730 }
1731 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1732 }
1733 fallthrough
1734 case encoder.OpStructHeadOmitEmptyString:
1735 p := load(ctxptr, code.Idx)
1736 if p == 0 {
1737 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1738 b = appendNullComma(ctx, b)
1739 }
1740 code = code.End.Next
1741 break
1742 }
1743 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1744 b = appendStructHead(ctx, b)
1745 }
1746 v := ptrToString(p + uintptr(code.Offset))
1747 if v == "" {
1748 code = code.NextField
1749 } else {
1750 b = appendStructKey(ctx, code, b)
1751 b = appendString(ctx, b, v)
1752 b = appendComma(ctx, b)
1753 code = code.Next
1754 }
1755 case encoder.OpStructPtrHeadStringString:
1756 if (code.Flags & encoder.IndirectFlags) != 0 {
1757 p := load(ctxptr, code.Idx)
1758 if p == 0 {
1759 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1760 b = appendNullComma(ctx, b)
1761 }
1762 code = code.End.Next
1763 break
1764 }
1765 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1766 }
1767 fallthrough
1768 case encoder.OpStructHeadStringString:
1769 p := load(ctxptr, code.Idx)
1770 if p == 0 {
1771 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1772 b = appendNullComma(ctx, b)
1773 }
1774 code = code.End.Next
1775 break
1776 }
1777 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1778 b = appendStructHead(ctx, b)
1779 }
1780 b = appendStructKey(ctx, code, b)
1781 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset)))))
1782 b = appendComma(ctx, b)
1783 code = code.Next
1784 case encoder.OpStructPtrHeadOmitEmptyStringString:
1785 if (code.Flags & encoder.IndirectFlags) != 0 {
1786 p := load(ctxptr, code.Idx)
1787 if p == 0 {
1788 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1789 b = appendNullComma(ctx, b)
1790 }
1791 code = code.End.Next
1792 break
1793 }
1794 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1795 }
1796 fallthrough
1797 case encoder.OpStructHeadOmitEmptyStringString:
1798 p := load(ctxptr, code.Idx)
1799 if p == 0 {
1800 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1801 b = appendNullComma(ctx, b)
1802 }
1803 code = code.End.Next
1804 break
1805 }
1806 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1807 b = appendStructHead(ctx, b)
1808 }
1809 v := ptrToString(p + uintptr(code.Offset))
1810 if v == "" {
1811 code = code.NextField
1812 } else {
1813 b = appendStructKey(ctx, code, b)
1814 b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
1815 b = appendComma(ctx, b)
1816 code = code.Next
1817 }
1818 case encoder.OpStructPtrHeadStringPtr:
1819 p := load(ctxptr, code.Idx)
1820 if p == 0 {
1821 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1822 b = appendNullComma(ctx, b)
1823 }
1824 code = code.End.Next
1825 break
1826 }
1827 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1828 fallthrough
1829 case encoder.OpStructHeadStringPtr:
1830 p := load(ctxptr, code.Idx)
1831 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1832 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1833 b = appendNullComma(ctx, b)
1834 }
1835 code = code.End.Next
1836 break
1837 }
1838 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1839 b = appendStructHead(ctx, b)
1840 }
1841 b = appendStructKey(ctx, code, b)
1842 if (code.Flags & encoder.IndirectFlags) != 0 {
1843 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1844 }
1845 if p == 0 {
1846 b = appendNull(ctx, b)
1847 } else {
1848 b = appendString(ctx, b, ptrToString(p))
1849 }
1850 b = appendComma(ctx, b)
1851 code = code.Next
1852 case encoder.OpStructPtrHeadOmitEmptyStringPtr:
1853 p := load(ctxptr, code.Idx)
1854 if p == 0 {
1855 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1856 b = appendNullComma(ctx, b)
1857 }
1858 code = code.End.Next
1859 break
1860 }
1861 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1862 fallthrough
1863 case encoder.OpStructHeadOmitEmptyStringPtr:
1864 p := load(ctxptr, code.Idx)
1865 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1866 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1867 b = appendNullComma(ctx, b)
1868 }
1869 code = code.End.Next
1870 break
1871 }
1872 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1873 b = appendStructHead(ctx, b)
1874 }
1875 if (code.Flags & encoder.IndirectFlags) != 0 {
1876 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1877 }
1878 if p != 0 {
1879 b = appendStructKey(ctx, code, b)
1880 b = appendString(ctx, b, ptrToString(p))
1881 b = appendComma(ctx, b)
1882 }
1883 code = code.Next
1884 case encoder.OpStructPtrHeadStringPtrString:
1885 p := load(ctxptr, code.Idx)
1886 if p == 0 {
1887 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1888 b = appendNullComma(ctx, b)
1889 }
1890 code = code.End.Next
1891 break
1892 }
1893 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1894 fallthrough
1895 case encoder.OpStructHeadStringPtrString:
1896 p := load(ctxptr, code.Idx)
1897 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1898 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1899 b = appendNullComma(ctx, b)
1900 }
1901 code = code.End.Next
1902 break
1903 }
1904 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1905 b = appendStructHead(ctx, b)
1906 }
1907 b = appendStructKey(ctx, code, b)
1908 if (code.Flags & encoder.IndirectFlags) != 0 {
1909 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1910 }
1911 if p == 0 {
1912 b = appendNull(ctx, b)
1913 } else {
1914 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
1915 }
1916 b = appendComma(ctx, b)
1917 code = code.Next
1918 case encoder.OpStructPtrHeadOmitEmptyStringPtrString:
1919 p := load(ctxptr, code.Idx)
1920 if p == 0 {
1921 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1922 b = appendNullComma(ctx, b)
1923 }
1924 code = code.End.Next
1925 break
1926 }
1927 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1928 fallthrough
1929 case encoder.OpStructHeadOmitEmptyStringPtrString:
1930 p := load(ctxptr, code.Idx)
1931 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
1932 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1933 b = appendNullComma(ctx, b)
1934 }
1935 code = code.End.Next
1936 break
1937 }
1938 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1939 b = appendStructHead(ctx, b)
1940 }
1941 if (code.Flags & encoder.IndirectFlags) != 0 {
1942 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
1943 }
1944 if p != 0 {
1945 b = appendStructKey(ctx, code, b)
1946 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
1947 b = appendComma(ctx, b)
1948 }
1949 code = code.Next
1950 case encoder.OpStructPtrHeadBool:
1951 if (code.Flags & encoder.IndirectFlags) != 0 {
1952 p := load(ctxptr, code.Idx)
1953 if p == 0 {
1954 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1955 b = appendNullComma(ctx, b)
1956 }
1957 code = code.End.Next
1958 break
1959 }
1960 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1961 }
1962 fallthrough
1963 case encoder.OpStructHeadBool:
1964 p := load(ctxptr, code.Idx)
1965 if p == 0 {
1966 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1967 b = appendNullComma(ctx, b)
1968 }
1969 code = code.End.Next
1970 break
1971 }
1972 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1973 b = appendStructHead(ctx, b)
1974 }
1975 b = appendStructKey(ctx, code, b)
1976 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
1977 b = appendComma(ctx, b)
1978 code = code.Next
1979 case encoder.OpStructPtrHeadOmitEmptyBool:
1980 if (code.Flags & encoder.IndirectFlags) != 0 {
1981 p := load(ctxptr, code.Idx)
1982 if p == 0 {
1983 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1984 b = appendNullComma(ctx, b)
1985 }
1986 code = code.End.Next
1987 break
1988 }
1989 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
1990 }
1991 fallthrough
1992 case encoder.OpStructHeadOmitEmptyBool:
1993 p := load(ctxptr, code.Idx)
1994 if p == 0 {
1995 if code.Flags&encoder.AnonymousHeadFlags == 0 {
1996 b = appendNullComma(ctx, b)
1997 }
1998 code = code.End.Next
1999 break
2000 }
2001 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2002 b = appendStructHead(ctx, b)
2003 }
2004 v := ptrToBool(p + uintptr(code.Offset))
2005 if v {
2006 b = appendStructKey(ctx, code, b)
2007 b = appendBool(ctx, b, v)
2008 b = appendComma(ctx, b)
2009 code = code.Next
2010 } else {
2011 code = code.NextField
2012 }
2013 case encoder.OpStructPtrHeadBoolString:
2014 if (code.Flags & encoder.IndirectFlags) != 0 {
2015 p := load(ctxptr, code.Idx)
2016 if p == 0 {
2017 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2018 b = appendNullComma(ctx, b)
2019 }
2020 code = code.End.Next
2021 break
2022 }
2023 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2024 }
2025 fallthrough
2026 case encoder.OpStructHeadBoolString:
2027 p := load(ctxptr, code.Idx)
2028 if p == 0 {
2029 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2030 b = appendNullComma(ctx, b)
2031 }
2032 code = code.End.Next
2033 break
2034 }
2035 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2036 b = appendStructHead(ctx, b)
2037 }
2038 b = appendStructKey(ctx, code, b)
2039 b = append(b, '"')
2040 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
2041 b = append(b, '"')
2042 b = appendComma(ctx, b)
2043 code = code.Next
2044 case encoder.OpStructPtrHeadOmitEmptyBoolString:
2045 if (code.Flags & encoder.IndirectFlags) != 0 {
2046 p := load(ctxptr, code.Idx)
2047 if p == 0 {
2048 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2049 b = appendNullComma(ctx, b)
2050 }
2051 code = code.End.Next
2052 break
2053 }
2054 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2055 }
2056 fallthrough
2057 case encoder.OpStructHeadOmitEmptyBoolString:
2058 p := load(ctxptr, code.Idx)
2059 if p == 0 {
2060 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2061 b = appendNullComma(ctx, b)
2062 }
2063 code = code.End.Next
2064 break
2065 }
2066 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2067 b = appendStructHead(ctx, b)
2068 }
2069 v := ptrToBool(p + uintptr(code.Offset))
2070 if v {
2071 b = appendStructKey(ctx, code, b)
2072 b = append(b, '"')
2073 b = appendBool(ctx, b, v)
2074 b = append(b, '"')
2075 b = appendComma(ctx, b)
2076 code = code.Next
2077 } else {
2078 code = code.NextField
2079 }
2080 case encoder.OpStructPtrHeadBoolPtr:
2081 p := load(ctxptr, code.Idx)
2082 if p == 0 {
2083 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2084 b = appendNullComma(ctx, b)
2085 }
2086 code = code.End.Next
2087 break
2088 }
2089 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2090 fallthrough
2091 case encoder.OpStructHeadBoolPtr:
2092 p := load(ctxptr, code.Idx)
2093 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2094 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2095 b = appendNullComma(ctx, b)
2096 }
2097 code = code.End.Next
2098 break
2099 }
2100 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2101 b = appendStructHead(ctx, b)
2102 }
2103 b = appendStructKey(ctx, code, b)
2104 if (code.Flags & encoder.IndirectFlags) != 0 {
2105 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2106 }
2107 if p == 0 {
2108 b = appendNull(ctx, b)
2109 } else {
2110 b = appendBool(ctx, b, ptrToBool(p))
2111 }
2112 b = appendComma(ctx, b)
2113 code = code.Next
2114 case encoder.OpStructPtrHeadOmitEmptyBoolPtr:
2115 p := load(ctxptr, code.Idx)
2116 if p == 0 {
2117 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2118 b = appendNullComma(ctx, b)
2119 }
2120 code = code.End.Next
2121 break
2122 }
2123 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2124 fallthrough
2125 case encoder.OpStructHeadOmitEmptyBoolPtr:
2126 p := load(ctxptr, code.Idx)
2127 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2128 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2129 b = appendNullComma(ctx, b)
2130 }
2131 code = code.End.Next
2132 break
2133 }
2134 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2135 b = appendStructHead(ctx, b)
2136 }
2137 if (code.Flags & encoder.IndirectFlags) != 0 {
2138 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2139 }
2140 if p != 0 {
2141 b = appendStructKey(ctx, code, b)
2142 b = appendBool(ctx, b, ptrToBool(p))
2143 b = appendComma(ctx, b)
2144 }
2145 code = code.Next
2146 case encoder.OpStructPtrHeadBoolPtrString:
2147 p := load(ctxptr, code.Idx)
2148 if p == 0 {
2149 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2150 b = appendNullComma(ctx, b)
2151 }
2152 code = code.End.Next
2153 break
2154 }
2155 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2156 fallthrough
2157 case encoder.OpStructHeadBoolPtrString:
2158 p := load(ctxptr, code.Idx)
2159 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2160 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2161 b = appendNullComma(ctx, b)
2162 }
2163 code = code.End.Next
2164 break
2165 }
2166 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2167 b = appendStructHead(ctx, b)
2168 }
2169 b = appendStructKey(ctx, code, b)
2170 if (code.Flags & encoder.IndirectFlags) != 0 {
2171 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2172 }
2173 if p == 0 {
2174 b = appendNull(ctx, b)
2175 } else {
2176 b = append(b, '"')
2177 b = appendBool(ctx, b, ptrToBool(p))
2178 b = append(b, '"')
2179 }
2180 b = appendComma(ctx, b)
2181 code = code.Next
2182 case encoder.OpStructPtrHeadOmitEmptyBoolPtrString:
2183 p := load(ctxptr, code.Idx)
2184 if p == 0 {
2185 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2186 b = appendNullComma(ctx, b)
2187 }
2188 code = code.End.Next
2189 break
2190 }
2191 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2192 fallthrough
2193 case encoder.OpStructHeadOmitEmptyBoolPtrString:
2194 p := load(ctxptr, code.Idx)
2195 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2196 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2197 b = appendNullComma(ctx, b)
2198 }
2199 code = code.End.Next
2200 break
2201 }
2202 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2203 b = appendStructHead(ctx, b)
2204 }
2205 if (code.Flags & encoder.IndirectFlags) != 0 {
2206 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2207 }
2208 if p != 0 {
2209 b = appendStructKey(ctx, code, b)
2210 b = append(b, '"')
2211 b = appendBool(ctx, b, ptrToBool(p))
2212 b = append(b, '"')
2213 b = appendComma(ctx, b)
2214 }
2215 code = code.Next
2216 case encoder.OpStructPtrHeadBytes:
2217 if (code.Flags & encoder.IndirectFlags) != 0 {
2218 p := load(ctxptr, code.Idx)
2219 if p == 0 {
2220 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2221 b = appendNullComma(ctx, b)
2222 }
2223 code = code.End.Next
2224 break
2225 }
2226 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2227 }
2228 fallthrough
2229 case encoder.OpStructHeadBytes:
2230 p := load(ctxptr, code.Idx)
2231 if p == 0 {
2232 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2233 b = appendNullComma(ctx, b)
2234 }
2235 code = code.End.Next
2236 break
2237 }
2238 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2239 b = appendStructHead(ctx, b)
2240 }
2241 b = appendStructKey(ctx, code, b)
2242 b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
2243 b = appendComma(ctx, b)
2244 code = code.Next
2245 case encoder.OpStructPtrHeadOmitEmptyBytes:
2246 if (code.Flags & encoder.IndirectFlags) != 0 {
2247 p := load(ctxptr, code.Idx)
2248 if p == 0 {
2249 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2250 b = appendNullComma(ctx, b)
2251 }
2252 code = code.End.Next
2253 break
2254 }
2255 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2256 }
2257 fallthrough
2258 case encoder.OpStructHeadOmitEmptyBytes:
2259 p := load(ctxptr, code.Idx)
2260 if p == 0 {
2261 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2262 b = appendNullComma(ctx, b)
2263 }
2264 code = code.End.Next
2265 break
2266 }
2267 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2268 b = appendStructHead(ctx, b)
2269 }
2270 v := ptrToBytes(p + uintptr(code.Offset))
2271 if len(v) == 0 {
2272 code = code.NextField
2273 } else {
2274 b = appendStructKey(ctx, code, b)
2275 b = appendByteSlice(ctx, b, v)
2276 b = appendComma(ctx, b)
2277 code = code.Next
2278 }
2279 case encoder.OpStructPtrHeadBytesPtr:
2280 p := load(ctxptr, code.Idx)
2281 if p == 0 {
2282 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2283 b = appendNullComma(ctx, b)
2284 }
2285 code = code.End.Next
2286 break
2287 }
2288 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2289 fallthrough
2290 case encoder.OpStructHeadBytesPtr:
2291 p := load(ctxptr, code.Idx)
2292 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2293 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2294 b = appendNullComma(ctx, b)
2295 }
2296 code = code.End.Next
2297 break
2298 }
2299 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2300 b = appendStructHead(ctx, b)
2301 }
2302 b = appendStructKey(ctx, code, b)
2303 if (code.Flags & encoder.IndirectFlags) != 0 {
2304 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2305 }
2306 if p == 0 {
2307 b = appendNull(ctx, b)
2308 } else {
2309 b = appendByteSlice(ctx, b, ptrToBytes(p))
2310 }
2311 b = appendComma(ctx, b)
2312 code = code.Next
2313 case encoder.OpStructPtrHeadOmitEmptyBytesPtr:
2314 p := load(ctxptr, code.Idx)
2315 if p == 0 {
2316 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2317 b = appendNullComma(ctx, b)
2318 }
2319 code = code.End.Next
2320 break
2321 }
2322 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2323 fallthrough
2324 case encoder.OpStructHeadOmitEmptyBytesPtr:
2325 p := load(ctxptr, code.Idx)
2326 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2327 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2328 b = appendNullComma(ctx, b)
2329 }
2330 code = code.End.Next
2331 break
2332 }
2333 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2334 b = appendStructHead(ctx, b)
2335 }
2336 if (code.Flags & encoder.IndirectFlags) != 0 {
2337 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2338 }
2339 if p != 0 {
2340 b = appendStructKey(ctx, code, b)
2341 b = appendByteSlice(ctx, b, ptrToBytes(p))
2342 b = appendComma(ctx, b)
2343 }
2344 code = code.Next
2345 case encoder.OpStructPtrHeadNumber:
2346 if (code.Flags & encoder.IndirectFlags) != 0 {
2347 p := load(ctxptr, code.Idx)
2348 if p == 0 {
2349 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2350 b = appendNullComma(ctx, b)
2351 }
2352 code = code.End.Next
2353 break
2354 }
2355 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2356 }
2357 fallthrough
2358 case encoder.OpStructHeadNumber:
2359 p := load(ctxptr, code.Idx)
2360 if p == 0 {
2361 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2362 b = appendNullComma(ctx, b)
2363 }
2364 code = code.End.Next
2365 break
2366 }
2367 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2368 b = appendStructHead(ctx, b)
2369 }
2370 b = appendStructKey(ctx, code, b)
2371 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2372 if err != nil {
2373 return nil, err
2374 }
2375 b = appendComma(ctx, bb)
2376 code = code.Next
2377 case encoder.OpStructPtrHeadOmitEmptyNumber:
2378 if (code.Flags & encoder.IndirectFlags) != 0 {
2379 p := load(ctxptr, code.Idx)
2380 if p == 0 {
2381 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2382 b = appendNullComma(ctx, b)
2383 }
2384 code = code.End.Next
2385 break
2386 }
2387 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2388 }
2389 fallthrough
2390 case encoder.OpStructHeadOmitEmptyNumber:
2391 p := load(ctxptr, code.Idx)
2392 if p == 0 {
2393 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2394 b = appendNullComma(ctx, b)
2395 }
2396 code = code.End.Next
2397 break
2398 }
2399 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2400 b = appendStructHead(ctx, b)
2401 }
2402 v := ptrToNumber(p + uintptr(code.Offset))
2403 if v == "" {
2404 code = code.NextField
2405 } else {
2406 b = appendStructKey(ctx, code, b)
2407 bb, err := appendNumber(ctx, b, v)
2408 if err != nil {
2409 return nil, err
2410 }
2411 b = appendComma(ctx, bb)
2412 code = code.Next
2413 }
2414 case encoder.OpStructPtrHeadNumberString:
2415 if (code.Flags & encoder.IndirectFlags) != 0 {
2416 p := load(ctxptr, code.Idx)
2417 if p == 0 {
2418 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2419 b = appendNullComma(ctx, b)
2420 }
2421 code = code.End.Next
2422 break
2423 }
2424 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2425 }
2426 fallthrough
2427 case encoder.OpStructHeadNumberString:
2428 p := load(ctxptr, code.Idx)
2429 if p == 0 {
2430 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2431 b = appendNullComma(ctx, b)
2432 }
2433 code = code.End.Next
2434 break
2435 }
2436 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2437 b = appendStructHead(ctx, b)
2438 }
2439 b = appendStructKey(ctx, code, b)
2440 b = append(b, '"')
2441 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2442 if err != nil {
2443 return nil, err
2444 }
2445 b = append(bb, '"')
2446 b = appendComma(ctx, b)
2447 code = code.Next
2448 case encoder.OpStructPtrHeadOmitEmptyNumberString:
2449 if (code.Flags & encoder.IndirectFlags) != 0 {
2450 p := load(ctxptr, code.Idx)
2451 if p == 0 {
2452 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2453 b = appendNullComma(ctx, b)
2454 }
2455 code = code.End.Next
2456 break
2457 }
2458 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2459 }
2460 fallthrough
2461 case encoder.OpStructHeadOmitEmptyNumberString:
2462 p := load(ctxptr, code.Idx)
2463 if p == 0 {
2464 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2465 b = appendNullComma(ctx, b)
2466 }
2467 code = code.End.Next
2468 break
2469 }
2470 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2471 b = appendStructHead(ctx, b)
2472 }
2473 v := ptrToNumber(p + uintptr(code.Offset))
2474 if v == "" {
2475 code = code.NextField
2476 } else {
2477 b = appendStructKey(ctx, code, b)
2478 b = append(b, '"')
2479 bb, err := appendNumber(ctx, b, v)
2480 if err != nil {
2481 return nil, err
2482 }
2483 b = append(bb, '"')
2484 b = appendComma(ctx, b)
2485 code = code.Next
2486 }
2487 case encoder.OpStructPtrHeadNumberPtr:
2488 p := load(ctxptr, code.Idx)
2489 if p == 0 {
2490 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2491 b = appendNullComma(ctx, b)
2492 }
2493 code = code.End.Next
2494 break
2495 }
2496 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2497 fallthrough
2498 case encoder.OpStructHeadNumberPtr:
2499 p := load(ctxptr, code.Idx)
2500 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2501 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2502 b = appendNullComma(ctx, b)
2503 }
2504 code = code.End.Next
2505 break
2506 }
2507 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2508 b = appendStructHead(ctx, b)
2509 }
2510 b = appendStructKey(ctx, code, b)
2511 if (code.Flags & encoder.IndirectFlags) != 0 {
2512 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2513 }
2514 if p == 0 {
2515 b = appendNull(ctx, b)
2516 } else {
2517 bb, err := appendNumber(ctx, b, ptrToNumber(p))
2518 if err != nil {
2519 return nil, err
2520 }
2521 b = bb
2522 }
2523 b = appendComma(ctx, b)
2524 code = code.Next
2525 case encoder.OpStructPtrHeadOmitEmptyNumberPtr:
2526 p := load(ctxptr, code.Idx)
2527 if p == 0 {
2528 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2529 b = appendNullComma(ctx, b)
2530 }
2531 code = code.End.Next
2532 break
2533 }
2534 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2535 fallthrough
2536 case encoder.OpStructHeadOmitEmptyNumberPtr:
2537 p := load(ctxptr, code.Idx)
2538 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2539 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2540 b = appendNullComma(ctx, b)
2541 }
2542 code = code.End.Next
2543 break
2544 }
2545 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2546 b = appendStructHead(ctx, b)
2547 }
2548 if (code.Flags & encoder.IndirectFlags) != 0 {
2549 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2550 }
2551 if p != 0 {
2552 b = appendStructKey(ctx, code, b)
2553 bb, err := appendNumber(ctx, b, ptrToNumber(p))
2554 if err != nil {
2555 return nil, err
2556 }
2557 b = appendComma(ctx, bb)
2558 }
2559 code = code.Next
2560 case encoder.OpStructPtrHeadNumberPtrString:
2561 p := load(ctxptr, code.Idx)
2562 if p == 0 {
2563 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2564 b = appendNullComma(ctx, b)
2565 }
2566 code = code.End.Next
2567 break
2568 }
2569 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2570 fallthrough
2571 case encoder.OpStructHeadNumberPtrString:
2572 p := load(ctxptr, code.Idx)
2573 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2574 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2575 b = appendNullComma(ctx, b)
2576 }
2577 code = code.End.Next
2578 break
2579 }
2580 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2581 b = appendStructHead(ctx, b)
2582 }
2583 b = appendStructKey(ctx, code, b)
2584 if (code.Flags & encoder.IndirectFlags) != 0 {
2585 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2586 }
2587 if p == 0 {
2588 b = appendNull(ctx, b)
2589 } else {
2590 b = append(b, '"')
2591 bb, err := appendNumber(ctx, b, ptrToNumber(p))
2592 if err != nil {
2593 return nil, err
2594 }
2595 b = append(bb, '"')
2596 }
2597 b = appendComma(ctx, b)
2598 code = code.Next
2599 case encoder.OpStructPtrHeadOmitEmptyNumberPtrString:
2600 p := load(ctxptr, code.Idx)
2601 if p == 0 {
2602 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2603 b = appendNullComma(ctx, b)
2604 }
2605 code = code.End.Next
2606 break
2607 }
2608 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2609 fallthrough
2610 case encoder.OpStructHeadOmitEmptyNumberPtrString:
2611 p := load(ctxptr, code.Idx)
2612 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2613 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2614 b = appendNullComma(ctx, b)
2615 }
2616 code = code.End.Next
2617 break
2618 }
2619 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2620 b = appendStructHead(ctx, b)
2621 }
2622 if (code.Flags & encoder.IndirectFlags) != 0 {
2623 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2624 }
2625 if p != 0 {
2626 b = appendStructKey(ctx, code, b)
2627 b = append(b, '"')
2628 bb, err := appendNumber(ctx, b, ptrToNumber(p))
2629 if err != nil {
2630 return nil, err
2631 }
2632 b = append(bb, '"')
2633 b = appendComma(ctx, b)
2634 }
2635 code = code.Next
2636 case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
2637 if (code.Flags & encoder.IndirectFlags) != 0 {
2638 p := load(ctxptr, code.Idx)
2639 if p == 0 {
2640 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2641 b = appendNullComma(ctx, b)
2642 }
2643 code = code.End.Next
2644 break
2645 }
2646 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2647 }
2648 fallthrough
2649 case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
2650 p := load(ctxptr, code.Idx)
2651 if p == 0 {
2652 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2653 b = appendNullComma(ctx, b)
2654 }
2655 code = code.End.Next
2656 break
2657 }
2658 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2659 b = appendStructHead(ctx, b)
2660 }
2661 b = appendStructKey(ctx, code, b)
2662 p += uintptr(code.Offset)
2663 code = code.Next
2664 store(ctxptr, code.Idx, p)
2665 case encoder.OpStructPtrHeadOmitEmptyArray:
2666 if (code.Flags & encoder.IndirectFlags) != 0 {
2667 p := load(ctxptr, code.Idx)
2668 if p == 0 {
2669 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2670 b = appendNullComma(ctx, b)
2671 }
2672 code = code.End.Next
2673 break
2674 }
2675 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2676 }
2677 fallthrough
2678 case encoder.OpStructHeadOmitEmptyArray:
2679 p := load(ctxptr, code.Idx)
2680 if p == 0 {
2681 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2682 b = appendNullComma(ctx, b)
2683 }
2684 code = code.End.Next
2685 break
2686 }
2687 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2688 b = appendStructHead(ctx, b)
2689 }
2690 p += uintptr(code.Offset)
2691 b = appendStructKey(ctx, code, b)
2692 code = code.Next
2693 store(ctxptr, code.Idx, p)
2694 case encoder.OpStructPtrHeadOmitEmptySlice:
2695 if (code.Flags & encoder.IndirectFlags) != 0 {
2696 p := load(ctxptr, code.Idx)
2697 if p == 0 {
2698 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2699 b = appendNullComma(ctx, b)
2700 }
2701 code = code.End.Next
2702 break
2703 }
2704 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2705 }
2706 fallthrough
2707 case encoder.OpStructHeadOmitEmptySlice:
2708 p := load(ctxptr, code.Idx)
2709 if p == 0 {
2710 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2711 b = appendNullComma(ctx, b)
2712 }
2713 code = code.End.Next
2714 break
2715 }
2716 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2717 b = appendStructHead(ctx, b)
2718 }
2719 p += uintptr(code.Offset)
2720 slice := ptrToSlice(p)
2721 if slice.Len == 0 {
2722 code = code.NextField
2723 } else {
2724 b = appendStructKey(ctx, code, b)
2725 code = code.Next
2726 store(ctxptr, code.Idx, p)
2727 }
2728 case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
2729 p := load(ctxptr, code.Idx)
2730 if p == 0 {
2731 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2732 b = appendNullComma(ctx, b)
2733 }
2734 code = code.End.Next
2735 break
2736 }
2737 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2738 fallthrough
2739 case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
2740 p := load(ctxptr, code.Idx)
2741 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2742 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2743 b = appendNullComma(ctx, b)
2744 }
2745 code = code.End.Next
2746 break
2747 }
2748 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2749 b = appendStructHead(ctx, b)
2750 }
2751 b = appendStructKey(ctx, code, b)
2752 if (code.Flags & encoder.IndirectFlags) != 0 {
2753 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2754 }
2755 if p == 0 {
2756 b = appendNullComma(ctx, b)
2757 code = code.NextField
2758 } else {
2759 code = code.Next
2760 store(ctxptr, code.Idx, p)
2761 }
2762 case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr:
2763 p := load(ctxptr, code.Idx)
2764 if p == 0 {
2765 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2766 b = appendNullComma(ctx, b)
2767 }
2768 code = code.End.Next
2769 break
2770 }
2771 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2772 fallthrough
2773 case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr:
2774 p := load(ctxptr, code.Idx)
2775 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2776 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2777 b = appendNullComma(ctx, b)
2778 }
2779 code = code.End.Next
2780 break
2781 }
2782 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2783 b = appendStructHead(ctx, b)
2784 }
2785 if (code.Flags & encoder.IndirectFlags) != 0 {
2786 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2787 }
2788 if p == 0 {
2789 code = code.NextField
2790 } else {
2791 b = appendStructKey(ctx, code, b)
2792 code = code.Next
2793 store(ctxptr, code.Idx, p)
2794 }
2795 case encoder.OpStructPtrHeadMap:
2796 p := load(ctxptr, code.Idx)
2797 if p == 0 {
2798 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2799 b = appendNullComma(ctx, b)
2800 }
2801 code = code.End.Next
2802 break
2803 }
2804 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2805 fallthrough
2806 case encoder.OpStructHeadMap:
2807 p := load(ctxptr, code.Idx)
2808 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2809 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2810 b = appendNullComma(ctx, b)
2811 }
2812 code = code.End.Next
2813 break
2814 }
2815 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2816 b = appendStructHead(ctx, b)
2817 }
2818 b = appendStructKey(ctx, code, b)
2819 if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2820 p = ptrToPtr(p + uintptr(code.Offset))
2821 }
2822 code = code.Next
2823 store(ctxptr, code.Idx, p)
2824 case encoder.OpStructPtrHeadOmitEmptyMap:
2825 p := load(ctxptr, code.Idx)
2826 if p == 0 {
2827 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2828 b = appendNullComma(ctx, b)
2829 }
2830 code = code.End.Next
2831 break
2832 }
2833 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2834 fallthrough
2835 case encoder.OpStructHeadOmitEmptyMap:
2836 p := load(ctxptr, code.Idx)
2837 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2838 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2839 b = appendNullComma(ctx, b)
2840 }
2841 code = code.End.Next
2842 break
2843 }
2844 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2845 b = appendStructHead(ctx, b)
2846 }
2847 if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2848 p = ptrToPtr(p + uintptr(code.Offset))
2849 }
2850 if maplen(ptrToUnsafePtr(p)) == 0 {
2851 code = code.NextField
2852 } else {
2853 b = appendStructKey(ctx, code, b)
2854 code = code.Next
2855 store(ctxptr, code.Idx, p)
2856 }
2857 case encoder.OpStructPtrHeadMapPtr:
2858 p := load(ctxptr, code.Idx)
2859 if p == 0 {
2860 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2861 b = appendNullComma(ctx, b)
2862 }
2863 code = code.End.Next
2864 break
2865 }
2866 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2867 fallthrough
2868 case encoder.OpStructHeadMapPtr:
2869 p := load(ctxptr, code.Idx)
2870 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2871 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2872 b = appendNullComma(ctx, b)
2873 }
2874 code = code.End.Next
2875 break
2876 }
2877 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2878 b = appendStructHead(ctx, b)
2879 }
2880 b = appendStructKey(ctx, code, b)
2881 if p == 0 {
2882 b = appendNullComma(ctx, b)
2883 code = code.NextField
2884 break
2885 }
2886 p = ptrToPtr(p + uintptr(code.Offset))
2887 if p == 0 {
2888 b = appendNullComma(ctx, b)
2889 code = code.NextField
2890 } else {
2891 if (code.Flags & encoder.IndirectFlags) != 0 {
2892 p = ptrToNPtr(p, code.PtrNum)
2893 }
2894 code = code.Next
2895 store(ctxptr, code.Idx, p)
2896 }
2897 case encoder.OpStructPtrHeadOmitEmptyMapPtr:
2898 p := load(ctxptr, code.Idx)
2899 if p == 0 {
2900 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2901 b = appendNullComma(ctx, b)
2902 }
2903 code = code.End.Next
2904 break
2905 }
2906 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2907 fallthrough
2908 case encoder.OpStructHeadOmitEmptyMapPtr:
2909 p := load(ctxptr, code.Idx)
2910 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2911 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2912 b = appendNullComma(ctx, b)
2913 }
2914 code = code.End.Next
2915 break
2916 }
2917 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2918 b = appendStructHead(ctx, b)
2919 }
2920 if p == 0 {
2921 code = code.NextField
2922 break
2923 }
2924 p = ptrToPtr(p + uintptr(code.Offset))
2925 if p == 0 {
2926 code = code.NextField
2927 } else {
2928 if (code.Flags & encoder.IndirectFlags) != 0 {
2929 p = ptrToNPtr(p, code.PtrNum)
2930 }
2931 b = appendStructKey(ctx, code, b)
2932 code = code.Next
2933 store(ctxptr, code.Idx, p)
2934 }
2935 case encoder.OpStructPtrHeadMarshalJSON:
2936 p := load(ctxptr, code.Idx)
2937 if p == 0 {
2938 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2939 b = appendNullComma(ctx, b)
2940 }
2941 code = code.End.Next
2942 break
2943 }
2944 if (code.Flags & encoder.IndirectFlags) != 0 {
2945 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2946 }
2947 fallthrough
2948 case encoder.OpStructHeadMarshalJSON:
2949 p := load(ctxptr, code.Idx)
2950 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2951 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2952 b = appendNullComma(ctx, b)
2953 }
2954 code = code.End.Next
2955 break
2956 }
2957 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2958 b = appendStructHead(ctx, b)
2959 }
2960 b = appendStructKey(ctx, code, b)
2961 p += uintptr(code.Offset)
2962 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
2963 if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
2964 p = ptrToPtr(p)
2965 }
2966 }
2967 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
2968 b = appendNull(ctx, b)
2969 } else {
2970 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2971 if err != nil {
2972 return nil, err
2973 }
2974 b = bb
2975 }
2976 b = appendComma(ctx, b)
2977 code = code.Next
2978 case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
2979 p := load(ctxptr, code.Idx)
2980 if p == 0 {
2981 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2982 b = appendNullComma(ctx, b)
2983 }
2984 code = code.End.Next
2985 break
2986 }
2987 if (code.Flags & encoder.IndirectFlags) != 0 {
2988 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2989 }
2990 fallthrough
2991 case encoder.OpStructHeadOmitEmptyMarshalJSON:
2992 p := load(ctxptr, code.Idx)
2993 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2994 if code.Flags&encoder.AnonymousHeadFlags == 0 {
2995 b = appendNullComma(ctx, b)
2996 }
2997 code = code.End.Next
2998 break
2999 }
3000 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3001 b = appendStructHead(ctx, b)
3002 }
3003 p += uintptr(code.Offset)
3004 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3005 if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
3006 p = ptrToPtr(p)
3007 }
3008 }
3009 iface := ptrToInterface(code, p)
3010 if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) {
3011 code = code.NextField
3012 } else {
3013 b = appendStructKey(ctx, code, b)
3014 bb, err := appendMarshalJSON(ctx, code, b, iface)
3015 if err != nil {
3016 return nil, err
3017 }
3018 b = bb
3019 b = appendComma(ctx, b)
3020 code = code.Next
3021 }
3022 case encoder.OpStructPtrHeadMarshalJSONPtr:
3023 p := load(ctxptr, code.Idx)
3024 if p == 0 {
3025 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3026 b = appendNullComma(ctx, b)
3027 }
3028 code = code.End.Next
3029 break
3030 }
3031 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3032 fallthrough
3033 case encoder.OpStructHeadMarshalJSONPtr:
3034 p := load(ctxptr, code.Idx)
3035 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3036 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3037 b = appendNullComma(ctx, b)
3038 }
3039 code = code.End.Next
3040 break
3041 }
3042 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3043 b = appendStructHead(ctx, b)
3044 }
3045 b = appendStructKey(ctx, code, b)
3046 if (code.Flags & encoder.IndirectFlags) != 0 {
3047 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3048 }
3049 if p == 0 {
3050 b = appendNull(ctx, b)
3051 } else {
3052 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
3053 if err != nil {
3054 return nil, err
3055 }
3056 b = bb
3057 }
3058 b = appendComma(ctx, b)
3059 code = code.Next
3060 case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr:
3061 p := load(ctxptr, code.Idx)
3062 if p == 0 {
3063 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3064 b = appendNullComma(ctx, b)
3065 }
3066 code = code.End.Next
3067 break
3068 }
3069 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3070 fallthrough
3071 case encoder.OpStructHeadOmitEmptyMarshalJSONPtr:
3072 p := load(ctxptr, code.Idx)
3073 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3074 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3075 b = appendNullComma(ctx, b)
3076 }
3077 code = code.End.Next
3078 break
3079 }
3080 if (code.Flags & encoder.IndirectFlags) != 0 {
3081 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3082 }
3083 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3084 b = appendStructHead(ctx, b)
3085 }
3086 if p == 0 {
3087 code = code.NextField
3088 } else {
3089 b = appendStructKey(ctx, code, b)
3090 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
3091 if err != nil {
3092 return nil, err
3093 }
3094 b = bb
3095 b = appendComma(ctx, b)
3096 code = code.Next
3097 }
3098 case encoder.OpStructPtrHeadMarshalText:
3099 p := load(ctxptr, code.Idx)
3100 if p == 0 {
3101 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3102 b = appendNullComma(ctx, b)
3103 }
3104 code = code.End.Next
3105 break
3106 }
3107 if (code.Flags & encoder.IndirectFlags) != 0 {
3108 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3109 }
3110 fallthrough
3111 case encoder.OpStructHeadMarshalText:
3112 p := load(ctxptr, code.Idx)
3113 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3114 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3115 b = appendNullComma(ctx, b)
3116 }
3117 code = code.End.Next
3118 break
3119 }
3120 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3121 b = appendStructHead(ctx, b)
3122 }
3123 b = appendStructKey(ctx, code, b)
3124 p += uintptr(code.Offset)
3125 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3126 if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
3127 p = ptrToPtr(p)
3128 }
3129 }
3130 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
3131 b = appendNull(ctx, b)
3132 } else {
3133 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
3134 if err != nil {
3135 return nil, err
3136 }
3137 b = bb
3138 }
3139 b = appendComma(ctx, b)
3140 code = code.Next
3141 case encoder.OpStructPtrHeadOmitEmptyMarshalText:
3142 p := load(ctxptr, code.Idx)
3143 if p == 0 {
3144 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3145 b = appendNullComma(ctx, b)
3146 }
3147 code = code.End.Next
3148 break
3149 }
3150 if (code.Flags & encoder.IndirectFlags) != 0 {
3151 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3152 }
3153 fallthrough
3154 case encoder.OpStructHeadOmitEmptyMarshalText:
3155 p := load(ctxptr, code.Idx)
3156 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3157 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3158 b = appendNullComma(ctx, b)
3159 }
3160 code = code.End.Next
3161 break
3162 }
3163 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3164 b = appendStructHead(ctx, b)
3165 }
3166 p += uintptr(code.Offset)
3167 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3168 if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
3169 p = ptrToPtr(p)
3170 }
3171 }
3172 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
3173 code = code.NextField
3174 } else {
3175 b = appendStructKey(ctx, code, b)
3176 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
3177 if err != nil {
3178 return nil, err
3179 }
3180 b = bb
3181 b = appendComma(ctx, b)
3182 code = code.Next
3183 }
3184 case encoder.OpStructPtrHeadMarshalTextPtr:
3185 p := load(ctxptr, code.Idx)
3186 if p == 0 {
3187 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3188 b = appendNullComma(ctx, b)
3189 }
3190 code = code.End.Next
3191 break
3192 }
3193 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3194 fallthrough
3195 case encoder.OpStructHeadMarshalTextPtr:
3196 p := load(ctxptr, code.Idx)
3197 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3198 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3199 b = appendNullComma(ctx, b)
3200 }
3201 code = code.End.Next
3202 break
3203 }
3204 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3205 b = appendStructHead(ctx, b)
3206 }
3207 b = appendStructKey(ctx, code, b)
3208 if (code.Flags & encoder.IndirectFlags) != 0 {
3209 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3210 }
3211 if p == 0 {
3212 b = appendNull(ctx, b)
3213 } else {
3214 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
3215 if err != nil {
3216 return nil, err
3217 }
3218 b = bb
3219 }
3220 b = appendComma(ctx, b)
3221 code = code.Next
3222 case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr:
3223 p := load(ctxptr, code.Idx)
3224 if p == 0 {
3225 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3226 b = appendNullComma(ctx, b)
3227 }
3228 code = code.End.Next
3229 break
3230 }
3231 store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
3232 fallthrough
3233 case encoder.OpStructHeadOmitEmptyMarshalTextPtr:
3234 p := load(ctxptr, code.Idx)
3235 if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
3236 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3237 b = appendNullComma(ctx, b)
3238 }
3239 code = code.End.Next
3240 break
3241 }
3242 if (code.Flags & encoder.IndirectFlags) != 0 {
3243 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3244 }
3245 if code.Flags&encoder.AnonymousHeadFlags == 0 {
3246 b = appendStructHead(ctx, b)
3247 }
3248 if p == 0 {
3249 code = code.NextField
3250 } else {
3251 b = appendStructKey(ctx, code, b)
3252 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
3253 if err != nil {
3254 return nil, err
3255 }
3256 b = bb
3257 b = appendComma(ctx, b)
3258 code = code.Next
3259 }
3260 case encoder.OpStructField:
3261 if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 {
3262 b = appendStructKey(ctx, code, b)
3263 }
3264 p := load(ctxptr, code.Idx) + uintptr(code.Offset)
3265 code = code.Next
3266 store(ctxptr, code.Idx, p)
3267 case encoder.OpStructFieldOmitEmpty:
3268 p := load(ctxptr, code.Idx)
3269 p += uintptr(code.Offset)
3270 if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 {
3271 code = code.NextField
3272 } else {
3273 b = appendStructKey(ctx, code, b)
3274 code = code.Next
3275 store(ctxptr, code.Idx, p)
3276 }
3277 case encoder.OpStructFieldInt:
3278 p := load(ctxptr, code.Idx)
3279 b = appendStructKey(ctx, code, b)
3280 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
3281 b = appendComma(ctx, b)
3282 code = code.Next
3283 case encoder.OpStructFieldOmitEmptyInt:
3284 p := load(ctxptr, code.Idx)
3285 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
3286 v := u64 & ((1 << code.NumBitSize) - 1)
3287 if v != 0 {
3288 b = appendStructKey(ctx, code, b)
3289 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
3290 b = appendComma(ctx, b)
3291 }
3292 code = code.Next
3293 case encoder.OpStructFieldIntString:
3294 p := load(ctxptr, code.Idx)
3295 b = appendStructKey(ctx, code, b)
3296 b = append(b, '"')
3297 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
3298 b = append(b, '"')
3299 b = appendComma(ctx, b)
3300 code = code.Next
3301 case encoder.OpStructFieldOmitEmptyIntString:
3302 p := load(ctxptr, code.Idx)
3303 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
3304 v := u64 & ((1 << code.NumBitSize) - 1)
3305 if v != 0 {
3306 b = appendStructKey(ctx, code, b)
3307 b = append(b, '"')
3308 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
3309 b = append(b, '"')
3310 b = appendComma(ctx, b)
3311 }
3312 code = code.Next
3313 case encoder.OpStructFieldIntPtr:
3314 p := load(ctxptr, code.Idx)
3315 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3316 b = appendStructKey(ctx, code, b)
3317 if p == 0 {
3318 b = appendNull(ctx, b)
3319 } else {
3320 b = appendInt(ctx, b, p, code)
3321 }
3322 b = appendComma(ctx, b)
3323 code = code.Next
3324 case encoder.OpStructFieldOmitEmptyIntPtr:
3325 p := load(ctxptr, code.Idx)
3326 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3327 if p != 0 {
3328 b = appendStructKey(ctx, code, b)
3329 b = appendInt(ctx, b, p, code)
3330 b = appendComma(ctx, b)
3331 }
3332 code = code.Next
3333 case encoder.OpStructFieldIntPtrString:
3334 p := load(ctxptr, code.Idx)
3335 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3336 b = appendStructKey(ctx, code, b)
3337 if p == 0 {
3338 b = appendNull(ctx, b)
3339 } else {
3340 b = append(b, '"')
3341 b = appendInt(ctx, b, p, code)
3342 b = append(b, '"')
3343 }
3344 b = appendComma(ctx, b)
3345 code = code.Next
3346 case encoder.OpStructFieldOmitEmptyIntPtrString:
3347 p := load(ctxptr, code.Idx)
3348 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3349 if p != 0 {
3350 b = appendStructKey(ctx, code, b)
3351 b = append(b, '"')
3352 b = appendInt(ctx, b, p, code)
3353 b = append(b, '"')
3354 b = appendComma(ctx, b)
3355 }
3356 code = code.Next
3357 case encoder.OpStructFieldUint:
3358 p := load(ctxptr, code.Idx)
3359 b = appendStructKey(ctx, code, b)
3360 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
3361 b = appendComma(ctx, b)
3362 code = code.Next
3363 case encoder.OpStructFieldOmitEmptyUint:
3364 p := load(ctxptr, code.Idx)
3365 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
3366 v := u64 & ((1 << code.NumBitSize) - 1)
3367 if v != 0 {
3368 b = appendStructKey(ctx, code, b)
3369 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
3370 b = appendComma(ctx, b)
3371 }
3372 code = code.Next
3373 case encoder.OpStructFieldUintString:
3374 p := load(ctxptr, code.Idx)
3375 b = appendStructKey(ctx, code, b)
3376 b = append(b, '"')
3377 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
3378 b = append(b, '"')
3379 b = appendComma(ctx, b)
3380 code = code.Next
3381 case encoder.OpStructFieldOmitEmptyUintString:
3382 p := load(ctxptr, code.Idx)
3383 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
3384 v := u64 & ((1 << code.NumBitSize) - 1)
3385 if v != 0 {
3386 b = appendStructKey(ctx, code, b)
3387 b = append(b, '"')
3388 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
3389 b = append(b, '"')
3390 b = appendComma(ctx, b)
3391 }
3392 code = code.Next
3393 case encoder.OpStructFieldUintPtr:
3394 p := load(ctxptr, code.Idx)
3395 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3396 b = appendStructKey(ctx, code, b)
3397 if p == 0 {
3398 b = appendNull(ctx, b)
3399 } else {
3400 b = appendUint(ctx, b, p, code)
3401 }
3402 b = appendComma(ctx, b)
3403 code = code.Next
3404 case encoder.OpStructFieldOmitEmptyUintPtr:
3405 p := load(ctxptr, code.Idx)
3406 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3407 if p != 0 {
3408 b = appendStructKey(ctx, code, b)
3409 b = appendUint(ctx, b, p, code)
3410 b = appendComma(ctx, b)
3411 }
3412 code = code.Next
3413 case encoder.OpStructFieldUintPtrString:
3414 p := load(ctxptr, code.Idx)
3415 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3416 b = appendStructKey(ctx, code, b)
3417 if p == 0 {
3418 b = appendNull(ctx, b)
3419 } else {
3420 b = append(b, '"')
3421 b = appendUint(ctx, b, p, code)
3422 b = append(b, '"')
3423 }
3424 b = appendComma(ctx, b)
3425 code = code.Next
3426 case encoder.OpStructFieldOmitEmptyUintPtrString:
3427 p := load(ctxptr, code.Idx)
3428 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3429 if p != 0 {
3430 b = appendStructKey(ctx, code, b)
3431 b = append(b, '"')
3432 b = appendUint(ctx, b, p, code)
3433 b = append(b, '"')
3434 b = appendComma(ctx, b)
3435 }
3436 code = code.Next
3437 case encoder.OpStructFieldFloat32:
3438 p := load(ctxptr, code.Idx)
3439 b = appendStructKey(ctx, code, b)
3440 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
3441 b = appendComma(ctx, b)
3442 code = code.Next
3443 case encoder.OpStructFieldOmitEmptyFloat32:
3444 p := load(ctxptr, code.Idx)
3445 v := ptrToFloat32(p + uintptr(code.Offset))
3446 if v != 0 {
3447 b = appendStructKey(ctx, code, b)
3448 b = appendFloat32(ctx, b, v)
3449 b = appendComma(ctx, b)
3450 }
3451 code = code.Next
3452 case encoder.OpStructFieldFloat32String:
3453 p := load(ctxptr, code.Idx)
3454 b = appendStructKey(ctx, code, b)
3455 b = append(b, '"')
3456 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
3457 b = append(b, '"')
3458 b = appendComma(ctx, b)
3459 code = code.Next
3460 case encoder.OpStructFieldOmitEmptyFloat32String:
3461 p := load(ctxptr, code.Idx)
3462 v := ptrToFloat32(p + uintptr(code.Offset))
3463 if v != 0 {
3464 b = appendStructKey(ctx, code, b)
3465 b = append(b, '"')
3466 b = appendFloat32(ctx, b, v)
3467 b = append(b, '"')
3468 b = appendComma(ctx, b)
3469 }
3470 code = code.Next
3471 case encoder.OpStructFieldFloat32Ptr:
3472 p := load(ctxptr, code.Idx)
3473 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3474 b = appendStructKey(ctx, code, b)
3475 if p == 0 {
3476 b = appendNull(ctx, b)
3477 } else {
3478 b = appendFloat32(ctx, b, ptrToFloat32(p))
3479 }
3480 b = appendComma(ctx, b)
3481 code = code.Next
3482 case encoder.OpStructFieldOmitEmptyFloat32Ptr:
3483 p := load(ctxptr, code.Idx)
3484 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3485 if p != 0 {
3486 b = appendStructKey(ctx, code, b)
3487 b = appendFloat32(ctx, b, ptrToFloat32(p))
3488 b = appendComma(ctx, b)
3489 }
3490 code = code.Next
3491 case encoder.OpStructFieldFloat32PtrString:
3492 p := load(ctxptr, code.Idx)
3493 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3494 b = appendStructKey(ctx, code, b)
3495 if p == 0 {
3496 b = appendNull(ctx, b)
3497 } else {
3498 b = append(b, '"')
3499 b = appendFloat32(ctx, b, ptrToFloat32(p))
3500 b = append(b, '"')
3501 }
3502 b = appendComma(ctx, b)
3503 code = code.Next
3504 case encoder.OpStructFieldOmitEmptyFloat32PtrString:
3505 p := load(ctxptr, code.Idx)
3506 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3507 if p != 0 {
3508 b = appendStructKey(ctx, code, b)
3509 b = append(b, '"')
3510 b = appendFloat32(ctx, b, ptrToFloat32(p))
3511 b = append(b, '"')
3512 b = appendComma(ctx, b)
3513 }
3514 code = code.Next
3515 case encoder.OpStructFieldFloat64:
3516 p := load(ctxptr, code.Idx)
3517 b = appendStructKey(ctx, code, b)
3518 v := ptrToFloat64(p + uintptr(code.Offset))
3519 if math.IsInf(v, 0) || math.IsNaN(v) {
3520 return nil, errUnsupportedFloat(v)
3521 }
3522 b = appendFloat64(ctx, b, v)
3523 b = appendComma(ctx, b)
3524 code = code.Next
3525 case encoder.OpStructFieldOmitEmptyFloat64:
3526 p := load(ctxptr, code.Idx)
3527 v := ptrToFloat64(p + uintptr(code.Offset))
3528 if v != 0 {
3529 if math.IsInf(v, 0) || math.IsNaN(v) {
3530 return nil, errUnsupportedFloat(v)
3531 }
3532 b = appendStructKey(ctx, code, b)
3533 b = appendFloat64(ctx, b, v)
3534 b = appendComma(ctx, b)
3535 }
3536 code = code.Next
3537 case encoder.OpStructFieldFloat64String:
3538 p := load(ctxptr, code.Idx)
3539 v := ptrToFloat64(p + uintptr(code.Offset))
3540 if math.IsInf(v, 0) || math.IsNaN(v) {
3541 return nil, errUnsupportedFloat(v)
3542 }
3543 b = appendStructKey(ctx, code, b)
3544 b = append(b, '"')
3545 b = appendFloat64(ctx, b, v)
3546 b = append(b, '"')
3547 b = appendComma(ctx, b)
3548 code = code.Next
3549 case encoder.OpStructFieldOmitEmptyFloat64String:
3550 p := load(ctxptr, code.Idx)
3551 v := ptrToFloat64(p + uintptr(code.Offset))
3552 if v != 0 {
3553 if math.IsInf(v, 0) || math.IsNaN(v) {
3554 return nil, errUnsupportedFloat(v)
3555 }
3556 b = appendStructKey(ctx, code, b)
3557 b = append(b, '"')
3558 b = appendFloat64(ctx, b, v)
3559 b = append(b, '"')
3560 b = appendComma(ctx, b)
3561 }
3562 code = code.Next
3563 case encoder.OpStructFieldFloat64Ptr:
3564 p := load(ctxptr, code.Idx)
3565 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3566 b = appendStructKey(ctx, code, b)
3567 if p == 0 {
3568 b = appendNullComma(ctx, b)
3569 code = code.Next
3570 break
3571 }
3572 v := ptrToFloat64(p)
3573 if math.IsInf(v, 0) || math.IsNaN(v) {
3574 return nil, errUnsupportedFloat(v)
3575 }
3576 b = appendFloat64(ctx, b, v)
3577 b = appendComma(ctx, b)
3578 code = code.Next
3579 case encoder.OpStructFieldOmitEmptyFloat64Ptr:
3580 p := load(ctxptr, code.Idx)
3581 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3582 if p != 0 {
3583 b = appendStructKey(ctx, code, b)
3584 v := ptrToFloat64(p)
3585 if math.IsInf(v, 0) || math.IsNaN(v) {
3586 return nil, errUnsupportedFloat(v)
3587 }
3588 b = appendFloat64(ctx, b, v)
3589 b = appendComma(ctx, b)
3590 }
3591 code = code.Next
3592 case encoder.OpStructFieldFloat64PtrString:
3593 p := load(ctxptr, code.Idx)
3594 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3595 b = appendStructKey(ctx, code, b)
3596 if p == 0 {
3597 b = appendNull(ctx, b)
3598 } else {
3599 v := ptrToFloat64(p)
3600 if math.IsInf(v, 0) || math.IsNaN(v) {
3601 return nil, errUnsupportedFloat(v)
3602 }
3603 b = append(b, '"')
3604 b = appendFloat64(ctx, b, v)
3605 b = append(b, '"')
3606 }
3607 b = appendComma(ctx, b)
3608 code = code.Next
3609 case encoder.OpStructFieldOmitEmptyFloat64PtrString:
3610 p := load(ctxptr, code.Idx)
3611 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3612 if p != 0 {
3613 b = appendStructKey(ctx, code, b)
3614 b = append(b, '"')
3615 v := ptrToFloat64(p)
3616 if math.IsInf(v, 0) || math.IsNaN(v) {
3617 return nil, errUnsupportedFloat(v)
3618 }
3619 b = appendFloat64(ctx, b, v)
3620 b = append(b, '"')
3621 b = appendComma(ctx, b)
3622 }
3623 code = code.Next
3624 case encoder.OpStructFieldString:
3625 p := load(ctxptr, code.Idx)
3626 b = appendStructKey(ctx, code, b)
3627 b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
3628 b = appendComma(ctx, b)
3629 code = code.Next
3630 case encoder.OpStructFieldOmitEmptyString:
3631 p := load(ctxptr, code.Idx)
3632 v := ptrToString(p + uintptr(code.Offset))
3633 if v != "" {
3634 b = appendStructKey(ctx, code, b)
3635 b = appendString(ctx, b, v)
3636 b = appendComma(ctx, b)
3637 }
3638 code = code.Next
3639 case encoder.OpStructFieldStringString:
3640 p := load(ctxptr, code.Idx)
3641 s := ptrToString(p + uintptr(code.Offset))
3642 b = appendStructKey(ctx, code, b)
3643 b = appendString(ctx, b, string(appendString(ctx, []byte{}, s)))
3644 b = appendComma(ctx, b)
3645 code = code.Next
3646 case encoder.OpStructFieldOmitEmptyStringString:
3647 p := load(ctxptr, code.Idx)
3648 v := ptrToString(p + uintptr(code.Offset))
3649 if v != "" {
3650 b = appendStructKey(ctx, code, b)
3651 b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
3652 b = appendComma(ctx, b)
3653 }
3654 code = code.Next
3655 case encoder.OpStructFieldStringPtr:
3656 p := load(ctxptr, code.Idx)
3657 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3658 b = appendStructKey(ctx, code, b)
3659 if p == 0 {
3660 b = appendNull(ctx, b)
3661 } else {
3662 b = appendString(ctx, b, ptrToString(p))
3663 }
3664 b = appendComma(ctx, b)
3665 code = code.Next
3666 case encoder.OpStructFieldOmitEmptyStringPtr:
3667 p := load(ctxptr, code.Idx)
3668 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3669 if p != 0 {
3670 b = appendStructKey(ctx, code, b)
3671 b = appendString(ctx, b, ptrToString(p))
3672 b = appendComma(ctx, b)
3673 }
3674 code = code.Next
3675 case encoder.OpStructFieldStringPtrString:
3676 p := load(ctxptr, code.Idx)
3677 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3678 b = appendStructKey(ctx, code, b)
3679 if p == 0 {
3680 b = appendNull(ctx, b)
3681 } else {
3682 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
3683 }
3684 b = appendComma(ctx, b)
3685 code = code.Next
3686 case encoder.OpStructFieldOmitEmptyStringPtrString:
3687 p := load(ctxptr, code.Idx)
3688 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3689 if p != 0 {
3690 b = appendStructKey(ctx, code, b)
3691 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
3692 b = appendComma(ctx, b)
3693 }
3694 code = code.Next
3695 case encoder.OpStructFieldBool:
3696 p := load(ctxptr, code.Idx)
3697 b = appendStructKey(ctx, code, b)
3698 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
3699 b = appendComma(ctx, b)
3700 code = code.Next
3701 case encoder.OpStructFieldOmitEmptyBool:
3702 p := load(ctxptr, code.Idx)
3703 v := ptrToBool(p + uintptr(code.Offset))
3704 if v {
3705 b = appendStructKey(ctx, code, b)
3706 b = appendBool(ctx, b, v)
3707 b = appendComma(ctx, b)
3708 }
3709 code = code.Next
3710 case encoder.OpStructFieldBoolString:
3711 p := load(ctxptr, code.Idx)
3712 b = appendStructKey(ctx, code, b)
3713 b = append(b, '"')
3714 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
3715 b = append(b, '"')
3716 b = appendComma(ctx, b)
3717 code = code.Next
3718 case encoder.OpStructFieldOmitEmptyBoolString:
3719 p := load(ctxptr, code.Idx)
3720 v := ptrToBool(p + uintptr(code.Offset))
3721 if v {
3722 b = appendStructKey(ctx, code, b)
3723 b = append(b, '"')
3724 b = appendBool(ctx, b, v)
3725 b = append(b, '"')
3726 b = appendComma(ctx, b)
3727 }
3728 code = code.Next
3729 case encoder.OpStructFieldBoolPtr:
3730 p := load(ctxptr, code.Idx)
3731 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3732 b = appendStructKey(ctx, code, b)
3733 if p == 0 {
3734 b = appendNull(ctx, b)
3735 } else {
3736 b = appendBool(ctx, b, ptrToBool(p))
3737 }
3738 b = appendComma(ctx, b)
3739 code = code.Next
3740 case encoder.OpStructFieldOmitEmptyBoolPtr:
3741 p := load(ctxptr, code.Idx)
3742 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3743 if p != 0 {
3744 b = appendStructKey(ctx, code, b)
3745 b = appendBool(ctx, b, ptrToBool(p))
3746 b = appendComma(ctx, b)
3747 }
3748 code = code.Next
3749 case encoder.OpStructFieldBoolPtrString:
3750 p := load(ctxptr, code.Idx)
3751 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3752 b = appendStructKey(ctx, code, b)
3753 if p == 0 {
3754 b = appendNull(ctx, b)
3755 } else {
3756 b = append(b, '"')
3757 b = appendBool(ctx, b, ptrToBool(p))
3758 b = append(b, '"')
3759 }
3760 b = appendComma(ctx, b)
3761 code = code.Next
3762 case encoder.OpStructFieldOmitEmptyBoolPtrString:
3763 p := load(ctxptr, code.Idx)
3764 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3765 if p != 0 {
3766 b = appendStructKey(ctx, code, b)
3767 b = append(b, '"')
3768 b = appendBool(ctx, b, ptrToBool(p))
3769 b = append(b, '"')
3770 b = appendComma(ctx, b)
3771 }
3772 code = code.Next
3773 case encoder.OpStructFieldBytes:
3774 p := load(ctxptr, code.Idx)
3775 b = appendStructKey(ctx, code, b)
3776 b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
3777 b = appendComma(ctx, b)
3778 code = code.Next
3779 case encoder.OpStructFieldOmitEmptyBytes:
3780 p := load(ctxptr, code.Idx)
3781 v := ptrToBytes(p + uintptr(code.Offset))
3782 if len(v) > 0 {
3783 b = appendStructKey(ctx, code, b)
3784 b = appendByteSlice(ctx, b, v)
3785 b = appendComma(ctx, b)
3786 }
3787 code = code.Next
3788 case encoder.OpStructFieldBytesPtr:
3789 p := load(ctxptr, code.Idx)
3790 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3791 b = appendStructKey(ctx, code, b)
3792 if p == 0 {
3793 b = appendNull(ctx, b)
3794 } else {
3795 b = appendByteSlice(ctx, b, ptrToBytes(p))
3796 }
3797 b = appendComma(ctx, b)
3798 code = code.Next
3799 case encoder.OpStructFieldOmitEmptyBytesPtr:
3800 p := load(ctxptr, code.Idx)
3801 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3802 if p != 0 {
3803 b = appendStructKey(ctx, code, b)
3804 b = appendByteSlice(ctx, b, ptrToBytes(p))
3805 b = appendComma(ctx, b)
3806 }
3807 code = code.Next
3808 case encoder.OpStructFieldNumber:
3809 p := load(ctxptr, code.Idx)
3810 b = appendStructKey(ctx, code, b)
3811 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
3812 if err != nil {
3813 return nil, err
3814 }
3815 b = appendComma(ctx, bb)
3816 code = code.Next
3817 case encoder.OpStructFieldOmitEmptyNumber:
3818 p := load(ctxptr, code.Idx)
3819 v := ptrToNumber(p + uintptr(code.Offset))
3820 if v != "" {
3821 b = appendStructKey(ctx, code, b)
3822 bb, err := appendNumber(ctx, b, v)
3823 if err != nil {
3824 return nil, err
3825 }
3826 b = appendComma(ctx, bb)
3827 }
3828 code = code.Next
3829 case encoder.OpStructFieldNumberString:
3830 p := load(ctxptr, code.Idx)
3831 b = appendStructKey(ctx, code, b)
3832 b = append(b, '"')
3833 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
3834 if err != nil {
3835 return nil, err
3836 }
3837 b = append(bb, '"')
3838 b = appendComma(ctx, b)
3839 code = code.Next
3840 case encoder.OpStructFieldOmitEmptyNumberString:
3841 p := load(ctxptr, code.Idx)
3842 v := ptrToNumber(p + uintptr(code.Offset))
3843 if v != "" {
3844 b = appendStructKey(ctx, code, b)
3845 b = append(b, '"')
3846 bb, err := appendNumber(ctx, b, v)
3847 if err != nil {
3848 return nil, err
3849 }
3850 b = append(bb, '"')
3851 b = appendComma(ctx, b)
3852 }
3853 code = code.Next
3854 case encoder.OpStructFieldNumberPtr:
3855 p := load(ctxptr, code.Idx)
3856 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3857 b = appendStructKey(ctx, code, b)
3858 if p == 0 {
3859 b = appendNull(ctx, b)
3860 } else {
3861 bb, err := appendNumber(ctx, b, ptrToNumber(p))
3862 if err != nil {
3863 return nil, err
3864 }
3865 b = bb
3866 }
3867 b = appendComma(ctx, b)
3868 code = code.Next
3869 case encoder.OpStructFieldOmitEmptyNumberPtr:
3870 p := load(ctxptr, code.Idx)
3871 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3872 if p != 0 {
3873 b = appendStructKey(ctx, code, b)
3874 bb, err := appendNumber(ctx, b, ptrToNumber(p))
3875 if err != nil {
3876 return nil, err
3877 }
3878 b = appendComma(ctx, bb)
3879 }
3880 code = code.Next
3881 case encoder.OpStructFieldNumberPtrString:
3882 p := load(ctxptr, code.Idx)
3883 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3884 b = appendStructKey(ctx, code, b)
3885 if p == 0 {
3886 b = appendNull(ctx, b)
3887 } else {
3888 b = append(b, '"')
3889 bb, err := appendNumber(ctx, b, ptrToNumber(p))
3890 if err != nil {
3891 return nil, err
3892 }
3893 b = append(bb, '"')
3894 }
3895 b = appendComma(ctx, b)
3896 code = code.Next
3897 case encoder.OpStructFieldOmitEmptyNumberPtrString:
3898 p := load(ctxptr, code.Idx)
3899 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3900 if p != 0 {
3901 b = appendStructKey(ctx, code, b)
3902 b = append(b, '"')
3903 bb, err := appendNumber(ctx, b, ptrToNumber(p))
3904 if err != nil {
3905 return nil, err
3906 }
3907 b = append(bb, '"')
3908 b = appendComma(ctx, b)
3909 }
3910 code = code.Next
3911 case encoder.OpStructFieldMarshalJSON:
3912 p := load(ctxptr, code.Idx)
3913 b = appendStructKey(ctx, code, b)
3914 p += uintptr(code.Offset)
3915 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3916 p = ptrToPtr(p)
3917 }
3918 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
3919 b = appendNull(ctx, b)
3920 } else {
3921 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
3922 if err != nil {
3923 return nil, err
3924 }
3925 b = bb
3926 }
3927 b = appendComma(ctx, b)
3928 code = code.Next
3929 case encoder.OpStructFieldOmitEmptyMarshalJSON:
3930 p := load(ctxptr, code.Idx)
3931 p += uintptr(code.Offset)
3932 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3933 p = ptrToPtr(p)
3934 }
3935 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
3936 code = code.NextField
3937 break
3938 }
3939 iface := ptrToInterface(code, p)
3940 if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) {
3941 code = code.NextField
3942 break
3943 }
3944 b = appendStructKey(ctx, code, b)
3945 bb, err := appendMarshalJSON(ctx, code, b, iface)
3946 if err != nil {
3947 return nil, err
3948 }
3949 b = appendComma(ctx, bb)
3950 code = code.Next
3951 case encoder.OpStructFieldMarshalJSONPtr:
3952 p := load(ctxptr, code.Idx)
3953 b = appendStructKey(ctx, code, b)
3954 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3955 if p == 0 {
3956 b = appendNull(ctx, b)
3957 } else {
3958 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
3959 if err != nil {
3960 return nil, err
3961 }
3962 b = bb
3963 }
3964 b = appendComma(ctx, b)
3965 code = code.Next
3966 case encoder.OpStructFieldOmitEmptyMarshalJSONPtr:
3967 p := load(ctxptr, code.Idx)
3968 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
3969 if p != 0 {
3970 b = appendStructKey(ctx, code, b)
3971 bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
3972 if err != nil {
3973 return nil, err
3974 }
3975 b = appendComma(ctx, bb)
3976 }
3977 code = code.Next
3978 case encoder.OpStructFieldMarshalText:
3979 p := load(ctxptr, code.Idx)
3980 b = appendStructKey(ctx, code, b)
3981 p += uintptr(code.Offset)
3982 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
3983 p = ptrToPtr(p)
3984 }
3985 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
3986 b = appendNull(ctx, b)
3987 } else {
3988 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
3989 if err != nil {
3990 return nil, err
3991 }
3992 b = bb
3993 }
3994 b = appendComma(ctx, b)
3995 code = code.Next
3996 case encoder.OpStructFieldOmitEmptyMarshalText:
3997 p := load(ctxptr, code.Idx)
3998 p += uintptr(code.Offset)
3999 if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
4000 p = ptrToPtr(p)
4001 }
4002 if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
4003 code = code.NextField
4004 break
4005 }
4006 b = appendStructKey(ctx, code, b)
4007 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
4008 if err != nil {
4009 return nil, err
4010 }
4011 b = appendComma(ctx, bb)
4012 code = code.Next
4013 case encoder.OpStructFieldMarshalTextPtr:
4014 p := load(ctxptr, code.Idx)
4015 b = appendStructKey(ctx, code, b)
4016 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4017 if p == 0 {
4018 b = appendNull(ctx, b)
4019 } else {
4020 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
4021 if err != nil {
4022 return nil, err
4023 }
4024 b = bb
4025 }
4026 b = appendComma(ctx, b)
4027 code = code.Next
4028 case encoder.OpStructFieldOmitEmptyMarshalTextPtr:
4029 p := load(ctxptr, code.Idx)
4030 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4031 if p != 0 {
4032 b = appendStructKey(ctx, code, b)
4033 bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
4034 if err != nil {
4035 return nil, err
4036 }
4037 b = appendComma(ctx, bb)
4038 }
4039 code = code.Next
4040 case encoder.OpStructFieldArray:
4041 b = appendStructKey(ctx, code, b)
4042 p := load(ctxptr, code.Idx)
4043 p += uintptr(code.Offset)
4044 code = code.Next
4045 store(ctxptr, code.Idx, p)
4046 case encoder.OpStructFieldOmitEmptyArray:
4047 b = appendStructKey(ctx, code, b)
4048 p := load(ctxptr, code.Idx)
4049 p += uintptr(code.Offset)
4050 code = code.Next
4051 store(ctxptr, code.Idx, p)
4052 case encoder.OpStructFieldArrayPtr:
4053 b = appendStructKey(ctx, code, b)
4054 p := load(ctxptr, code.Idx)
4055 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4056 code = code.Next
4057 store(ctxptr, code.Idx, p)
4058 case encoder.OpStructFieldOmitEmptyArrayPtr:
4059 p := load(ctxptr, code.Idx)
4060 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4061 if p != 0 {
4062 b = appendStructKey(ctx, code, b)
4063 code = code.Next
4064 store(ctxptr, code.Idx, p)
4065 } else {
4066 code = code.NextField
4067 }
4068 case encoder.OpStructFieldSlice:
4069 b = appendStructKey(ctx, code, b)
4070 p := load(ctxptr, code.Idx)
4071 p += uintptr(code.Offset)
4072 code = code.Next
4073 store(ctxptr, code.Idx, p)
4074 case encoder.OpStructFieldOmitEmptySlice:
4075 p := load(ctxptr, code.Idx)
4076 p += uintptr(code.Offset)
4077 slice := ptrToSlice(p)
4078 if slice.Len == 0 {
4079 code = code.NextField
4080 } else {
4081 b = appendStructKey(ctx, code, b)
4082 code = code.Next
4083 store(ctxptr, code.Idx, p)
4084 }
4085 case encoder.OpStructFieldSlicePtr:
4086 b = appendStructKey(ctx, code, b)
4087 p := load(ctxptr, code.Idx)
4088 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4089 code = code.Next
4090 store(ctxptr, code.Idx, p)
4091 case encoder.OpStructFieldOmitEmptySlicePtr:
4092 p := load(ctxptr, code.Idx)
4093 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4094 if p != 0 {
4095 b = appendStructKey(ctx, code, b)
4096 code = code.Next
4097 store(ctxptr, code.Idx, p)
4098 } else {
4099 code = code.NextField
4100 }
4101 case encoder.OpStructFieldMap:
4102 b = appendStructKey(ctx, code, b)
4103 p := load(ctxptr, code.Idx)
4104 p = ptrToPtr(p + uintptr(code.Offset))
4105 code = code.Next
4106 store(ctxptr, code.Idx, p)
4107 case encoder.OpStructFieldOmitEmptyMap:
4108 p := load(ctxptr, code.Idx)
4109 p = ptrToPtr(p + uintptr(code.Offset))
4110 if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 {
4111 code = code.NextField
4112 } else {
4113 b = appendStructKey(ctx, code, b)
4114 code = code.Next
4115 store(ctxptr, code.Idx, p)
4116 }
4117 case encoder.OpStructFieldMapPtr:
4118 b = appendStructKey(ctx, code, b)
4119 p := load(ctxptr, code.Idx)
4120 p = ptrToPtr(p + uintptr(code.Offset))
4121 if p != 0 {
4122 p = ptrToNPtr(p, code.PtrNum)
4123 }
4124 code = code.Next
4125 store(ctxptr, code.Idx, p)
4126 case encoder.OpStructFieldOmitEmptyMapPtr:
4127 p := load(ctxptr, code.Idx)
4128 p = ptrToPtr(p + uintptr(code.Offset))
4129 if p != 0 {
4130 p = ptrToNPtr(p, code.PtrNum)
4131 }
4132 if p != 0 {
4133 b = appendStructKey(ctx, code, b)
4134 code = code.Next
4135 store(ctxptr, code.Idx, p)
4136 } else {
4137 code = code.NextField
4138 }
4139 case encoder.OpStructFieldStruct:
4140 b = appendStructKey(ctx, code, b)
4141 p := load(ctxptr, code.Idx)
4142 p += uintptr(code.Offset)
4143 code = code.Next
4144 store(ctxptr, code.Idx, p)
4145 case encoder.OpStructFieldOmitEmptyStruct:
4146 p := load(ctxptr, code.Idx)
4147 p += uintptr(code.Offset)
4148 if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 {
4149 code = code.NextField
4150 } else {
4151 b = appendStructKey(ctx, code, b)
4152 code = code.Next
4153 store(ctxptr, code.Idx, p)
4154 }
4155 case encoder.OpStructEnd:
4156 b = appendStructEndSkipLast(ctx, code, b)
4157 code = code.Next
4158 case encoder.OpStructEndInt:
4159 p := load(ctxptr, code.Idx)
4160 b = appendStructKey(ctx, code, b)
4161 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
4162 b = appendStructEnd(ctx, code, b)
4163 code = code.Next
4164 case encoder.OpStructEndOmitEmptyInt:
4165 p := load(ctxptr, code.Idx)
4166 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
4167 v := u64 & ((1 << code.NumBitSize) - 1)
4168 if v != 0 {
4169 b = appendStructKey(ctx, code, b)
4170 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
4171 b = appendStructEnd(ctx, code, b)
4172 } else {
4173 b = appendStructEndSkipLast(ctx, code, b)
4174 }
4175 code = code.Next
4176 case encoder.OpStructEndIntString:
4177 p := load(ctxptr, code.Idx)
4178 b = appendStructKey(ctx, code, b)
4179 b = append(b, '"')
4180 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
4181 b = append(b, '"')
4182 b = appendStructEnd(ctx, code, b)
4183 code = code.Next
4184 case encoder.OpStructEndOmitEmptyIntString:
4185 p := load(ctxptr, code.Idx)
4186 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
4187 v := u64 & ((1 << code.NumBitSize) - 1)
4188 if v != 0 {
4189 b = appendStructKey(ctx, code, b)
4190 b = append(b, '"')
4191 b = appendInt(ctx, b, p+uintptr(code.Offset), code)
4192 b = append(b, '"')
4193 b = appendStructEnd(ctx, code, b)
4194 } else {
4195 b = appendStructEndSkipLast(ctx, code, b)
4196 }
4197 code = code.Next
4198 case encoder.OpStructEndIntPtr:
4199 b = appendStructKey(ctx, code, b)
4200 p := load(ctxptr, code.Idx)
4201 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4202 if p == 0 {
4203 b = appendNull(ctx, b)
4204 } else {
4205 b = appendInt(ctx, b, p, code)
4206 }
4207 b = appendStructEnd(ctx, code, b)
4208 code = code.Next
4209 case encoder.OpStructEndOmitEmptyIntPtr:
4210 p := load(ctxptr, code.Idx)
4211 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4212 if p != 0 {
4213 b = appendStructKey(ctx, code, b)
4214 b = appendInt(ctx, b, p, code)
4215 b = appendStructEnd(ctx, code, b)
4216 } else {
4217 b = appendStructEndSkipLast(ctx, code, b)
4218 }
4219 code = code.Next
4220 case encoder.OpStructEndIntPtrString:
4221 b = appendStructKey(ctx, code, b)
4222 p := load(ctxptr, code.Idx)
4223 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4224 if p == 0 {
4225 b = appendNull(ctx, b)
4226 } else {
4227 b = append(b, '"')
4228 b = appendInt(ctx, b, p, code)
4229 b = append(b, '"')
4230 }
4231 b = appendStructEnd(ctx, code, b)
4232 code = code.Next
4233 case encoder.OpStructEndOmitEmptyIntPtrString:
4234 p := load(ctxptr, code.Idx)
4235 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4236 if p != 0 {
4237 b = appendStructKey(ctx, code, b)
4238 b = append(b, '"')
4239 b = appendInt(ctx, b, p, code)
4240 b = append(b, '"')
4241 b = appendStructEnd(ctx, code, b)
4242 } else {
4243 b = appendStructEndSkipLast(ctx, code, b)
4244 }
4245 code = code.Next
4246 case encoder.OpStructEndUint:
4247 p := load(ctxptr, code.Idx)
4248 b = appendStructKey(ctx, code, b)
4249 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
4250 b = appendStructEnd(ctx, code, b)
4251 code = code.Next
4252 case encoder.OpStructEndOmitEmptyUint:
4253 p := load(ctxptr, code.Idx)
4254 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
4255 v := u64 & ((1 << code.NumBitSize) - 1)
4256 if v != 0 {
4257 b = appendStructKey(ctx, code, b)
4258 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
4259 b = appendStructEnd(ctx, code, b)
4260 } else {
4261 b = appendStructEndSkipLast(ctx, code, b)
4262 }
4263 code = code.Next
4264 case encoder.OpStructEndUintString:
4265 p := load(ctxptr, code.Idx)
4266 b = appendStructKey(ctx, code, b)
4267 b = append(b, '"')
4268 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
4269 b = append(b, '"')
4270 b = appendStructEnd(ctx, code, b)
4271 code = code.Next
4272 case encoder.OpStructEndOmitEmptyUintString:
4273 p := load(ctxptr, code.Idx)
4274 u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
4275 v := u64 & ((1 << code.NumBitSize) - 1)
4276 if v != 0 {
4277 b = appendStructKey(ctx, code, b)
4278 b = append(b, '"')
4279 b = appendUint(ctx, b, p+uintptr(code.Offset), code)
4280 b = append(b, '"')
4281 b = appendStructEnd(ctx, code, b)
4282 } else {
4283 b = appendStructEndSkipLast(ctx, code, b)
4284 }
4285 code = code.Next
4286 case encoder.OpStructEndUintPtr:
4287 b = appendStructKey(ctx, code, b)
4288 p := load(ctxptr, code.Idx)
4289 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4290 if p == 0 {
4291 b = appendNull(ctx, b)
4292 } else {
4293 b = appendUint(ctx, b, p, code)
4294 }
4295 b = appendStructEnd(ctx, code, b)
4296 code = code.Next
4297 case encoder.OpStructEndOmitEmptyUintPtr:
4298 p := load(ctxptr, code.Idx)
4299 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4300 if p != 0 {
4301 b = appendStructKey(ctx, code, b)
4302 b = appendUint(ctx, b, p, code)
4303 b = appendStructEnd(ctx, code, b)
4304 } else {
4305 b = appendStructEndSkipLast(ctx, code, b)
4306 }
4307 code = code.Next
4308 case encoder.OpStructEndUintPtrString:
4309 b = appendStructKey(ctx, code, b)
4310 p := load(ctxptr, code.Idx)
4311 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4312 if p == 0 {
4313 b = appendNull(ctx, b)
4314 } else {
4315 b = append(b, '"')
4316 b = appendUint(ctx, b, p, code)
4317 b = append(b, '"')
4318 }
4319 b = appendStructEnd(ctx, code, b)
4320 code = code.Next
4321 case encoder.OpStructEndOmitEmptyUintPtrString:
4322 p := load(ctxptr, code.Idx)
4323 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4324 if p != 0 {
4325 b = appendStructKey(ctx, code, b)
4326 b = append(b, '"')
4327 b = appendUint(ctx, b, p, code)
4328 b = append(b, '"')
4329 b = appendStructEnd(ctx, code, b)
4330 } else {
4331 b = appendStructEndSkipLast(ctx, code, b)
4332 }
4333 code = code.Next
4334 case encoder.OpStructEndFloat32:
4335 p := load(ctxptr, code.Idx)
4336 b = appendStructKey(ctx, code, b)
4337 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
4338 b = appendStructEnd(ctx, code, b)
4339 code = code.Next
4340 case encoder.OpStructEndOmitEmptyFloat32:
4341 p := load(ctxptr, code.Idx)
4342 v := ptrToFloat32(p + uintptr(code.Offset))
4343 if v != 0 {
4344 b = appendStructKey(ctx, code, b)
4345 b = appendFloat32(ctx, b, v)
4346 b = appendStructEnd(ctx, code, b)
4347 } else {
4348 b = appendStructEndSkipLast(ctx, code, b)
4349 }
4350 code = code.Next
4351 case encoder.OpStructEndFloat32String:
4352 p := load(ctxptr, code.Idx)
4353 b = appendStructKey(ctx, code, b)
4354 b = append(b, '"')
4355 b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
4356 b = append(b, '"')
4357 b = appendStructEnd(ctx, code, b)
4358 code = code.Next
4359 case encoder.OpStructEndOmitEmptyFloat32String:
4360 p := load(ctxptr, code.Idx)
4361 v := ptrToFloat32(p + uintptr(code.Offset))
4362 if v != 0 {
4363 b = appendStructKey(ctx, code, b)
4364 b = append(b, '"')
4365 b = appendFloat32(ctx, b, v)
4366 b = append(b, '"')
4367 b = appendStructEnd(ctx, code, b)
4368 } else {
4369 b = appendStructEndSkipLast(ctx, code, b)
4370 }
4371 code = code.Next
4372 case encoder.OpStructEndFloat32Ptr:
4373 b = appendStructKey(ctx, code, b)
4374 p := load(ctxptr, code.Idx)
4375 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4376 if p == 0 {
4377 b = appendNull(ctx, b)
4378 } else {
4379 b = appendFloat32(ctx, b, ptrToFloat32(p))
4380 }
4381 b = appendStructEnd(ctx, code, b)
4382 code = code.Next
4383 case encoder.OpStructEndOmitEmptyFloat32Ptr:
4384 p := load(ctxptr, code.Idx)
4385 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4386 if p != 0 {
4387 b = appendStructKey(ctx, code, b)
4388 b = appendFloat32(ctx, b, ptrToFloat32(p))
4389 b = appendStructEnd(ctx, code, b)
4390 } else {
4391 b = appendStructEndSkipLast(ctx, code, b)
4392 }
4393 code = code.Next
4394 case encoder.OpStructEndFloat32PtrString:
4395 b = appendStructKey(ctx, code, b)
4396 p := load(ctxptr, code.Idx)
4397 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4398 if p == 0 {
4399 b = appendNull(ctx, b)
4400 } else {
4401 b = append(b, '"')
4402 b = appendFloat32(ctx, b, ptrToFloat32(p))
4403 b = append(b, '"')
4404 }
4405 b = appendStructEnd(ctx, code, b)
4406 code = code.Next
4407 case encoder.OpStructEndOmitEmptyFloat32PtrString:
4408 p := load(ctxptr, code.Idx)
4409 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4410 if p != 0 {
4411 b = appendStructKey(ctx, code, b)
4412 b = append(b, '"')
4413 b = appendFloat32(ctx, b, ptrToFloat32(p))
4414 b = append(b, '"')
4415 b = appendStructEnd(ctx, code, b)
4416 } else {
4417 b = appendStructEndSkipLast(ctx, code, b)
4418 }
4419 code = code.Next
4420 case encoder.OpStructEndFloat64:
4421 p := load(ctxptr, code.Idx)
4422 v := ptrToFloat64(p + uintptr(code.Offset))
4423 if math.IsInf(v, 0) || math.IsNaN(v) {
4424 return nil, errUnsupportedFloat(v)
4425 }
4426 b = appendStructKey(ctx, code, b)
4427 b = appendFloat64(ctx, b, v)
4428 b = appendStructEnd(ctx, code, b)
4429 code = code.Next
4430 case encoder.OpStructEndOmitEmptyFloat64:
4431 p := load(ctxptr, code.Idx)
4432 v := ptrToFloat64(p + uintptr(code.Offset))
4433 if v != 0 {
4434 if math.IsInf(v, 0) || math.IsNaN(v) {
4435 return nil, errUnsupportedFloat(v)
4436 }
4437 b = appendStructKey(ctx, code, b)
4438 b = appendFloat64(ctx, b, v)
4439 b = appendStructEnd(ctx, code, b)
4440 } else {
4441 b = appendStructEndSkipLast(ctx, code, b)
4442 }
4443 code = code.Next
4444 case encoder.OpStructEndFloat64String:
4445 p := load(ctxptr, code.Idx)
4446 v := ptrToFloat64(p + uintptr(code.Offset))
4447 if math.IsInf(v, 0) || math.IsNaN(v) {
4448 return nil, errUnsupportedFloat(v)
4449 }
4450 b = appendStructKey(ctx, code, b)
4451 b = append(b, '"')
4452 b = appendFloat64(ctx, b, v)
4453 b = append(b, '"')
4454 b = appendStructEnd(ctx, code, b)
4455 code = code.Next
4456 case encoder.OpStructEndOmitEmptyFloat64String:
4457 p := load(ctxptr, code.Idx)
4458 v := ptrToFloat64(p + uintptr(code.Offset))
4459 if v != 0 {
4460 if math.IsInf(v, 0) || math.IsNaN(v) {
4461 return nil, errUnsupportedFloat(v)
4462 }
4463 b = appendStructKey(ctx, code, b)
4464 b = append(b, '"')
4465 b = appendFloat64(ctx, b, v)
4466 b = append(b, '"')
4467 b = appendStructEnd(ctx, code, b)
4468 } else {
4469 b = appendStructEndSkipLast(ctx, code, b)
4470 }
4471 code = code.Next
4472 case encoder.OpStructEndFloat64Ptr:
4473 b = appendStructKey(ctx, code, b)
4474 p := load(ctxptr, code.Idx)
4475 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4476 if p == 0 {
4477 b = appendNull(ctx, b)
4478 b = appendStructEnd(ctx, code, b)
4479 code = code.Next
4480 break
4481 }
4482 v := ptrToFloat64(p)
4483 if math.IsInf(v, 0) || math.IsNaN(v) {
4484 return nil, errUnsupportedFloat(v)
4485 }
4486 b = appendFloat64(ctx, b, v)
4487 b = appendStructEnd(ctx, code, b)
4488 code = code.Next
4489 case encoder.OpStructEndOmitEmptyFloat64Ptr:
4490 p := load(ctxptr, code.Idx)
4491 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4492 if p != 0 {
4493 b = appendStructKey(ctx, code, b)
4494 v := ptrToFloat64(p)
4495 if math.IsInf(v, 0) || math.IsNaN(v) {
4496 return nil, errUnsupportedFloat(v)
4497 }
4498 b = appendFloat64(ctx, b, v)
4499 b = appendStructEnd(ctx, code, b)
4500 } else {
4501 b = appendStructEndSkipLast(ctx, code, b)
4502 }
4503 code = code.Next
4504 case encoder.OpStructEndFloat64PtrString:
4505 b = appendStructKey(ctx, code, b)
4506 p := load(ctxptr, code.Idx)
4507 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4508 if p == 0 {
4509 b = appendNull(ctx, b)
4510 } else {
4511 b = append(b, '"')
4512 v := ptrToFloat64(p)
4513 if math.IsInf(v, 0) || math.IsNaN(v) {
4514 return nil, errUnsupportedFloat(v)
4515 }
4516 b = appendFloat64(ctx, b, v)
4517 b = append(b, '"')
4518 }
4519 b = appendStructEnd(ctx, code, b)
4520 code = code.Next
4521 case encoder.OpStructEndOmitEmptyFloat64PtrString:
4522 p := load(ctxptr, code.Idx)
4523 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4524 if p != 0 {
4525 b = appendStructKey(ctx, code, b)
4526 v := ptrToFloat64(p)
4527 if math.IsInf(v, 0) || math.IsNaN(v) {
4528 return nil, errUnsupportedFloat(v)
4529 }
4530 b = append(b, '"')
4531 b = appendFloat64(ctx, b, v)
4532 b = append(b, '"')
4533 b = appendStructEnd(ctx, code, b)
4534 } else {
4535 b = appendStructEndSkipLast(ctx, code, b)
4536 }
4537 code = code.Next
4538 case encoder.OpStructEndString:
4539 p := load(ctxptr, code.Idx)
4540 b = appendStructKey(ctx, code, b)
4541 b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
4542 b = appendStructEnd(ctx, code, b)
4543 code = code.Next
4544 case encoder.OpStructEndOmitEmptyString:
4545 p := load(ctxptr, code.Idx)
4546 v := ptrToString(p + uintptr(code.Offset))
4547 if v != "" {
4548 b = appendStructKey(ctx, code, b)
4549 b = appendString(ctx, b, v)
4550 b = appendStructEnd(ctx, code, b)
4551 } else {
4552 b = appendStructEndSkipLast(ctx, code, b)
4553 }
4554 code = code.Next
4555 case encoder.OpStructEndStringString:
4556 p := load(ctxptr, code.Idx)
4557 b = appendStructKey(ctx, code, b)
4558 s := ptrToString(p + uintptr(code.Offset))
4559 b = appendString(ctx, b, string(appendString(ctx, []byte{}, s)))
4560 b = appendStructEnd(ctx, code, b)
4561 code = code.Next
4562 case encoder.OpStructEndOmitEmptyStringString:
4563 p := load(ctxptr, code.Idx)
4564 v := ptrToString(p + uintptr(code.Offset))
4565 if v != "" {
4566 b = appendStructKey(ctx, code, b)
4567 b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
4568 b = appendStructEnd(ctx, code, b)
4569 } else {
4570 b = appendStructEndSkipLast(ctx, code, b)
4571 }
4572 code = code.Next
4573 case encoder.OpStructEndStringPtr:
4574 b = appendStructKey(ctx, code, b)
4575 p := load(ctxptr, code.Idx)
4576 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4577 if p == 0 {
4578 b = appendNull(ctx, b)
4579 } else {
4580 b = appendString(ctx, b, ptrToString(p))
4581 }
4582 b = appendStructEnd(ctx, code, b)
4583 code = code.Next
4584 case encoder.OpStructEndOmitEmptyStringPtr:
4585 p := load(ctxptr, code.Idx)
4586 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4587 if p != 0 {
4588 b = appendStructKey(ctx, code, b)
4589 b = appendString(ctx, b, ptrToString(p))
4590 b = appendStructEnd(ctx, code, b)
4591 } else {
4592 b = appendStructEndSkipLast(ctx, code, b)
4593 }
4594 code = code.Next
4595 case encoder.OpStructEndStringPtrString:
4596 b = appendStructKey(ctx, code, b)
4597 p := load(ctxptr, code.Idx)
4598 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4599 if p == 0 {
4600 b = appendNull(ctx, b)
4601 } else {
4602 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
4603 }
4604 b = appendStructEnd(ctx, code, b)
4605 code = code.Next
4606 case encoder.OpStructEndOmitEmptyStringPtrString:
4607 p := load(ctxptr, code.Idx)
4608 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4609 if p != 0 {
4610 b = appendStructKey(ctx, code, b)
4611 b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
4612 b = appendStructEnd(ctx, code, b)
4613 } else {
4614 b = appendStructEndSkipLast(ctx, code, b)
4615 }
4616 code = code.Next
4617 case encoder.OpStructEndBool:
4618 p := load(ctxptr, code.Idx)
4619 b = appendStructKey(ctx, code, b)
4620 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
4621 b = appendStructEnd(ctx, code, b)
4622 code = code.Next
4623 case encoder.OpStructEndOmitEmptyBool:
4624 p := load(ctxptr, code.Idx)
4625 v := ptrToBool(p + uintptr(code.Offset))
4626 if v {
4627 b = appendStructKey(ctx, code, b)
4628 b = appendBool(ctx, b, v)
4629 b = appendStructEnd(ctx, code, b)
4630 } else {
4631 b = appendStructEndSkipLast(ctx, code, b)
4632 }
4633 code = code.Next
4634 case encoder.OpStructEndBoolString:
4635 p := load(ctxptr, code.Idx)
4636 b = appendStructKey(ctx, code, b)
4637 b = append(b, '"')
4638 b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
4639 b = append(b, '"')
4640 b = appendStructEnd(ctx, code, b)
4641 code = code.Next
4642 case encoder.OpStructEndOmitEmptyBoolString:
4643 p := load(ctxptr, code.Idx)
4644 v := ptrToBool(p + uintptr(code.Offset))
4645 if v {
4646 b = appendStructKey(ctx, code, b)
4647 b = append(b, '"')
4648 b = appendBool(ctx, b, v)
4649 b = append(b, '"')
4650 b = appendStructEnd(ctx, code, b)
4651 } else {
4652 b = appendStructEndSkipLast(ctx, code, b)
4653 }
4654 code = code.Next
4655 case encoder.OpStructEndBoolPtr:
4656 b = appendStructKey(ctx, code, b)
4657 p := load(ctxptr, code.Idx)
4658 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4659 if p == 0 {
4660 b = appendNull(ctx, b)
4661 } else {
4662 b = appendBool(ctx, b, ptrToBool(p))
4663 }
4664 b = appendStructEnd(ctx, code, b)
4665 code = code.Next
4666 case encoder.OpStructEndOmitEmptyBoolPtr:
4667 p := load(ctxptr, code.Idx)
4668 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4669 if p != 0 {
4670 b = appendStructKey(ctx, code, b)
4671 b = appendBool(ctx, b, ptrToBool(p))
4672 b = appendStructEnd(ctx, code, b)
4673 } else {
4674 b = appendStructEndSkipLast(ctx, code, b)
4675 }
4676 code = code.Next
4677 case encoder.OpStructEndBoolPtrString:
4678 b = appendStructKey(ctx, code, b)
4679 p := load(ctxptr, code.Idx)
4680 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4681 if p == 0 {
4682 b = appendNull(ctx, b)
4683 } else {
4684 b = append(b, '"')
4685 b = appendBool(ctx, b, ptrToBool(p))
4686 b = append(b, '"')
4687 }
4688 b = appendStructEnd(ctx, code, b)
4689 code = code.Next
4690 case encoder.OpStructEndOmitEmptyBoolPtrString:
4691 p := load(ctxptr, code.Idx)
4692 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4693 if p != 0 {
4694 b = appendStructKey(ctx, code, b)
4695 b = append(b, '"')
4696 b = appendBool(ctx, b, ptrToBool(p))
4697 b = append(b, '"')
4698 b = appendStructEnd(ctx, code, b)
4699 } else {
4700 b = appendStructEndSkipLast(ctx, code, b)
4701 }
4702 code = code.Next
4703 case encoder.OpStructEndBytes:
4704 p := load(ctxptr, code.Idx)
4705 b = appendStructKey(ctx, code, b)
4706 b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
4707 b = appendStructEnd(ctx, code, b)
4708 code = code.Next
4709 case encoder.OpStructEndOmitEmptyBytes:
4710 p := load(ctxptr, code.Idx)
4711 v := ptrToBytes(p + uintptr(code.Offset))
4712 if len(v) > 0 {
4713 b = appendStructKey(ctx, code, b)
4714 b = appendByteSlice(ctx, b, v)
4715 b = appendStructEnd(ctx, code, b)
4716 } else {
4717 b = appendStructEndSkipLast(ctx, code, b)
4718 }
4719 code = code.Next
4720 case encoder.OpStructEndBytesPtr:
4721 b = appendStructKey(ctx, code, b)
4722 p := load(ctxptr, code.Idx)
4723 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4724 if p == 0 {
4725 b = appendNull(ctx, b)
4726 } else {
4727 b = appendByteSlice(ctx, b, ptrToBytes(p))
4728 }
4729 b = appendStructEnd(ctx, code, b)
4730 code = code.Next
4731 case encoder.OpStructEndOmitEmptyBytesPtr:
4732 p := load(ctxptr, code.Idx)
4733 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4734 if p != 0 {
4735 b = appendStructKey(ctx, code, b)
4736 b = appendByteSlice(ctx, b, ptrToBytes(p))
4737 b = appendStructEnd(ctx, code, b)
4738 } else {
4739 b = appendStructEndSkipLast(ctx, code, b)
4740 }
4741 code = code.Next
4742 case encoder.OpStructEndNumber:
4743 p := load(ctxptr, code.Idx)
4744 b = appendStructKey(ctx, code, b)
4745 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
4746 if err != nil {
4747 return nil, err
4748 }
4749 b = appendStructEnd(ctx, code, bb)
4750 code = code.Next
4751 case encoder.OpStructEndOmitEmptyNumber:
4752 p := load(ctxptr, code.Idx)
4753 v := ptrToNumber(p + uintptr(code.Offset))
4754 if v != "" {
4755 b = appendStructKey(ctx, code, b)
4756 bb, err := appendNumber(ctx, b, v)
4757 if err != nil {
4758 return nil, err
4759 }
4760 b = appendStructEnd(ctx, code, bb)
4761 } else {
4762 b = appendStructEndSkipLast(ctx, code, b)
4763 }
4764 code = code.Next
4765 case encoder.OpStructEndNumberString:
4766 p := load(ctxptr, code.Idx)
4767 b = appendStructKey(ctx, code, b)
4768 b = append(b, '"')
4769 bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
4770 if err != nil {
4771 return nil, err
4772 }
4773 b = append(bb, '"')
4774 b = appendStructEnd(ctx, code, b)
4775 code = code.Next
4776 case encoder.OpStructEndOmitEmptyNumberString:
4777 p := load(ctxptr, code.Idx)
4778 v := ptrToNumber(p + uintptr(code.Offset))
4779 if v != "" {
4780 b = appendStructKey(ctx, code, b)
4781 b = append(b, '"')
4782 bb, err := appendNumber(ctx, b, v)
4783 if err != nil {
4784 return nil, err
4785 }
4786 b = append(bb, '"')
4787 b = appendStructEnd(ctx, code, b)
4788 } else {
4789 b = appendStructEndSkipLast(ctx, code, b)
4790 }
4791 code = code.Next
4792 case encoder.OpStructEndNumberPtr:
4793 b = appendStructKey(ctx, code, b)
4794 p := load(ctxptr, code.Idx)
4795 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4796 if p == 0 {
4797 b = appendNull(ctx, b)
4798 } else {
4799 bb, err := appendNumber(ctx, b, ptrToNumber(p))
4800 if err != nil {
4801 return nil, err
4802 }
4803 b = bb
4804 }
4805 b = appendStructEnd(ctx, code, b)
4806 code = code.Next
4807 case encoder.OpStructEndOmitEmptyNumberPtr:
4808 p := load(ctxptr, code.Idx)
4809 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4810 if p != 0 {
4811 b = appendStructKey(ctx, code, b)
4812 bb, err := appendNumber(ctx, b, ptrToNumber(p))
4813 if err != nil {
4814 return nil, err
4815 }
4816 b = appendStructEnd(ctx, code, bb)
4817 } else {
4818 b = appendStructEndSkipLast(ctx, code, b)
4819 }
4820 code = code.Next
4821 case encoder.OpStructEndNumberPtrString:
4822 b = appendStructKey(ctx, code, b)
4823 p := load(ctxptr, code.Idx)
4824 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4825 if p == 0 {
4826 b = appendNull(ctx, b)
4827 } else {
4828 b = append(b, '"')
4829 bb, err := appendNumber(ctx, b, ptrToNumber(p))
4830 if err != nil {
4831 return nil, err
4832 }
4833 b = append(bb, '"')
4834 }
4835 b = appendStructEnd(ctx, code, b)
4836 code = code.Next
4837 case encoder.OpStructEndOmitEmptyNumberPtrString:
4838 p := load(ctxptr, code.Idx)
4839 p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
4840 if p != 0 {
4841 b = appendStructKey(ctx, code, b)
4842 b = append(b, '"')
4843 bb, err := appendNumber(ctx, b, ptrToNumber(p))
4844 if err != nil {
4845 return nil, err
4846 }
4847 b = append(bb, '"')
4848 b = appendStructEnd(ctx, code, b)
4849 } else {
4850 b = appendStructEndSkipLast(ctx, code, b)
4851 }
4852 code = code.Next
4853 case encoder.OpEnd:
4854 goto END
4855 }
4856 }
4857 END:
4858 return b, nil
4859 }
4860
View as plain text