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