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