From 182b4eea73881c611a0f519576aa6ad2aa6799c2 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:26:58 +0100 Subject: [PATCH] Update dependencies (#333) --- go.mod | 67 +- go.sum | 246 +- testrig/storage.go | 4 +- vendor/codeberg.org/gruf/go-errors/data.go | 17 +- vendor/codeberg.org/gruf/go-errors/errors.go | 19 + vendor/codeberg.org/gruf/go-logger/clock.go | 2 +- vendor/codeberg.org/gruf/go-logger/default.go | 30 +- vendor/codeberg.org/gruf/go-logger/entry.go | 29 +- vendor/codeberg.org/gruf/go-logger/format.go | 656 +- .../gruf/go-logger/format_text.go | 915 + vendor/codeberg.org/gruf/go-logger/level.go | 10 +- vendor/codeberg.org/gruf/go-logger/logger.go | 2 +- vendor/codeberg.org/gruf/go-logger/writer.go | 29 + vendor/codeberg.org/gruf/go-mutexes/LICENSE | 662 +- vendor/codeberg.org/gruf/go-store/kv/store.go | 2 +- .../gruf/go-store/storage/block.go | 2 +- .../gruf/go-store/storage/disk.go | 2 +- .../gruf/go-store/storage/memory.go | 131 + .../gruf/go-store/storage/storage.go | 2 +- .../github.com/coreos/go-oidc/v3/oidc/jwks.go | 10 +- .../github.com/coreos/go-oidc/v3/oidc/oidc.go | 45 +- .../coreos/go-oidc/v3/oidc/verify.go | 14 - .../gin-contrib/sessions/.travis.yml | 44 - .../github.com/gin-contrib/sessions/README.md | 370 +- .../gin-contrib/sessions/sessions.go | 6 + vendor/github.com/gin-gonic/gin/.golangci.yml | 22 - vendor/github.com/gin-gonic/gin/.travis.yml | 48 + vendor/github.com/gin-gonic/gin/CHANGELOG.md | 30 + .../github.com/gin-gonic/gin/CONTRIBUTING.md | 2 +- vendor/github.com/gin-gonic/gin/Makefile | 10 +- vendor/github.com/gin-gonic/gin/README.md | 130 +- .../gin-gonic/gin/binding/binding.go | 4 +- .../gin/binding/binding_nomsgpack.go | 4 +- .../gin/binding/default_validator.go | 26 +- .../github.com/gin-gonic/gin/binding/form.go | 6 +- .../gin-gonic/gin/binding/form_mapping.go | 29 +- .../gin-gonic/gin/binding/header.go | 2 +- .../github.com/gin-gonic/gin/binding/json.go | 4 +- .../gin/binding/multipart_form_mapping.go | 14 +- .../gin-gonic/gin/binding/protobuf.go | 9 +- .../github.com/gin-gonic/gin/binding/uri.go | 2 +- vendor/github.com/gin-gonic/gin/context.go | 167 +- vendor/github.com/gin-gonic/gin/debug.go | 6 +- vendor/github.com/gin-gonic/gin/fs.go | 2 +- vendor/github.com/gin-gonic/gin/gin.go | 89 +- .../gin-gonic/gin/internal/json/go_json.go | 23 - .../gin-gonic/gin/internal/json/json.go | 4 +- vendor/github.com/gin-gonic/gin/logger.go | 3 +- vendor/github.com/gin-gonic/gin/mode.go | 6 +- vendor/github.com/gin-gonic/gin/recovery.go | 6 +- .../github.com/gin-gonic/gin/render/json.go | 28 +- .../gin-gonic/gin/render/msgpack.go | 2 - .../gin-gonic/gin/render/protobuf.go | 2 +- .../github.com/gin-gonic/gin/routergroup.go | 11 +- vendor/github.com/gin-gonic/gin/tree.go | 137 +- vendor/github.com/gin-gonic/gin/version.go | 2 +- .../github.com/go-errors/errors/.travis.yml | 1 + vendor/github.com/go-errors/errors/README.md | 1 + vendor/github.com/go-errors/errors/cover.out | 89 - vendor/github.com/goccy/go-json/.codecov.yml | 32 - vendor/github.com/goccy/go-json/.gitignore | 2 - vendor/github.com/goccy/go-json/.golangci.yml | 75 - vendor/github.com/goccy/go-json/CHANGELOG.md | 260 - vendor/github.com/goccy/go-json/LICENSE | 21 - vendor/github.com/goccy/go-json/Makefile | 39 - vendor/github.com/goccy/go-json/README.md | 529 - vendor/github.com/goccy/go-json/color.go | 68 - vendor/github.com/goccy/go-json/decode.go | 232 - .../goccy/go-json/docker-compose.yml | 13 - vendor/github.com/goccy/go-json/encode.go | 323 - vendor/github.com/goccy/go-json/error.go | 39 - .../internal/decoder/anonymous_field.go | 37 - .../goccy/go-json/internal/decoder/array.go | 169 - .../goccy/go-json/internal/decoder/bool.go | 78 - .../goccy/go-json/internal/decoder/bytes.go | 114 - .../goccy/go-json/internal/decoder/compile.go | 510 - .../internal/decoder/compile_norace.go | 28 - .../go-json/internal/decoder/compile_race.go | 36 - .../goccy/go-json/internal/decoder/context.go | 254 - .../goccy/go-json/internal/decoder/float.go | 158 - .../goccy/go-json/internal/decoder/func.go | 141 - .../goccy/go-json/internal/decoder/int.go | 242 - .../go-json/internal/decoder/interface.go | 458 - .../goccy/go-json/internal/decoder/map.go | 186 - .../goccy/go-json/internal/decoder/number.go | 112 - .../goccy/go-json/internal/decoder/option.go | 15 - .../goccy/go-json/internal/decoder/ptr.go | 87 - .../goccy/go-json/internal/decoder/slice.go | 301 - .../goccy/go-json/internal/decoder/stream.go | 554 - .../goccy/go-json/internal/decoder/string.go | 371 - .../goccy/go-json/internal/decoder/struct.go | 819 - .../goccy/go-json/internal/decoder/type.go | 29 - .../goccy/go-json/internal/decoder/uint.go | 190 - .../internal/decoder/unmarshal_json.go | 91 - .../internal/decoder/unmarshal_text.go | 280 - .../internal/decoder/wrapped_string.go | 68 - .../goccy/go-json/internal/encoder/compact.go | 286 - .../go-json/internal/encoder/compiler.go | 1570 - .../internal/encoder/compiler_norace.go | 56 - .../go-json/internal/encoder/compiler_race.go | 65 - .../goccy/go-json/internal/encoder/context.go | 141 - .../goccy/go-json/internal/encoder/encoder.go | 551 - .../goccy/go-json/internal/encoder/indent.go | 211 - .../goccy/go-json/internal/encoder/int.go | 130 - .../goccy/go-json/internal/encoder/map112.go | 8 - .../goccy/go-json/internal/encoder/map113.go | 8 - .../goccy/go-json/internal/encoder/opcode.go | 772 - .../goccy/go-json/internal/encoder/option.go | 41 - .../goccy/go-json/internal/encoder/optype.go | 934 - .../goccy/go-json/internal/encoder/string.go | 640 - .../go-json/internal/encoder/vm/debug_vm.go | 34 - .../goccy/go-json/internal/encoder/vm/hack.go | 9 - .../goccy/go-json/internal/encoder/vm/util.go | 191 - .../goccy/go-json/internal/encoder/vm/vm.go | 5056 - .../internal/encoder/vm_color/debug_vm.go | 34 - .../go-json/internal/encoder/vm_color/hack.go | 9 - .../go-json/internal/encoder/vm_color/util.go | 255 - .../go-json/internal/encoder/vm_color/vm.go | 5056 - .../encoder/vm_color_indent/debug_vm.go | 34 - .../internal/encoder/vm_color_indent/util.go | 276 - .../internal/encoder/vm_color_indent/vm.go | 5056 - .../internal/encoder/vm_indent/debug_vm.go | 34 - .../internal/encoder/vm_indent/hack.go | 9 - .../internal/encoder/vm_indent/util.go | 213 - .../go-json/internal/encoder/vm_indent/vm.go | 5056 - .../goccy/go-json/internal/errors/error.go | 164 - .../goccy/go-json/internal/runtime/rtype.go | 263 - .../go-json/internal/runtime/struct_field.go | 87 - .../goccy/go-json/internal/runtime/type.go | 100 - vendor/github.com/goccy/go-json/json.go | 366 - vendor/github.com/goccy/go-json/option.go | 46 - vendor/github.com/golang/snappy/AUTHORS | 1 + vendor/github.com/golang/snappy/CONTRIBUTORS | 2 + vendor/github.com/golang/snappy/decode.go | 83 +- .../github.com/golang/snappy/encode_arm64.s | 4 +- vendor/github.com/h2non/filetype/History.md | 15 + vendor/github.com/h2non/filetype/README.md | 2 + vendor/github.com/h2non/filetype/kind.go | 11 + .../h2non/filetype/matchers/archive.go | 193 +- .../h2non/filetype/matchers/audio.go | 10 + vendor/github.com/h2non/filetype/version.go | 2 +- vendor/github.com/jackc/pgconn/CHANGELOG.md | 7 + .../internal/ctxwatch/context_watcher.go | 13 +- vendor/github.com/jackc/pgconn/pgconn.go | 25 +- .../github.com/jackc/pgconn/stmtcache/lru.go | 8 + .../github.com/jackc/pgproto3/v2/backend.go | 12 +- .../jackc/pgproto3/v2/function_call.go | 94 + .../pgproto3/v2/sasl_initial_response.go | 2 +- .../jackc/pgproto3/v2/sasl_response.go | 2 +- vendor/github.com/jackc/pgtype/.travis.yml | 34 - vendor/github.com/jackc/pgtype/CHANGELOG.md | 14 + vendor/github.com/jackc/pgtype/array.go | 2 +- vendor/github.com/jackc/pgtype/bpchar.go | 21 +- vendor/github.com/jackc/pgtype/hstore.go | 25 +- vendor/github.com/jackc/pgtype/inet.go | 10 +- vendor/github.com/jackc/pgtype/numeric.go | 66 +- vendor/github.com/jackc/pgtype/pgtype.go | 6 +- vendor/github.com/jackc/pgtype/text.go | 30 + vendor/github.com/jackc/pgtype/timestamp.go | 6 +- vendor/github.com/jackc/pgtype/timestamptz.go | 6 +- vendor/github.com/jackc/pgx/v4/CHANGELOG.md | 12 + vendor/github.com/jackc/pgx/v4/README.md | 4 +- vendor/github.com/jackc/pgx/v4/batch.go | 30 + vendor/github.com/jackc/pgx/v4/conn.go | 22 +- vendor/github.com/jackc/pgx/v4/doc.go | 2 +- .../jackc/pgx/v4/extended_query_builder.go | 33 +- vendor/github.com/jackc/pgx/v4/tx.go | 8 +- vendor/github.com/json-iterator/go/README.md | 2 - .../mitchellh/mapstructure/CHANGELOG.md | 10 +- .../mitchellh/mapstructure/decode_hooks.go | 3 +- .../mitchellh/mapstructure/mapstructure.go | 13 +- .../github.com/modern-go/reflect2/.travis.yml | 2 +- .../github.com/modern-go/reflect2/Gopkg.lock | 8 +- .../github.com/modern-go/reflect2/Gopkg.toml | 4 - .../modern-go/reflect2/go_above_118.go | 23 + .../modern-go/reflect2/go_above_17.go | 8 - .../modern-go/reflect2/go_above_19.go | 3 + .../modern-go/reflect2/go_below_118.go | 21 + .../modern-go/reflect2/go_below_17.go | 9 - .../modern-go/reflect2/go_below_19.go | 14 - .../github.com/modern-go/reflect2/reflect2.go | 20 +- vendor/github.com/modern-go/reflect2/test.sh | 12 - .../github.com/modern-go/reflect2/type_map.go | 51 +- .../modern-go/reflect2/unsafe_link.go | 26 +- .../modern-go/reflect2/unsafe_map.go | 8 - .../github.com/tdewolff/minify/v2/README.md | 5 + .../tdewolff/minify/v2/html/table.go | 2 +- .../github.com/tdewolff/parse/v2/html/lex.go | 1 + vendor/github.com/uptrace/bun/CHANGELOG.md | 17 + vendor/github.com/uptrace/bun/README.md | 23 +- vendor/github.com/uptrace/bun/db.go | 7 + .../uptrace/bun/dialect/feature/feature.go | 4 +- .../uptrace/bun/dialect/pgdialect/dialect.go | 3 +- .../bun/dialect/sqlitedialect/dialect.go | 3 +- vendor/github.com/uptrace/bun/package.json | 2 +- vendor/github.com/uptrace/bun/query_insert.go | 13 +- .../uptrace/bun/query_table_create.go | 12 + vendor/github.com/uptrace/bun/query_update.go | 2 +- vendor/github.com/uptrace/bun/version.go | 2 +- .../vmihailenco/msgpack/v5/.golangci.yml | 18 - .../vmihailenco/msgpack/v5/CHANGELOG.md | 52 +- .../vmihailenco/msgpack/v5/Makefile | 3 +- .../vmihailenco/msgpack/v5/README.md | 9 +- .../msgpack/v5/commitlint.config.js | 1 + .../vmihailenco/msgpack/v5/decode.go | 3 + .../vmihailenco/msgpack/v5/encode_map.go | 7 +- .../vmihailenco/msgpack/v5/package.json | 4 + .../vmihailenco/msgpack/v5/version.go | 6 + vendor/golang.org/x/crypto/acme/acme.go | 2 +- vendor/golang.org/x/crypto/acme/rfc8555.go | 26 + .../{ => internal}/poly1305/bits_compat.go | 0 .../{ => internal}/poly1305/bits_go1.13.go | 0 .../{ => internal}/poly1305/mac_noasm.go | 0 .../{ => internal}/poly1305/poly1305.go | 2 +- .../{ => internal}/poly1305/sum_amd64.go | 0 .../{ => internal}/poly1305/sum_amd64.s | 0 .../{ => internal}/poly1305/sum_generic.go | 0 .../{ => internal}/poly1305/sum_ppc64le.go | 0 .../{ => internal}/poly1305/sum_ppc64le.s | 0 .../{ => internal}/poly1305/sum_s390x.go | 0 .../{ => internal}/poly1305/sum_s390x.s | 2 +- vendor/golang.org/x/crypto/ssh/certs.go | 24 +- vendor/golang.org/x/crypto/ssh/cipher.go | 2 +- vendor/golang.org/x/crypto/ssh/client.go | 15 +- vendor/golang.org/x/crypto/ssh/common.go | 30 +- vendor/golang.org/x/crypto/ssh/handshake.go | 29 +- vendor/golang.org/x/crypto/ssh/keys.go | 9 + vendor/golang.org/x/crypto/ssh/server.go | 2 +- vendor/golang.org/x/net/idna/go118.go | 14 + vendor/golang.org/x/net/idna/idna10.0.0.go | 6 +- vendor/golang.org/x/net/idna/idna9.0.0.go | 4 +- vendor/golang.org/x/net/idna/pre_go118.go | 12 + vendor/golang.org/x/net/idna/punycode.go | 36 +- vendor/golang.org/x/sys/cpu/cpu_x86.go | 7 +- vendor/golang.org/x/sys/cpu/cpu_x86.s | 24 - vendor/golang.org/x/sys/unix/README.md | 2 +- vendor/golang.org/x/sys/unix/mkall.sh | 2 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 3 +- .../golang.org/x/sys/unix/sockcmsg_linux.go | 49 + vendor/golang.org/x/sys/unix/syscall_aix.go | 22 +- vendor/golang.org/x/sys/unix/syscall_bsd.go | 24 +- .../golang.org/x/sys/unix/syscall_darwin.go | 21 +- vendor/golang.org/x/sys/unix/syscall_linux.go | 52 +- .../golang.org/x/sys/unix/syscall_solaris.go | 16 +- .../x/sys/unix/syscall_zos_s390x.go | 16 +- vendor/golang.org/x/sys/unix/zerrors_linux.go | 40 +- .../x/sys/unix/zerrors_linux_386.go | 3 +- .../x/sys/unix/zerrors_linux_amd64.go | 3 +- .../x/sys/unix/zerrors_linux_arm.go | 3 +- .../x/sys/unix/zerrors_linux_arm64.go | 3 +- .../x/sys/unix/zerrors_linux_mips.go | 3 +- .../x/sys/unix/zerrors_linux_mips64.go | 3 +- .../x/sys/unix/zerrors_linux_mips64le.go | 3 +- .../x/sys/unix/zerrors_linux_mipsle.go | 3 +- .../x/sys/unix/zerrors_linux_ppc.go | 3 +- .../x/sys/unix/zerrors_linux_ppc64.go | 3 +- .../x/sys/unix/zerrors_linux_ppc64le.go | 3 +- .../x/sys/unix/zerrors_linux_riscv64.go | 3 +- .../x/sys/unix/zerrors_linux_s390x.go | 3 +- .../x/sys/unix/zerrors_linux_sparc64.go | 3 +- .../golang.org/x/sys/unix/zsyscall_aix_ppc.go | 22 +- .../x/sys/unix/zsyscall_aix_ppc64.go | 20 +- .../x/sys/unix/zsyscall_aix_ppc64_gc.go | 20 +- .../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 18 +- .../golang.org/x/sys/unix/zsyscall_linux.go | 17 +- .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 2 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../x/sys/unix/ztypes_darwin_amd64.go | 6 +- .../x/sys/unix/ztypes_darwin_arm64.go | 6 +- vendor/golang.org/x/sys/unix/ztypes_linux.go | 18 +- .../golang.org/x/sys/unix/ztypes_linux_386.go | 2 +- .../x/sys/unix/ztypes_linux_amd64.go | 2 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 2 +- .../x/sys/unix/ztypes_linux_arm64.go | 2 +- .../x/sys/unix/ztypes_linux_mips.go | 2 +- .../x/sys/unix/ztypes_linux_mips64.go | 2 +- .../x/sys/unix/ztypes_linux_mips64le.go | 2 +- .../x/sys/unix/ztypes_linux_mipsle.go | 2 +- .../golang.org/x/sys/unix/ztypes_linux_ppc.go | 2 +- .../x/sys/unix/ztypes_linux_ppc64.go | 2 +- .../x/sys/unix/ztypes_linux_ppc64le.go | 2 +- .../x/sys/unix/ztypes_linux_riscv64.go | 2 +- .../x/sys/unix/ztypes_linux_s390x.go | 2 +- .../x/sys/unix/ztypes_linux_sparc64.go | 2 +- .../x/sys/unix/ztypes_openbsd_386.go | 11 +- .../x/sys/unix/ztypes_openbsd_amd64.go | 11 +- .../x/sys/unix/ztypes_openbsd_arm.go | 11 +- .../x/sys/unix/ztypes_openbsd_arm64.go | 11 +- .../x/sys/unix/ztypes_openbsd_mips64.go | 11 +- vendor/golang.org/x/sys/windows/aliases.go | 4 +- vendor/golang.org/x/sys/windows/eventlog.go | 1 + vendor/golang.org/x/sys/windows/mksyscall.go | 3 +- vendor/golang.org/x/sys/windows/race.go | 1 + vendor/golang.org/x/sys/windows/race0.go | 1 + vendor/golang.org/x/sys/windows/service.go | 14 +- .../x/sys/windows/setupapi_windows.go | 1425 + .../x/sys/windows/setupapierrors_windows.go | 100 - vendor/golang.org/x/sys/windows/str.go | 1 + vendor/golang.org/x/sys/windows/syscall.go | 1 + .../x/sys/windows/syscall_windows.go | 27 +- .../golang.org/x/sys/windows/types_windows.go | 337 +- .../x/sys/windows/zsyscall_windows.go | 415 + .../x/tools/go/internal/gcimporter/bexport.go | 20 +- .../x/tools/go/internal/gcimporter/bimport.go | 1 + .../x/tools/go/internal/gcimporter/iexport.go | 198 +- .../x/tools/go/internal/gcimporter/iimport.go | 211 +- .../go/internal/gcimporter/support_go117.go | 16 + .../go/internal/gcimporter/support_go118.go | 20 + .../x/tools/internal/typeparams/common.go | 25 + .../internal/typeparams/enabled_go117.go | 12 + .../internal/typeparams/enabled_go118.go | 15 + .../internal/typeparams/typeparams_go117.go | 177 + .../internal/typeparams/typeparams_go118.go | 165 + .../x/tools/internal/typesinternal/types.go | 9 +- vendor/modernc.org/cc/v3/Makefile | 4 +- vendor/modernc.org/cc/v3/abi.go | 17 +- vendor/modernc.org/cc/v3/abi_platforms.go | 101 +- vendor/modernc.org/cc/v3/ast.go | 2 + vendor/modernc.org/cc/v3/ast2.go | 39 +- vendor/modernc.org/cc/v3/cc.go | 16 +- vendor/modernc.org/cc/v3/check.go | 567 +- vendor/modernc.org/cc/v3/cpp.go | 30 +- vendor/modernc.org/cc/v3/lexer.go | 8 +- vendor/modernc.org/cc/v3/lexer.l | 2 +- vendor/modernc.org/cc/v3/parser.yy | 4 +- vendor/modernc.org/cc/v3/scanner.go | 4 - vendor/modernc.org/cc/v3/type.go | 35 +- vendor/modernc.org/ccgo/v3/lib/Makefile | 18 +- vendor/modernc.org/ccgo/v3/lib/ccgo.go | 369 +- vendor/modernc.org/ccgo/v3/lib/dmesg.go | 1 + vendor/modernc.org/ccgo/v3/lib/go.go | 575 +- vendor/modernc.org/ccgo/v3/lib/init.go | 221 +- vendor/modernc.org/ccgo/v3/lib/mem.go | 1 + vendor/modernc.org/ccgo/v3/lib/nodmesg.go | 1 + vendor/modernc.org/ccgo/v3/lib/util.go | 22 +- vendor/modernc.org/libc/Makefile | 50 +- vendor/modernc.org/libc/capi_darwin_amd64.go | 897 +- vendor/modernc.org/libc/capi_darwin_arm64.go | 58 +- vendor/modernc.org/libc/capi_freebsd_amd64.go | 879 +- vendor/modernc.org/libc/capi_linux_386.go | 55 + vendor/modernc.org/libc/capi_linux_amd64.go | 28 + vendor/modernc.org/libc/capi_linux_arm.go | 55 + vendor/modernc.org/libc/capi_linux_arm64.go | 55 + vendor/modernc.org/libc/capi_linux_s390x.go | 52 + vendor/modernc.org/libc/capi_netbsd_amd64.go | 475 + vendor/modernc.org/libc/capi_windows_386.go | 34 +- vendor/modernc.org/libc/capi_windows_amd64.go | 34 +- vendor/modernc.org/libc/ccgo.go | 128 +- .../libc/errno/capi_darwin_amd64.go | 2 +- .../libc/errno/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/errno/capi_linux_386.go | 2 +- .../libc/errno/capi_linux_amd64.go | 2 +- .../modernc.org/libc/errno/capi_linux_arm.go | 2 +- .../libc/errno/capi_linux_arm64.go | 2 +- .../libc/errno/capi_linux_s390x.go | 2 +- .../libc/errno/capi_netbsd_amd64.go | 5 + .../libc/errno/capi_windows_386.go | 2 +- .../libc/errno/capi_windows_amd64.go | 2 +- .../libc/errno/errno_darwin_amd64.go | 2 +- .../libc/errno/errno_darwin_arm64.go | 2 +- .../modernc.org/libc/errno/errno_linux_386.go | 3 +- .../libc/errno/errno_linux_amd64.go | 2 +- .../modernc.org/libc/errno/errno_linux_arm.go | 4 +- .../libc/errno/errno_linux_arm64.go | 4 +- .../libc/errno/errno_linux_s390x.go | 4 +- .../libc/errno/errno_netbsd_amd64.go | 144 + .../libc/errno/errno_windows_386.go | 60 +- .../libc/errno/errno_windows_amd64.go | 3 +- .../libc/fcntl/capi_darwin_amd64.go | 2 +- .../libc/fcntl/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/fcntl/capi_linux_386.go | 2 +- .../libc/fcntl/capi_linux_amd64.go | 2 +- .../modernc.org/libc/fcntl/capi_linux_arm.go | 2 +- .../libc/fcntl/capi_linux_arm64.go | 2 +- .../libc/fcntl/capi_linux_s390x.go | 2 +- .../libc/fcntl/capi_netbsd_amd64.go | 5 + .../libc/fcntl/capi_windows_386.go | 2 +- .../libc/fcntl/capi_windows_amd64.go | 2 +- .../libc/fcntl/fcntl_darwin_amd64.go | 14 +- .../libc/fcntl/fcntl_darwin_arm64.go | 12 +- .../libc/fcntl/fcntl_freebsd_amd64.go | 18 +- .../modernc.org/libc/fcntl/fcntl_linux_386.go | 386 +- .../libc/fcntl/fcntl_linux_amd64.go | 297 +- .../modernc.org/libc/fcntl/fcntl_linux_arm.go | 356 +- .../libc/fcntl/fcntl_linux_arm64.go | 611 +- .../libc/fcntl/fcntl_linux_s390x.go | 374 +- .../libc/fcntl/fcntl_netbsd_amd64.go | 1481 + .../libc/fcntl/fcntl_windows_386.go | 74 +- .../libc/fcntl/fcntl_windows_amd64.go | 17 +- .../modernc.org/libc/fts/capi_darwin_amd64.go | 2 +- .../modernc.org/libc/fts/capi_darwin_arm64.go | 2 +- vendor/modernc.org/libc/fts/capi_linux_386.go | 2 +- .../modernc.org/libc/fts/capi_linux_amd64.go | 2 +- vendor/modernc.org/libc/fts/capi_linux_arm.go | 2 +- .../modernc.org/libc/fts/capi_linux_arm64.go | 2 +- .../modernc.org/libc/fts/capi_linux_s390x.go | 2 +- .../modernc.org/libc/fts/capi_netbsd_amd64.go | 5 + .../modernc.org/libc/fts/fts_darwin_amd64.go | 4491 +- .../modernc.org/libc/fts/fts_darwin_arm64.go | 5248 +- .../modernc.org/libc/fts/fts_freebsd_amd64.go | 1847 +- vendor/modernc.org/libc/fts/fts_linux_386.go | 991 +- .../modernc.org/libc/fts/fts_linux_amd64.go | 983 +- vendor/modernc.org/libc/fts/fts_linux_arm.go | 1090 +- .../modernc.org/libc/fts/fts_linux_arm64.go | 1085 +- .../modernc.org/libc/fts/fts_linux_s390x.go | 1000 +- .../modernc.org/libc/fts/fts_netbsd_amd64.go | 2626 + .../modernc.org/libc/grp/capi_darwin_amd64.go | 2 +- .../modernc.org/libc/grp/capi_darwin_arm64.go | 2 +- vendor/modernc.org/libc/grp/capi_linux_386.go | 2 +- .../modernc.org/libc/grp/capi_linux_amd64.go | 2 +- vendor/modernc.org/libc/grp/capi_linux_arm.go | 2 +- .../modernc.org/libc/grp/capi_linux_arm64.go | 2 +- .../modernc.org/libc/grp/capi_linux_s390x.go | 2 +- .../modernc.org/libc/grp/capi_netbsd_amd64.go | 5 + .../modernc.org/libc/grp/grp_darwin_amd64.go | 18 +- .../modernc.org/libc/grp/grp_darwin_arm64.go | 14 +- .../modernc.org/libc/grp/grp_freebsd_amd64.go | 14 +- vendor/modernc.org/libc/grp/grp_linux_386.go | 236 +- .../modernc.org/libc/grp/grp_linux_amd64.go | 241 +- vendor/modernc.org/libc/grp/grp_linux_arm.go | 262 +- .../modernc.org/libc/grp/grp_linux_arm64.go | 274 +- .../modernc.org/libc/grp/grp_linux_s390x.go | 246 +- .../modernc.org/libc/grp/grp_netbsd_amd64.go | 1596 + vendor/modernc.org/libc/ioutil_linux.go | 5 +- vendor/modernc.org/libc/ioutil_netbsd.go | 65 + .../libc/langinfo/capi_darwin_amd64.go | 2 +- .../libc/langinfo/capi_darwin_arm64.go | 2 +- .../libc/langinfo/capi_linux_386.go | 2 +- .../libc/langinfo/capi_linux_amd64.go | 2 +- .../libc/langinfo/capi_linux_arm.go | 2 +- .../libc/langinfo/capi_linux_arm64.go | 2 +- .../libc/langinfo/capi_linux_s390x.go | 2 +- .../libc/langinfo/capi_netbsd_amd64.go | 5 + .../libc/langinfo/langinfo_darwin_amd64.go | 6 +- .../libc/langinfo/langinfo_darwin_arm64.go | 2 +- .../libc/langinfo/langinfo_freebsd_amd64.go | 4 +- .../libc/langinfo/langinfo_linux_386.go | 61 +- .../libc/langinfo/langinfo_linux_amd64.go | 60 +- .../libc/langinfo/langinfo_linux_arm.go | 66 +- .../libc/langinfo/langinfo_linux_arm64.go | 70 +- .../libc/langinfo/langinfo_linux_s390x.go | 62 +- .../libc/langinfo/langinfo_netbsd_amd64.go | 189 + vendor/modernc.org/libc/libc.go | 266 +- vendor/modernc.org/libc/libc_darwin.go | 147 +- vendor/modernc.org/libc/libc_freebsd.go | 140 +- vendor/modernc.org/libc/libc_linux.go | 239 +- vendor/modernc.org/libc/libc_linux_amd64.go | 20 +- vendor/modernc.org/libc/libc_linux_s390x.go | 24 +- vendor/modernc.org/libc/libc_netbsd.go | 2158 + vendor/modernc.org/libc/libc_netbsd_amd64.go | 577 + vendor/modernc.org/libc/libc_unix.go | 48 +- vendor/modernc.org/libc/libc_windows.go | 462 +- .../libc/limits/capi_darwin_amd64.go | 2 +- .../libc/limits/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/limits/capi_linux_386.go | 2 +- .../libc/limits/capi_linux_amd64.go | 2 +- .../modernc.org/libc/limits/capi_linux_arm.go | 2 +- .../libc/limits/capi_linux_arm64.go | 2 +- .../libc/limits/capi_linux_s390x.go | 2 +- .../libc/limits/capi_netbsd_amd64.go | 5 + .../libc/limits/capi_windows_386.go | 2 +- .../libc/limits/capi_windows_amd64.go | 2 +- .../libc/limits/limits_darwin_amd64.go | 6 +- .../libc/limits/limits_darwin_arm64.go | 6 +- .../libc/limits/limits_linux_386.go | 73 +- .../libc/limits/limits_linux_amd64.go | 72 +- .../libc/limits/limits_linux_arm.go | 82 +- .../libc/limits/limits_linux_arm64.go | 86 +- .../libc/limits/limits_linux_s390x.go | 74 +- .../libc/limits/limits_netbsd_amd64.go | 460 + .../libc/limits/limits_windows_386.go | 64 +- .../libc/limits/limits_windows_amd64.go | 3 +- vendor/modernc.org/libc/log-generate | 27 - vendor/modernc.org/libc/musl_darwin_amd64.go | 77 +- vendor/modernc.org/libc/musl_darwin_arm64.go | 64 +- vendor/modernc.org/libc/musl_freebsd_amd64.go | 41 +- vendor/modernc.org/libc/musl_linux_386.go | 249 +- vendor/modernc.org/libc/musl_linux_amd64.go | 240 +- vendor/modernc.org/libc/musl_linux_arm.go | 519 +- vendor/modernc.org/libc/musl_linux_arm64.go | 517 +- vendor/modernc.org/libc/musl_linux_s390x.go | 523 +- vendor/modernc.org/libc/musl_netbsd_amd64.go | 4324 + vendor/modernc.org/libc/musl_windows_386.go | 29 +- vendor/modernc.org/libc/musl_windows_amd64.go | 30 +- .../libc/netdb/capi_darwin_amd64.go | 2 +- .../libc/netdb/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/netdb/capi_linux_386.go | 2 +- .../libc/netdb/capi_linux_amd64.go | 2 +- .../modernc.org/libc/netdb/capi_linux_arm.go | 2 +- .../libc/netdb/capi_linux_arm64.go | 2 +- .../libc/netdb/capi_linux_s390x.go | 2 +- .../libc/netdb/capi_netbsd_amd64.go | 5 + .../libc/netdb/netdb_darwin_amd64.go | 80 +- .../libc/netdb/netdb_darwin_arm64.go | 58 +- .../libc/netdb/netdb_freebsd_amd64.go | 24 +- .../modernc.org/libc/netdb/netdb_linux_386.go | 905 +- .../libc/netdb/netdb_linux_amd64.go | 929 +- .../modernc.org/libc/netdb/netdb_linux_arm.go | 1023 +- .../libc/netdb/netdb_linux_arm64.go | 1007 +- .../libc/netdb/netdb_linux_s390x.go | 957 +- .../libc/netdb/netdb_netbsd_amd64.go | 1018 + .../libc/netinet/in/capi_darwin_amd64.go | 2 +- .../libc/netinet/in/capi_darwin_arm64.go | 2 +- .../libc/netinet/in/capi_linux_386.go | 2 +- .../libc/netinet/in/capi_linux_amd64.go | 2 +- .../libc/netinet/in/capi_linux_arm.go | 2 +- .../libc/netinet/in/capi_linux_arm64.go | 2 +- .../libc/netinet/in/capi_linux_s390x.go | 2 +- .../libc/netinet/in/capi_netbsd_amd64.go | 5 + .../libc/netinet/in/in_darwin_amd64.go | 52 +- .../libc/netinet/in/in_darwin_arm64.go | 30 +- .../libc/netinet/in/in_freebsd_amd64.go | 36 +- .../libc/netinet/in/in_linux_386.go | 869 +- .../libc/netinet/in/in_linux_amd64.go | 865 +- .../libc/netinet/in/in_linux_arm.go | 987 +- .../libc/netinet/in/in_linux_arm64.go | 943 +- .../libc/netinet/in/in_linux_s390x.go | 893 +- .../libc/netinet/in/in_netbsd_amd64.go | 2950 + vendor/modernc.org/libc/nopthreads.go | 34 - .../libc/poll/capi_darwin_amd64.go | 2 +- .../libc/poll/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/poll/capi_linux_386.go | 2 +- .../modernc.org/libc/poll/capi_linux_amd64.go | 2 +- .../modernc.org/libc/poll/capi_linux_arm.go | 2 +- .../modernc.org/libc/poll/capi_linux_arm64.go | 2 +- .../modernc.org/libc/poll/capi_linux_s390x.go | 2 +- .../libc/poll/capi_netbsd_amd64.go | 5 + .../libc/poll/poll_darwin_amd64.go | 2 +- .../libc/poll/poll_darwin_arm64.go | 2 +- .../libc/poll/poll_freebsd_amd64.go | 4 +- .../modernc.org/libc/poll/poll_linux_386.go | 49 +- .../modernc.org/libc/poll/poll_linux_amd64.go | 48 +- .../modernc.org/libc/poll/poll_linux_arm.go | 54 +- .../modernc.org/libc/poll/poll_linux_arm64.go | 58 +- .../modernc.org/libc/poll/poll_linux_s390x.go | 50 +- .../libc/poll/poll_netbsd_amd64.go | 351 + vendor/modernc.org/libc/printf.go | 6 +- .../libc/{pthreads.go => pthread.go} | 43 +- .../libc/pthread/capi_darwin_amd64.go | 2 +- .../libc/pthread/capi_darwin_arm64.go | 2 +- .../libc/pthread/capi_linux_386.go | 2 +- .../libc/pthread/capi_linux_amd64.go | 2 +- .../libc/pthread/capi_linux_arm.go | 2 +- .../libc/pthread/capi_linux_arm64.go | 2 +- .../libc/pthread/capi_linux_s390x.go | 2 +- .../libc/pthread/capi_netbsd_amd64.go | 5 + .../libc/pthread/capi_windows_386.go | 2 +- .../libc/pthread/capi_windows_amd64.go | 2 +- .../libc/pthread/pthread_darwin_amd64.go | 30 +- .../libc/pthread/pthread_darwin_arm64.go | 28 +- .../libc/pthread/pthread_freebsd_amd64.go | 34 +- .../libc/pthread/pthread_linux_386.go | 1094 +- .../libc/pthread/pthread_linux_amd64.go | 1126 +- .../libc/pthread/pthread_linux_arm.go | 1209 +- .../libc/pthread/pthread_linux_arm64.go | 1221 +- .../libc/pthread/pthread_linux_s390x.go | 1137 +- .../libc/pthread/pthread_netbsd_amd64.go | 2741 + .../libc/pthread/pthread_windows_386.go | 139 +- .../libc/pthread/pthread_windows_amd64.go | 67 +- vendor/modernc.org/libc/pthread_all.go | 44 + .../modernc.org/libc/pwd/capi_darwin_amd64.go | 2 +- .../modernc.org/libc/pwd/capi_darwin_arm64.go | 2 +- vendor/modernc.org/libc/pwd/capi_linux_386.go | 2 +- .../modernc.org/libc/pwd/capi_linux_amd64.go | 2 +- vendor/modernc.org/libc/pwd/capi_linux_arm.go | 2 +- .../modernc.org/libc/pwd/capi_linux_arm64.go | 2 +- .../modernc.org/libc/pwd/capi_linux_s390x.go | 2 +- .../modernc.org/libc/pwd/capi_netbsd_amd64.go | 5 + .../modernc.org/libc/pwd/pwd_darwin_amd64.go | 8 +- .../modernc.org/libc/pwd/pwd_darwin_arm64.go | 4 +- .../modernc.org/libc/pwd/pwd_freebsd_amd64.go | 28 +- vendor/modernc.org/libc/pwd/pwd_linux_386.go | 236 +- .../modernc.org/libc/pwd/pwd_linux_amd64.go | 231 +- vendor/modernc.org/libc/pwd/pwd_linux_arm.go | 262 +- .../modernc.org/libc/pwd/pwd_linux_arm64.go | 264 +- .../modernc.org/libc/pwd/pwd_linux_s390x.go | 236 +- .../modernc.org/libc/pwd/pwd_netbsd_amd64.go | 1622 + .../libc/signal/capi_darwin_amd64.go | 2 +- .../libc/signal/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/signal/capi_linux_386.go | 2 +- .../libc/signal/capi_linux_amd64.go | 2 +- .../modernc.org/libc/signal/capi_linux_arm.go | 2 +- .../libc/signal/capi_linux_arm64.go | 2 +- .../libc/signal/capi_linux_s390x.go | 2 +- .../libc/signal/capi_netbsd_amd64.go | 5 + .../libc/signal/capi_windows_386.go | 2 +- .../libc/signal/capi_windows_amd64.go | 2 +- .../libc/signal/more_netbsd_amd64.go | 12 + .../libc/signal/signal_darwin_amd64.go | 186 +- .../libc/signal/signal_darwin_arm64.go | 27 +- .../libc/signal/signal_freebsd_amd64.go | 70 +- .../libc/signal/signal_linux_386.go | 748 +- .../libc/signal/signal_linux_amd64.go | 770 +- .../libc/signal/signal_linux_arm.go | 889 +- .../libc/signal/signal_linux_arm64.go | 1159 +- .../libc/signal/signal_linux_s390x.go | 816 +- .../libc/signal/signal_netbsd_amd64.go | 2889 + .../libc/signal/signal_windows_386.go | 60 +- .../libc/signal/signal_windows_amd64.go | 3 +- .../libc/stdio/capi_darwin_amd64.go | 2 +- .../libc/stdio/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/stdio/capi_linux_386.go | 2 +- .../libc/stdio/capi_linux_amd64.go | 2 +- .../modernc.org/libc/stdio/capi_linux_arm.go | 2 +- .../libc/stdio/capi_linux_arm64.go | 2 +- .../libc/stdio/capi_linux_s390x.go | 2 +- .../libc/stdio/capi_netbsd_amd64.go | 5 + .../libc/stdio/capi_windows_386.go | 2 +- .../libc/stdio/capi_windows_amd64.go | 2 +- .../libc/stdio/stdio_darwin_amd64.go | 68 +- .../libc/stdio/stdio_darwin_arm64.go | 66 +- .../libc/stdio/stdio_freebsd_amd64.go | 62 +- .../modernc.org/libc/stdio/stdio_linux_386.go | 276 +- .../libc/stdio/stdio_linux_amd64.go | 279 +- .../modernc.org/libc/stdio/stdio_linux_arm.go | 304 +- .../libc/stdio/stdio_linux_arm64.go | 308 +- .../libc/stdio/stdio_linux_s390x.go | 288 +- .../libc/stdio/stdio_netbsd_amd64.go | 466 + .../libc/stdio/stdio_windows_386.go | 349 +- .../libc/stdio/stdio_windows_amd64.go | 352 +- .../libc/stdlib/capi_darwin_amd64.go | 5 + .../libc/stdlib/capi_darwin_arm64.go | 5 + .../libc/stdlib/capi_freebsd_amd64.go | 5 + .../modernc.org/libc/stdlib/capi_linux_386.go | 5 + .../libc/stdlib/capi_linux_amd64.go | 5 + .../modernc.org/libc/stdlib/capi_linux_arm.go | 5 + .../libc/stdlib/capi_linux_arm64.go | 5 + .../libc/stdlib/capi_linux_s390x.go | 5 + .../libc/stdlib/capi_netbsd_amd64.go | 5 + .../libc/stdlib/capi_windows_386.go | 5 + .../libc/stdlib/capi_windows_amd64.go | 5 + .../libc/stdlib/stdlib_darwin_amd64.go | 6537 + .../libc/stdlib/stdlib_darwin_arm64.go | 4947 + .../libc/stdlib/stdlib_freebsd_amd64.go | 668 + .../libc/stdlib/stdlib_linux_386.go | 1513 + .../libc/stdlib/stdlib_linux_amd64.go | 1531 + .../libc/stdlib/stdlib_linux_arm.go | 1573 + .../libc/stdlib/stdlib_linux_arm64.go | 1607 + .../libc/stdlib/stdlib_linux_s390x.go | 1532 + .../libc/stdlib/stdlib_netbsd_amd64.go | 1620 + .../libc/stdlib/stdlib_windows_386.go | 547 + .../libc/stdlib/stdlib_windows_amd64.go | 548 + .../libc/{sync_linux_amd64.go => sync.go} | 11 +- vendor/modernc.org/libc/sync_linux_amd64.s | 9 - .../libc/sys/socket/capi_darwin_amd64.go | 2 +- .../libc/sys/socket/capi_darwin_arm64.go | 2 +- .../libc/sys/socket/capi_linux_386.go | 2 +- .../libc/sys/socket/capi_linux_amd64.go | 2 +- .../libc/sys/socket/capi_linux_arm.go | 2 +- .../libc/sys/socket/capi_linux_arm64.go | 2 +- .../libc/sys/socket/capi_linux_s390x.go | 2 +- .../libc/sys/socket/capi_netbsd_amd64.go | 5 + .../libc/sys/socket/socket_darwin_amd64.go | 28 +- .../libc/sys/socket/socket_darwin_arm64.go | 28 +- .../libc/sys/socket/socket_freebsd_amd64.go | 32 +- .../libc/sys/socket/socket_linux_386.go | 777 +- .../libc/sys/socket/socket_linux_amd64.go | 767 +- .../libc/sys/socket/socket_linux_arm.go | 879 +- .../libc/sys/socket/socket_linux_arm64.go | 825 +- .../libc/sys/socket/socket_linux_s390x.go | 783 +- .../libc/sys/socket/socket_netbsd_amd64.go | 863 + .../libc/sys/stat/capi_darwin_amd64.go | 2 +- .../libc/sys/stat/capi_darwin_arm64.go | 2 +- .../libc/sys/stat/capi_linux_386.go | 2 +- .../libc/sys/stat/capi_linux_amd64.go | 2 +- .../libc/sys/stat/capi_linux_arm.go | 2 +- .../libc/sys/stat/capi_linux_arm64.go | 2 +- .../libc/sys/stat/capi_linux_s390x.go | 2 +- .../libc/sys/stat/capi_netbsd_amd64.go | 5 + .../libc/sys/stat/capi_windows_386.go | 2 +- .../libc/sys/stat/capi_windows_amd64.go | 2 +- .../libc/sys/stat/stat_darwin_amd64.go | 14 +- .../libc/sys/stat/stat_darwin_arm64.go | 10 +- .../libc/sys/stat/stat_freebsd_amd64.go | 34 +- .../libc/sys/stat/stat_linux_386.go | 310 +- .../libc/sys/stat/stat_linux_amd64.go | 279 +- .../libc/sys/stat/stat_linux_arm.go | 338 +- .../libc/sys/stat/stat_linux_arm64.go | 469 +- .../libc/sys/stat/stat_linux_s390x.go | 284 +- .../libc/sys/stat/stat_netbsd_amd64.go | 2354 + .../libc/sys/stat/stat_windows_386.go | 200 +- .../libc/sys/stat/stat_windows_amd64.go | 171 +- .../libc/sys/types/capi_darwin_amd64.go | 2 +- .../libc/sys/types/capi_darwin_arm64.go | 2 +- .../libc/sys/types/capi_linux_386.go | 2 +- .../libc/sys/types/capi_linux_amd64.go | 2 +- .../libc/sys/types/capi_linux_arm.go | 2 +- .../libc/sys/types/capi_linux_arm64.go | 2 +- .../libc/sys/types/capi_linux_s390x.go | 2 +- .../libc/sys/types/capi_netbsd_amd64.go | 5 + .../libc/sys/types/capi_windows_386.go | 2 +- .../libc/sys/types/capi_windows_amd64.go | 2 +- .../libc/sys/types/types_darwin_amd64.go | 6 +- .../libc/sys/types/types_darwin_arm64.go | 6 +- .../libc/sys/types/types_freebsd_amd64.go | 10 +- .../libc/sys/types/types_linux_386.go | 598 +- .../libc/sys/types/types_linux_amd64.go | 590 +- .../libc/sys/types/types_linux_arm.go | 694 +- .../libc/sys/types/types_linux_arm64.go | 645 +- .../libc/sys/types/types_linux_s390x.go | 605 +- .../libc/sys/types/types_netbsd_amd64.go | 1364 + .../libc/sys/types/types_windows_386.go | 60 +- .../libc/sys/types/types_windows_amd64.go | 21 +- .../libc/termios/capi_darwin_amd64.go | 2 +- .../libc/termios/capi_darwin_arm64.go | 2 +- .../libc/termios/capi_linux_386.go | 2 +- .../libc/termios/capi_linux_amd64.go | 2 +- .../libc/termios/capi_linux_arm.go | 2 +- .../libc/termios/capi_linux_arm64.go | 2 +- .../libc/termios/capi_linux_s390x.go | 2 +- .../libc/termios/capi_netbsd_amd64.go | 5 + .../libc/termios/termios_darwin_amd64.go | 22 +- .../libc/termios/termios_darwin_arm64.go | 18 +- .../libc/termios/termios_freebsd_amd64.go | 4 +- .../libc/termios/termios_linux_386.go | 354 +- .../libc/termios/termios_linux_amd64.go | 353 +- .../libc/termios/termios_linux_arm.go | 380 +- .../libc/termios/termios_linux_arm64.go | 386 +- .../libc/termios/termios_linux_s390x.go | 358 +- .../libc/termios/termios_netbsd_amd64.go | 733 + .../libc/time/capi_darwin_amd64.go | 2 +- .../libc/time/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/time/capi_linux_386.go | 2 +- .../modernc.org/libc/time/capi_linux_amd64.go | 2 +- .../modernc.org/libc/time/capi_linux_arm.go | 2 +- .../modernc.org/libc/time/capi_linux_arm64.go | 2 +- .../modernc.org/libc/time/capi_linux_s390x.go | 2 +- .../libc/time/capi_netbsd_amd64.go | 5 + .../modernc.org/libc/time/capi_windows_386.go | 2 +- .../libc/time/capi_windows_amd64.go | 2 +- .../libc/time/time_darwin_amd64.go | 30 +- .../libc/time/time_darwin_arm64.go | 28 +- .../libc/time/time_freebsd_amd64.go | 28 +- .../modernc.org/libc/time/time_linux_386.go | 271 +- .../modernc.org/libc/time/time_linux_amd64.go | 294 +- .../modernc.org/libc/time/time_linux_arm.go | 293 +- .../modernc.org/libc/time/time_linux_arm64.go | 319 +- .../modernc.org/libc/time/time_linux_s390x.go | 299 +- .../libc/time/time_netbsd_amd64.go | 2340 + .../modernc.org/libc/time/time_windows_386.go | 102 +- .../libc/time/time_windows_amd64.go | 60 +- .../libc/unistd/capi_darwin_amd64.go | 2 +- .../libc/unistd/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/unistd/capi_linux_386.go | 2 +- .../libc/unistd/capi_linux_amd64.go | 2 +- .../modernc.org/libc/unistd/capi_linux_arm.go | 2 +- .../libc/unistd/capi_linux_arm64.go | 2 +- .../libc/unistd/capi_linux_s390x.go | 2 +- .../libc/unistd/capi_netbsd_amd64.go | 5 + .../libc/unistd/capi_windows_386.go | 2 +- .../libc/unistd/capi_windows_amd64.go | 2 +- .../libc/unistd/unistd_darwin_amd64.go | 12 +- .../libc/unistd/unistd_darwin_arm64.go | 8 +- .../libc/unistd/unistd_freebsd_amd64.go | 10 +- .../libc/unistd/unistd_linux_386.go | 272 +- .../libc/unistd/unistd_linux_amd64.go | 271 +- .../libc/unistd/unistd_linux_arm.go | 302 +- .../libc/unistd/unistd_linux_arm64.go | 308 +- .../libc/unistd/unistd_linux_s390x.go | 276 +- .../libc/unistd/unistd_netbsd_amd64.go | 1804 + .../libc/unistd/unistd_windows_386.go | 97 +- .../libc/unistd/unistd_windows_amd64.go | 37 +- .../libc/utime/capi_darwin_amd64.go | 2 +- .../libc/utime/capi_darwin_arm64.go | 2 +- .../modernc.org/libc/utime/capi_linux_386.go | 2 +- .../libc/utime/capi_linux_amd64.go | 2 +- .../modernc.org/libc/utime/capi_linux_arm.go | 2 +- .../libc/utime/capi_linux_arm64.go | 2 +- .../libc/utime/capi_linux_s390x.go | 2 +- .../libc/utime/capi_netbsd_amd64.go | 5 + .../libc/utime/capi_windows_386.go | 2 +- .../libc/utime/capi_windows_amd64.go | 2 +- .../libc/utime/utime_darwin_amd64.go | 6 +- .../libc/utime/utime_darwin_arm64.go | 2 +- .../libc/utime/utime_freebsd_amd64.go | 4 +- .../modernc.org/libc/utime/utime_linux_386.go | 303 +- .../libc/utime/utime_linux_amd64.go | 302 +- .../modernc.org/libc/utime/utime_linux_arm.go | 329 +- .../libc/utime/utime_linux_arm64.go | 335 +- .../libc/utime/utime_linux_s390x.go | 307 +- .../libc/utime/utime_netbsd_amd64.go | 144 + .../libc/utime/utime_windows_386.go | 60 +- .../libc/utime/utime_windows_amd64.go | 3 +- .../libc/uuid/uuid/capi_darwin_amd64.go | 2 +- .../libc/uuid/uuid/capi_darwin_arm64.go | 2 +- .../libc/uuid/uuid/capi_linux_386.go | 2 +- .../libc/uuid/uuid/capi_linux_amd64.go | 2 +- .../libc/uuid/uuid/capi_linux_arm.go | 2 +- .../libc/uuid/uuid/capi_linux_arm64.go | 2 +- .../libc/uuid/uuid/capi_linux_s390x.go | 2 +- .../libc/uuid/uuid/uuid_darwin_amd64.go | 8 +- .../libc/uuid/uuid/uuid_darwin_arm64.go | 4 +- .../libc/uuid/uuid/uuid_linux_386.go | 670 +- .../libc/uuid/uuid/uuid_linux_amd64.go | 686 +- .../libc/uuid/uuid/uuid_linux_arm.go | 766 +- .../libc/uuid/uuid/uuid_linux_arm64.go | 741 +- .../libc/uuid/uuid/uuid_linux_s390x.go | 701 +- .../libc/wctype/capi_darwin_amd64.go | 5 + .../libc/wctype/capi_darwin_arm64.go | 5 + .../libc/wctype/capi_freebsd_amd64.go | 29 + .../modernc.org/libc/wctype/capi_linux_386.go | 5 + .../libc/wctype/capi_linux_amd64.go | 5 + .../modernc.org/libc/wctype/capi_linux_arm.go | 5 + .../libc/wctype/capi_linux_arm64.go | 5 + .../libc/wctype/capi_linux_s390x.go | 5 + .../libc/wctype/capi_netbsd_amd64.go | 5 + .../libc/wctype/capi_windows_386.go | 5 + .../libc/wctype/capi_windows_amd64.go | 5 + .../libc/wctype/wctype_darwin_amd64.go | 1405 + .../libc/wctype/wctype_darwin_arm64.go | 1387 + .../libc/wctype/wctype_freebsd_amd64.go | 796 + .../libc/wctype/wctype_linux_386.go | 931 + .../libc/wctype/wctype_linux_amd64.go | 949 + .../libc/wctype/wctype_linux_arm.go | 990 + .../libc/wctype/wctype_linux_arm64.go | 1017 + .../libc/wctype/wctype_linux_s390x.go | 948 + .../libc/wctype/wctype_netbsd_amd64.go | 326 + .../libc/wctype/wctype_windows_386.go | 288 + .../libc/wctype/wctype_windows_amd64.go | 287 + vendor/modernc.org/sqlite/Makefile | 43 +- vendor/modernc.org/sqlite/doc.go | 15 +- vendor/modernc.org/sqlite/generator.go | 45 +- .../sqlite/lib/capi_linux_s390x.go | 63 +- .../sqlite/lib/capi_netbsd_amd64.go | 1304 + vendor/modernc.org/sqlite/lib/mutex.go | 17 +- .../sqlite/lib/sqlite_darwin_amd64.go | 4126 +- .../sqlite/lib/sqlite_freebsd_amd64.go | 11755 +- .../sqlite/lib/sqlite_linux_386.go | 2624 +- .../sqlite/lib/sqlite_linux_amd64.go | 9670 +- .../sqlite/lib/sqlite_linux_arm.go | 5460 +- .../sqlite/lib/sqlite_linux_arm64.go | 12209 +- .../sqlite/lib/sqlite_linux_s390x.go | 40421 +-- .../sqlite/lib/sqlite_netbsd_amd64.go | 192083 +++++++++++++++ .../sqlite/lib/sqlite_windows_amd64.go | 19229 +- vendor/modernc.org/sqlite/sqlite.go | 56 +- vendor/modules.txt | 96 +- 848 files changed, 377869 insertions(+), 107280 deletions(-) create mode 100644 vendor/codeberg.org/gruf/go-logger/format_text.go create mode 100644 vendor/codeberg.org/gruf/go-logger/writer.go create mode 100644 vendor/codeberg.org/gruf/go-store/storage/memory.go delete mode 100644 vendor/github.com/gin-contrib/sessions/.travis.yml delete mode 100644 vendor/github.com/gin-gonic/gin/.golangci.yml create mode 100644 vendor/github.com/gin-gonic/gin/.travis.yml delete mode 100644 vendor/github.com/gin-gonic/gin/internal/json/go_json.go delete mode 100644 vendor/github.com/go-errors/errors/cover.out delete mode 100644 vendor/github.com/goccy/go-json/.codecov.yml delete mode 100644 vendor/github.com/goccy/go-json/.gitignore delete mode 100644 vendor/github.com/goccy/go-json/.golangci.yml delete mode 100644 vendor/github.com/goccy/go-json/CHANGELOG.md delete mode 100644 vendor/github.com/goccy/go-json/LICENSE delete mode 100644 vendor/github.com/goccy/go-json/Makefile delete mode 100644 vendor/github.com/goccy/go-json/README.md delete mode 100644 vendor/github.com/goccy/go-json/color.go delete mode 100644 vendor/github.com/goccy/go-json/decode.go delete mode 100644 vendor/github.com/goccy/go-json/docker-compose.yml delete mode 100644 vendor/github.com/goccy/go-json/encode.go delete mode 100644 vendor/github.com/goccy/go-json/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/array.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bool.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/bytes.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/compile_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/float.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/func.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/interface.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/map.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/number.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/ptr.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/slice.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/stream.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/struct.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/type.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/uint.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go delete mode 100644 vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compact.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/context.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/encoder.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/indent.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/int.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map112.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/map113.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/opcode.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/option.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/optype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/string.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go delete mode 100644 vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go delete mode 100644 vendor/github.com/goccy/go-json/internal/errors/error.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/rtype.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/struct_field.go delete mode 100644 vendor/github.com/goccy/go-json/internal/runtime/type.go delete mode 100644 vendor/github.com/goccy/go-json/json.go delete mode 100644 vendor/github.com/goccy/go-json/option.go create mode 100644 vendor/github.com/jackc/pgproto3/v2/function_call.go delete mode 100644 vendor/github.com/jackc/pgtype/.travis.yml create mode 100644 vendor/github.com/modern-go/reflect2/go_above_118.go delete mode 100644 vendor/github.com/modern-go/reflect2/go_above_17.go create mode 100644 vendor/github.com/modern-go/reflect2/go_below_118.go delete mode 100644 vendor/github.com/modern-go/reflect2/go_below_17.go delete mode 100644 vendor/github.com/modern-go/reflect2/go_below_19.go delete mode 100644 vendor/github.com/modern-go/reflect2/test.sh delete mode 100644 vendor/github.com/vmihailenco/msgpack/v5/.golangci.yml create mode 100644 vendor/github.com/vmihailenco/msgpack/v5/commitlint.config.js create mode 100644 vendor/github.com/vmihailenco/msgpack/v5/package.json create mode 100644 vendor/github.com/vmihailenco/msgpack/v5/version.go rename vendor/golang.org/x/crypto/{ => internal}/poly1305/bits_compat.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/bits_go1.13.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/mac_noasm.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/poly1305.go (98%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_amd64.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_amd64.s (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_generic.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_ppc64le.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_ppc64le.s (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_s390x.go (100%) rename vendor/golang.org/x/crypto/{ => internal}/poly1305/sum_s390x.s (99%) create mode 100644 vendor/golang.org/x/net/idna/go118.go create mode 100644 vendor/golang.org/x/net/idna/pre_go118.go create mode 100644 vendor/golang.org/x/sys/windows/setupapi_windows.go delete mode 100644 vendor/golang.org/x/sys/windows/setupapierrors_windows.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/support_go117.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/support_go118.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/common.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go create mode 100644 vendor/modernc.org/libc/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/errno/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/errno/errno_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/fcntl/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/fcntl/fcntl_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/fts/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/fts/fts_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/grp/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/grp/grp_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/ioutil_netbsd.go create mode 100644 vendor/modernc.org/libc/langinfo/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/langinfo/langinfo_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/libc_netbsd.go create mode 100644 vendor/modernc.org/libc/libc_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/limits/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/limits/limits_netbsd_amd64.go delete mode 100644 vendor/modernc.org/libc/log-generate create mode 100644 vendor/modernc.org/libc/musl_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/netdb/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/netdb/netdb_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/netinet/in/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/netinet/in/in_netbsd_amd64.go delete mode 100644 vendor/modernc.org/libc/nopthreads.go create mode 100644 vendor/modernc.org/libc/poll/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/poll/poll_netbsd_amd64.go rename vendor/modernc.org/libc/{pthreads.go => pthread.go} (90%) create mode 100644 vendor/modernc.org/libc/pthread/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/pthread/pthread_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/pthread_all.go create mode 100644 vendor/modernc.org/libc/pwd/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/pwd/pwd_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/signal/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/signal/more_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/signal/signal_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdio/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdio/stdio_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_darwin_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_darwin_arm64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_freebsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_linux_386.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_linux_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_linux_arm.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_linux_arm64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_linux_s390x.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_windows_386.go create mode 100644 vendor/modernc.org/libc/stdlib/capi_windows_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_darwin_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_darwin_arm64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_freebsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_linux_386.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_linux_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_linux_arm.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_linux_arm64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_linux_s390x.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_windows_386.go create mode 100644 vendor/modernc.org/libc/stdlib/stdlib_windows_amd64.go rename vendor/modernc.org/libc/{sync_linux_amd64.go => sync.go} (54%) delete mode 100644 vendor/modernc.org/libc/sync_linux_amd64.s create mode 100644 vendor/modernc.org/libc/sys/socket/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/sys/socket/socket_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/sys/stat/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/sys/stat/stat_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/sys/types/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/sys/types/types_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/termios/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/termios/termios_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/time/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/time/time_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/unistd/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/unistd/unistd_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/utime/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/utime/utime_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_darwin_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_darwin_arm64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_freebsd_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_linux_386.go create mode 100644 vendor/modernc.org/libc/wctype/capi_linux_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_linux_arm.go create mode 100644 vendor/modernc.org/libc/wctype/capi_linux_arm64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_linux_s390x.go create mode 100644 vendor/modernc.org/libc/wctype/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/capi_windows_386.go create mode 100644 vendor/modernc.org/libc/wctype/capi_windows_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_darwin_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_darwin_arm64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_freebsd_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_linux_386.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_linux_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_linux_arm.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_linux_arm64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_linux_s390x.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_netbsd_amd64.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_windows_386.go create mode 100644 vendor/modernc.org/libc/wctype/wctype_windows_amd64.go create mode 100644 vendor/modernc.org/sqlite/lib/capi_netbsd_amd64.go create mode 100644 vendor/modernc.org/sqlite/lib/sqlite_netbsd_amd64.go diff --git a/go.mod b/go.mod index 578eed119..eebd87f7e 100644 --- a/go.mod +++ b/go.mod @@ -3,22 +3,22 @@ module github.com/superseriousbusiness/gotosocial go 1.17 require ( - codeberg.org/gruf/go-store v1.0.3 + codeberg.org/gruf/go-store v1.1.0 github.com/ReneKroon/ttlcache v1.7.0 github.com/buckket/go-blurhash v1.1.0 - github.com/coreos/go-oidc/v3 v3.0.0 + github.com/coreos/go-oidc/v3 v3.1.0 github.com/gin-contrib/cors v1.3.1 - github.com/gin-contrib/sessions v0.0.3 - github.com/gin-gonic/gin v1.7.2-0.20210908033055-3a6f18f32f22 + github.com/gin-contrib/sessions v0.0.4 + github.com/gin-gonic/gin v1.7.7 github.com/go-fed/httpsig v1.1.0 github.com/go-playground/validator/v10 v10.9.0 github.com/google/uuid v1.3.0 github.com/gorilla/websocket v1.4.2 - github.com/h2non/filetype v1.1.1 - github.com/jackc/pgconn v1.10.0 - github.com/jackc/pgx/v4 v4.13.0 + github.com/h2non/filetype v1.1.3 + github.com/jackc/pgconn v1.10.1 + github.com/jackc/pgx/v4 v4.14.0 github.com/microcosm-cc/bluemonday v1.0.16 - github.com/mitchellh/mapstructure v1.4.1 + github.com/mitchellh/mapstructure v1.4.2 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/oklog/ulid v1.3.1 github.com/russross/blackfriday/v2 v2.1.0 @@ -27,27 +27,27 @@ require ( github.com/superseriousbusiness/activity v1.0.1-0.20211113133524-56560b73ace8 github.com/superseriousbusiness/exifremove v0.0.0-20210330092427-6acd27eac203 github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB - github.com/tdewolff/minify/v2 v2.9.21 - github.com/uptrace/bun v1.0.17 - github.com/uptrace/bun/dialect/pgdialect v1.0.17 - github.com/uptrace/bun/dialect/sqlitedialect v1.0.17 + github.com/tdewolff/minify/v2 v2.9.22 + github.com/uptrace/bun v1.0.18 + github.com/uptrace/bun/dialect/pgdialect v1.0.18 + github.com/uptrace/bun/dialect/sqlitedialect v1.0.18 github.com/urfave/cli/v2 v2.3.0 github.com/wagslane/go-password-validator v0.3.0 - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 - golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f + golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 + golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 golang.org/x/text v0.3.7 gopkg.in/yaml.v2 v2.4.0 - modernc.org/sqlite v1.13.0 + modernc.org/sqlite v1.14.1 mvdan.cc/xurls/v2 v2.3.0 ) require ( codeberg.org/gruf/go-bytes v1.0.2 // indirect - codeberg.org/gruf/go-errors v1.0.0 // indirect + codeberg.org/gruf/go-errors v1.0.2 // indirect codeberg.org/gruf/go-fastpath v1.0.2 // indirect codeberg.org/gruf/go-hashenc v1.0.1 // indirect - codeberg.org/gruf/go-logger v1.0.3 // indirect - codeberg.org/gruf/go-mutexes v1.0.0 // indirect + codeberg.org/gruf/go-logger v1.2.3 // indirect + codeberg.org/gruf/go-mutexes v1.0.1 // indirect codeberg.org/gruf/go-nowish v1.0.2 // indirect codeberg.org/gruf/go-pools v1.0.2 // indirect github.com/aymerick/douceur v0.2.0 // indirect @@ -62,15 +62,14 @@ require ( github.com/dsoprea/go-png-image-structure v0.0.0-20210512210324-29b889a6093d // indirect github.com/dsoprea/go-utility v0.0.0-20200717064901-2fccff4aa15e // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-errors/errors v1.4.0 // indirect + github.com/go-errors/errors v1.4.1 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect - github.com/goccy/go-json v0.7.8 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/golang/snappy v0.0.3 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/gorilla/context v1.1.1 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect @@ -78,37 +77,37 @@ require ( github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.1.1 // indirect + github.com/jackc/pgproto3/v2 v2.2.0 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.8.1 // indirect + github.com/jackc/pgtype v1.9.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect - github.com/json-iterator/go v1.1.11 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect - github.com/tdewolff/parse/v2 v2.5.19 // indirect + github.com/tdewolff/parse/v2 v2.5.22 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect github.com/ugorji/go/codec v1.2.6 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - golang.org/x/mod v0.5.0 // indirect - golang.org/x/net v0.0.0-20210908191846-a5e095526f91 // indirect - golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect - golang.org/x/tools v0.1.5 // indirect + golang.org/x/mod v0.5.1 // indirect + golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect + golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect + golang.org/x/tools v0.1.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect lukechampine.com/uint128 v1.1.1 // indirect - modernc.org/cc/v3 v3.34.0 // indirect - modernc.org/ccgo/v3 v3.11.2 // indirect - modernc.org/libc v1.11.3 // indirect + modernc.org/cc/v3 v3.35.18 // indirect + modernc.org/ccgo/v3 v3.12.73 // indirect + modernc.org/libc v1.11.83 // indirect modernc.org/mathutil v1.4.1 // indirect modernc.org/memory v1.0.5 // indirect modernc.org/opt v0.1.1 // indirect diff --git a/go.sum b/go.sum index 9eb2f6c28..e568b38e3 100644 --- a/go.sum +++ b/go.sum @@ -34,25 +34,27 @@ codeberg.org/gruf/go-bytes v1.0.0/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9 codeberg.org/gruf/go-bytes v1.0.1/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg= codeberg.org/gruf/go-bytes v1.0.2 h1:malqE42Ni+h1nnYWBUAJaDDtEzF4aeN4uPN8DfMNNvo= codeberg.org/gruf/go-bytes v1.0.2/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg= -codeberg.org/gruf/go-cache v1.0.0/go.mod h1:nfefEzEvCd+uFetFioBQMmzcT/NNxdxc6e49qxDbFgg= -codeberg.org/gruf/go-errors v1.0.0 h1:jzEnAwICwGLTP4pHaGD9aD3HVR0ZzJb4AB01xTPKpF4= -codeberg.org/gruf/go-errors v1.0.0/go.mod h1:G66SPILZJMOGRRHwAK7KSEk9N5fEnCk7asFc+De1SP0= +codeberg.org/gruf/go-cache v1.1.1/go.mod h1:XSzglJd721RkWHIW7egiWBQEvGa1hwTNCv74PcBsZOk= +codeberg.org/gruf/go-errors v1.0.1/go.mod h1:JwoVg0AAwQkk2UWtDjR1mXcQLK/U8bs4RB4nUJ/yTCE= +codeberg.org/gruf/go-errors v1.0.2 h1:fKmNM/XDtCpRhQS7Wf/02nScUqEfOBZy08yqR0ysIcI= +codeberg.org/gruf/go-errors v1.0.2/go.mod h1:JwoVg0AAwQkk2UWtDjR1mXcQLK/U8bs4RB4nUJ/yTCE= codeberg.org/gruf/go-fastpath v1.0.1/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI= codeberg.org/gruf/go-fastpath v1.0.2 h1:O3nuYPMXnN89dsgAwVFU5iCGINtPJdITWmbRe2an/iQ= codeberg.org/gruf/go-fastpath v1.0.2/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI= codeberg.org/gruf/go-hashenc v1.0.1 h1:EBvNe2wW8IPMUqT1XihB6/IM6KMJDLMFBxIUvmsy1f8= codeberg.org/gruf/go-hashenc v1.0.1/go.mod h1:IfHhPCVScOiYmJLqdCQT9bYVS1nxNTV4ewMUvFWDPtc= -codeberg.org/gruf/go-logger v1.0.3 h1:ccCpkG+2RMV/TgkaivQoWoodSlKqAfixonFY7qR70M8= -codeberg.org/gruf/go-logger v1.0.3/go.mod h1:BLwlr04s5qjniVZ8okCT9fepGL+B/dfmyZ9zBjnjDWs= -codeberg.org/gruf/go-mutexes v1.0.0 h1:s15kUdv/ufCFH+kmMOAOTUUJ/TK9uaJU+rNSwRI9jY8= -codeberg.org/gruf/go-mutexes v1.0.0/go.mod h1:y2hbGLkWVHhNyxBOIVsA3/y2QMm6RSrYsC3sLVZ4EXM= +codeberg.org/gruf/go-logger v1.2.3 h1:WJWs/v4s//d+gJE3PJEXWHkSIsRVP1u3Ukcg+mPIVk4= +codeberg.org/gruf/go-logger v1.2.3/go.mod h1:tBduUc+Yb9vqGRxY9/FB0ZlYznSteLy/KmIANo7zFjA= +codeberg.org/gruf/go-mutexes v1.0.1 h1:X9bZW74YSEplWWdCrVXAvue5ztw3w5hh+INdXTENu88= +codeberg.org/gruf/go-mutexes v1.0.1/go.mod h1:y2hbGLkWVHhNyxBOIVsA3/y2QMm6RSrYsC3sLVZ4EXM= codeberg.org/gruf/go-nowish v1.0.0/go.mod h1:70nvICNcqQ9OHpF07N614Dyk7cpL5ToWU1K1ZVCec2s= codeberg.org/gruf/go-nowish v1.0.2 h1:/y8g38x44sD8JeqBPCkzqLoe0pReR1CTF8p6jXCOG1s= codeberg.org/gruf/go-nowish v1.0.2/go.mod h1:70nvICNcqQ9OHpF07N614Dyk7cpL5ToWU1K1ZVCec2s= codeberg.org/gruf/go-pools v1.0.2 h1:B0X6yoCL9FVmnvyoizb1SYRwMYPWwEJBjPnBMM5ILos= codeberg.org/gruf/go-pools v1.0.2/go.mod h1:MjUV3H6IASyBeBPCyCr7wjPpSNu8E2N87LG4r4TAyok= -codeberg.org/gruf/go-store v1.0.3 h1:lpMlE/T73dJyv4oPmkmq3/Xv92TM4J7mFnV6smhnMzE= -codeberg.org/gruf/go-store v1.0.3/go.mod h1:vcBYUK8+WwMqvtK0Ma2kl9lVZooaKkw2GvGnAs0E7kI= +codeberg.org/gruf/go-runners v1.0.0/go.mod h1:9gTrmMnO3d+50C+hVzcmGBf+zTuswReS278E2EMvnmw= +codeberg.org/gruf/go-store v1.1.0 h1:0LJP6MoMDf5im/d4vq4CZsUQQkqVmigoGB9Nz+kStEo= +codeberg.org/gruf/go-store v1.1.0/go.mod h1:jrISks8z/ND/FUpQX8zTlF7oTkHmKt4Sco+NdvSAzPg= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -64,10 +66,11 @@ github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4= github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/antonlindstrom/pgstore v0.0.0-20200229204646-b08ebf1105e0/go.mod h1:2Ti6VUHVxpC0VSmTZzEvpzysnaGAfGBOoMIz5ykPyyw= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff/go.mod h1:+RTT1BOk5P97fT2CiHkbFQwkK3mjsFAP6zCYV2aXtjw= -github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= +github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= github.com/bradleypeabody/gorilla-sessions-memcache v0.0.0-20181103040241-659414f458e1/go.mod h1:dkChI7Tbtx7H1Tj7TqGSZMOeGpMP5gLHtjroHd4agiI= github.com/buckket/go-blurhash v1.1.0 h1:X5M6r0LIvwdvKiUtiNcRL2YlmOfMzYobI3VCKCZc9Do= github.com/buckket/go-blurhash v1.1.0/go.mod h1:aT2iqo5W9vu9GpyoLErKfTHwgODsZp3bQfXjXJUxNb8= @@ -80,8 +83,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/coreos/go-oidc/v3 v3.0.0 h1:/mAA0XMgYJw2Uqm7WKGCsKnjitE/+A0FFbOmiRJm7LQ= -github.com/coreos/go-oidc/v3 v3.0.0/go.mod h1:rEJ/idjfUyfkBit1eI1fvyr+64/g9dcKpAm8MJMesvo= +github.com/coreos/go-oidc/v3 v3.1.0 h1:6avEvcdvTa1qYsOZ6I5PRkSYHzpTNWgKYmaJfaYbrRw= +github.com/coreos/go-oidc/v3 v3.1.0/go.mod h1:rEJ/idjfUyfkBit1eI1fvyr+64/g9dcKpAm8MJMesvo= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -93,6 +96,7 @@ github.com/dave/jennifer v1.3.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhr github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/djherbis/atime v1.1.0/go.mod h1:28OF6Y8s3NQWwacXc5eZTsEsiMzp7LF8MbXE+XJPdBE= github.com/dsoprea/go-exif v0.0.0-20210131231135-d154f10435cc/go.mod h1:lOaOt7+UEppOgyvRy749v3do836U/hw0YVJNjoyPaEs= github.com/dsoprea/go-exif v0.0.0-20210625224831-a6301f85c82b h1:hoVHc4m/v8Al8mbWyvKJWr4Z37yM4QUSVh/NY6A5Sbc= github.com/dsoprea/go-exif v0.0.0-20210625224831-a6301f85c82b/go.mod h1:lOaOt7+UEppOgyvRy749v3do836U/hw0YVJNjoyPaEs= @@ -134,23 +138,25 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gin-contrib/cors v1.3.1 h1:doAsuITavI4IOcd0Y19U4B+O0dNWihRyX//nn4sEmgA= github.com/gin-contrib/cors v1.3.1/go.mod h1:jjEJ4268OPZUcU7k9Pm653S7lXUGcqMADzFA61xsmDk= -github.com/gin-contrib/sessions v0.0.3 h1:PoBXki+44XdJdlgDqDrY5nDVe3Wk7wDV/UCOuLP6fBI= -github.com/gin-contrib/sessions v0.0.3/go.mod h1:8C/J6cad3Il1mWYYgtw0w+hqasmpvy25mPkXdOgeB9I= +github.com/gin-contrib/sessions v0.0.4 h1:gq4fNa1Zmp564iHP5G6EBuktilEos8VKhe2sza1KMgo= +github.com/gin-contrib/sessions v0.0.4/go.mod h1:pQ3sIyviBBGcxgyR8mkeJuXbeV3h3NYmhJADQTq5+Vo= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= -github.com/gin-gonic/gin v1.7.2-0.20210908033055-3a6f18f32f22 h1:kWkYy1sC7NJOQJ9d5byxqVYNtDxaHxNfBhxa1x+fncc= -github.com/gin-gonic/gin v1.7.2-0.20210908033055-3a6f18f32f22/go.mod h1:JkzyG2NNK3nIu6mIADW5aYvtWOsqhYbJhXueC0y9Iz8= +github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= +github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= +github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs= -github.com/go-errors/errors v1.4.0 h1:2OA7MFw38+e9na72T1xgkomPb6GzZzzxvJ5U630FoRM= -github.com/go-errors/errors v1.4.0/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.4.1 h1:IvVlgbzSsaUNudsw5dcXSzF3EWyXTi5XrAdngnuhRyg= +github.com/go-errors/errors v1.4.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-fed/httpsig v0.1.1-0.20190914113940-c2de3672e5b5/go.mod h1:T56HUNYZUQ1AGUzhAYPugZfp36sKApVnGBgKlIY+aIE= github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI= github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM= @@ -162,11 +168,14 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A= github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-session/session v3.1.2+incompatible/go.mod h1:8B3iivBQjrz/JtC68Np2T1yBBLxTan3mn/3OM0CyRt0= @@ -177,8 +186,6 @@ github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4 github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/goccy/go-json v0.4.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.5.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.7.8 h1:CvMH7LotYymYuLGEohBM1lTZWX4g6jzWUUl2aLFuBoE= -github.com/goccy/go-json v0.7.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= @@ -216,8 +223,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -259,13 +267,14 @@ github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.1.1/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= -github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w= +github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/h2non/filetype v1.1.1 h1:xvOwnXKAckvtLWsN398qS9QhlxlnVXBjXBydK2/UFB4= github.com/h2non/filetype v1.1.1/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= +github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= +github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -283,8 +292,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.10.0 h1:4EYhlDVEMsJ30nNj0mmgwIUXoq7e9sMJrVC2ED6QlCU= -github.com/jackc/pgconn v1.10.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.10.1 h1:DzdIHIjG1AxGwoEEqS+mGsURyjt4enSmqzACXvVzOT8= +github.com/jackc/pgconn v1.10.1/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -300,31 +309,34 @@ github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= +github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.8.1 h1:9k0IXtdJXHJbyAWQgbWr1lU+MEhPXZz6RIXxfR5oxXs= -github.com/jackc/pgtype v1.8.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.9.0 h1:/SH1RxEtltvJgsDqp3TbiTFApD3mey3iygpuEGeuBXk= +github.com/jackc/pgtype v1.9.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.13.0 h1:JCjhT5vmhMAf/YwBHLvrBn4OGdIQBiFG6ym8Zmdx570= -github.com/jackc/pgx/v4 v4.13.0/go.mod h1:9P4X524sErlaxj0XSGZk7s+LD0eOyu1ZDUrrpznYDF0= +github.com/jackc/pgx/v4 v4.14.0 h1:TgdrmgnM7VY72EuSQzBbBd4JA1RLqJolrw9nQVZABVc= +github.com/jackc/pgx/v4 v4.14.0/go.mod h1:jT3ibf/A0ZVCp89rtCIN0zCJxcE74ypROmHEZYsG/j8= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -339,9 +351,7 @@ github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kpango/fastime v1.0.16 h1:1prFG/3pTjzcDeCTxt98VB4IvjxcySLs0ldCEhZg0R8= github.com/kpango/fastime v1.0.16/go.mod h1:lVqUTcXmQnk1wriyvq5DElbRSRDC0XtqbXQRdz0Eo+g= -github.com/kpango/glg v1.5.8 h1:ZyxQa0Ft27dWci+2X7vMCCjHGEZCTFWLBHnLrAzxQZs= github.com/kpango/glg v1.5.8/go.mod h1:HI0g/1T4dmUhdoT2isXHrCM4FeNjc+t7fZujjvqYIeQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -353,13 +363,15 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg= +github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -370,19 +382,19 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU= -github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA= +github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc= github.com/microcosm-cc/bluemonday v1.0.16 h1:kHmAq2t7WPWLjiGvzKa5o3HzSfahUKiOq7fAPUiMNIc= github.com/microcosm-cc/bluemonday v1.0.16/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= +github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= @@ -396,12 +408,12 @@ github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1ls github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/quasoft/memstore v0.0.0-20180925164028-84a050167438/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg= github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b h1:aUNXCGgukb4gtY99imuIeoh8Vr0GSwAlYxPAhqZrpFc= github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= @@ -449,10 +461,11 @@ github.com/superseriousbusiness/exifremove v0.0.0-20210330092427-6acd27eac203 h1 github.com/superseriousbusiness/exifremove v0.0.0-20210330092427-6acd27eac203/go.mod h1:0Xw5cYMOYpgaWs+OOSx41ugycl2qvKTi9tlMMcZhFyY= github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB h1:PtW2w6budTvRV2J5QAoSvThTHBuvh8t/+BXIZFAaBSc= github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB/go.mod h1:uYC/W92oVRJ49Vh1GcvTqpeFqHi+Ovrl2sMllQWRAEo= -github.com/tdewolff/minify/v2 v2.9.21 h1:nO4s1PEMy7aRjlIlbr3Jgr+bJby8QYuifa2Vs2f9lh4= -github.com/tdewolff/minify/v2 v2.9.21/go.mod h1:PoDBts2L7sCwUT28vTAlozGeD6qxjrrihtin4bR/RMM= -github.com/tdewolff/parse/v2 v2.5.19 h1:Kjaj3KQOx/4elIxlBSglus4E2oMfdROphvbq2b+OBZ0= -github.com/tdewolff/parse/v2 v2.5.19/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= +github.com/tdewolff/minify/v2 v2.9.22 h1:PlmaAakaJHdMMdTTwjjsuSwIxKqWPTlvjTj6a/g/ILU= +github.com/tdewolff/minify/v2 v2.9.22/go.mod h1:dNlaFdXaIxgSXh3UFASqjTY0/xjpDkkCsYHA1NCGnmQ= +github.com/tdewolff/parse/v2 v2.5.21/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= +github.com/tdewolff/parse/v2 v2.5.22 h1:KXMHTyx4VTL6Zu9a94SULQalDMvtP5FQq10mnSfaoGs= +github.com/tdewolff/parse/v2 v2.5.22/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tidwall/btree v0.0.0-20191029221954-400434d76274 h1:G6Z6HvJuPjG6XfNGi/feOATzeJrfgTNJY+rGrHbA04E= @@ -481,12 +494,12 @@ github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/uptrace/bun v1.0.17 h1:ti3IyOieIKaBO2pmxB1Rj8R1WpXw7utaRmr5kL9WrSs= -github.com/uptrace/bun v1.0.17/go.mod h1:rs7qARtH6aqLtcfmloWM6qn90iyY53N2ScLQssIrevw= -github.com/uptrace/bun/dialect/pgdialect v1.0.17 h1:Cjm2YL1jAD00eclC6uf8MT6iPpHaXAyKL2GbxNYZdaE= -github.com/uptrace/bun/dialect/pgdialect v1.0.17/go.mod h1:b7tIxPup1wzryFZfUghMd2wIoYj9XzL+0Vr2OhQvAJA= -github.com/uptrace/bun/dialect/sqlitedialect v1.0.17 h1:ca3c/YnkrL1fp/Ok0lDGNbpgF0t07WWGHdh2NAzwctM= -github.com/uptrace/bun/dialect/sqlitedialect v1.0.17/go.mod h1:HH9VihgggYYA4igpgw/5qJEsC7UfpJPqfXgp5DvVJfU= +github.com/uptrace/bun v1.0.18 h1:F2UclG0HQQOy6lLS2NWOUKqzjO1j1s9AWe6aGysVlkk= +github.com/uptrace/bun v1.0.18/go.mod h1:Uv7z0z+7dXnUS9P5hMF0hdiM/4M+xOUHQCrZpyDrpRc= +github.com/uptrace/bun/dialect/pgdialect v1.0.18 h1:PZDvpQSrc7onj1SsGNKFHy4LDfobPtNKXWEbsCqr6q8= +github.com/uptrace/bun/dialect/pgdialect v1.0.18/go.mod h1:Zw3h+kaJKexgfsHi+0tAxZXx0iHh16lyvwXnnMHL7xc= +github.com/uptrace/bun/dialect/sqlitedialect v1.0.18 h1:Xc4zoBtS2lK47lDjA5J3K1p/JwGGKk50Yxhzzj2kwPY= +github.com/uptrace/bun/dialect/sqlitedialect v1.0.18/go.mod h1:A9R2zIMUL1MkIl5xYLzq/NHQ8PC2Ob3kRgegMs7obdA= github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -494,8 +507,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.14.0 h1:67bfuW9azCMwW/Jlq/C+VeihNpAuJMWkYPBig1gdi3A= github.com/valyala/fasthttp v1.14.0/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= -github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= -github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= +github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/wagslane/go-password-validator v0.3.0 h1:vfxOPzGHkz5S146HDpavl0cw1DSVP061Ry2PX0/ON6I= @@ -517,7 +530,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -528,7 +541,6 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4= go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI= @@ -536,14 +548,12 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/ go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -556,8 +566,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI= +golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -589,8 +599,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -624,17 +634,19 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210908191846-a5e095526f91 h1:E8wdt+zBjoxD3MA65wEc3pl25BsTi7tbkpwc4ANThjc= -golang.org/x/net v0.0.0-20210908191846-a5e095526f91/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 h1:0qxwC5n+ttVOINCBeRHO0nq9X7uy8SDsPoi5OaCdIEI= +golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f h1:Qmd2pbz05z7z6lm0DrgQVVPuBm92jqujBKMHMOlOQEw= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -686,15 +698,16 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -757,8 +770,8 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -883,22 +896,89 @@ lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= -modernc.org/cc/v3 v3.34.0 h1:dFhZc/HKR3qp92sYQxKRRaDMz+sr1bwcFD+m7LSCrAs= modernc.org/cc/v3 v3.34.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.0/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.4/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.5/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.8/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= +modernc.org/cc/v3 v3.35.18 h1:rMZhRcWrba0y3nVmdiQ7kxAgOOSq2m2f2VzjHLgEs6U= +modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g= modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60= modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw= modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI= modernc.org/ccgo/v3 v3.11.1/go.mod h1:lWHxfsn13L3f7hgGsGlU28D9eUOf6y3ZYHKoPaKU0ag= -modernc.org/ccgo/v3 v3.11.2 h1:gqa8PQ2v7SjrhHCgxUO5dzoAJWSLAveJqZTNkPCN0kc= -modernc.org/ccgo/v3 v3.11.2/go.mod h1:6kii3AptTDI+nUrM9RFBoIEUEisSWCbdczD9ZwQH2FE= +modernc.org/ccgo/v3 v3.11.3/go.mod h1:0oHunRBMBiXOKdaglfMlRPBALQqsfrCKXgw9okQ3GEw= +modernc.org/ccgo/v3 v3.12.4/go.mod h1:Bk+m6m2tsooJchP/Yk5ji56cClmN6R1cqc9o/YtbgBQ= +modernc.org/ccgo/v3 v3.12.6/go.mod h1:0Ji3ruvpFPpz+yu+1m0wk68pdr/LENABhTrDkMDWH6c= +modernc.org/ccgo/v3 v3.12.8/go.mod h1:Hq9keM4ZfjCDuDXxaHptpv9N24JhgBZmUG5q60iLgUo= +modernc.org/ccgo/v3 v3.12.11/go.mod h1:0jVcmyDwDKDGWbcrzQ+xwJjbhZruHtouiBEvDfoIsdg= +modernc.org/ccgo/v3 v3.12.14/go.mod h1:GhTu1k0YCpJSuWwtRAEHAol5W7g1/RRfS4/9hc9vF5I= +modernc.org/ccgo/v3 v3.12.18/go.mod h1:jvg/xVdWWmZACSgOiAhpWpwHWylbJaSzayCqNOJKIhs= +modernc.org/ccgo/v3 v3.12.20/go.mod h1:aKEdssiu7gVgSy/jjMastnv/q6wWGRbszbheXgWRHc8= +modernc.org/ccgo/v3 v3.12.21/go.mod h1:ydgg2tEprnyMn159ZO/N4pLBqpL7NOkJ88GT5zNU2dE= +modernc.org/ccgo/v3 v3.12.22/go.mod h1:nyDVFMmMWhMsgQw+5JH6B6o4MnZ+UQNw1pp52XYFPRk= +modernc.org/ccgo/v3 v3.12.25/go.mod h1:UaLyWI26TwyIT4+ZFNjkyTbsPsY3plAEB6E7L/vZV3w= +modernc.org/ccgo/v3 v3.12.29/go.mod h1:FXVjG7YLf9FetsS2OOYcwNhcdOLGt8S9bQ48+OP75cE= +modernc.org/ccgo/v3 v3.12.36/go.mod h1:uP3/Fiezp/Ga8onfvMLpREq+KUjUmYMxXPO8tETHtA8= +modernc.org/ccgo/v3 v3.12.38/go.mod h1:93O0G7baRST1vNj4wnZ49b1kLxt0xCW5Hsa2qRaZPqc= +modernc.org/ccgo/v3 v3.12.43/go.mod h1:k+DqGXd3o7W+inNujK15S5ZYuPoWYLpF5PYougCmthU= +modernc.org/ccgo/v3 v3.12.46/go.mod h1:UZe6EvMSqOxaJ4sznY7b23/k13R8XNlyWsO5bAmSgOE= +modernc.org/ccgo/v3 v3.12.47/go.mod h1:m8d6p0zNps187fhBwzY/ii6gxfjob1VxWb919Nk1HUk= +modernc.org/ccgo/v3 v3.12.50/go.mod h1:bu9YIwtg+HXQxBhsRDE+cJjQRuINuT9PUK4orOco/JI= +modernc.org/ccgo/v3 v3.12.51/go.mod h1:gaIIlx4YpmGO2bLye04/yeblmvWEmE4BBBls4aJXFiE= +modernc.org/ccgo/v3 v3.12.53/go.mod h1:8xWGGTFkdFEWBEsUmi+DBjwu/WLy3SSOrqEmKUjMeEg= +modernc.org/ccgo/v3 v3.12.54/go.mod h1:yANKFTm9llTFVX1FqNKHE0aMcQb1fuPJx6p8AcUx+74= +modernc.org/ccgo/v3 v3.12.55/go.mod h1:rsXiIyJi9psOwiBkplOaHye5L4MOOaCjHg1Fxkj7IeU= +modernc.org/ccgo/v3 v3.12.56/go.mod h1:ljeFks3faDseCkr60JMpeDb2GSO3TKAmrzm7q9YOcMU= +modernc.org/ccgo/v3 v3.12.57/go.mod h1:hNSF4DNVgBl8wYHpMvPqQWDQx8luqxDnNGCMM4NFNMc= +modernc.org/ccgo/v3 v3.12.60/go.mod h1:k/Nn0zdO1xHVWjPYVshDeWKqbRWIfif5dtsIOCUVMqM= +modernc.org/ccgo/v3 v3.12.65/go.mod h1:D6hQtKxPNZiY6wDBtehSGKFKmyXn53F8nGTpH+POmS4= +modernc.org/ccgo/v3 v3.12.66/go.mod h1:jUuxlCFZTUZLMV08s7B1ekHX5+LIAurKTTaugUr/EhQ= +modernc.org/ccgo/v3 v3.12.67/go.mod h1:Bll3KwKvGROizP2Xj17GEGOTrlvB1XcVaBrC90ORO84= +modernc.org/ccgo/v3 v3.12.73 h1:AMk4wEpzWjpODXohKvvnlwLob4Xk8tq3we6CwYh88mA= +modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3cQ= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q= modernc.org/libc v1.11.0/go.mod h1:2lOfPmj7cz+g1MrPNmX65QCzVxgNq2C5o0jdLY2gAYg= modernc.org/libc v1.11.2/go.mod h1:ioIyrl3ETkugDO3SGZ+6EOKvlP3zSOycUETe4XM4n8M= -modernc.org/libc v1.11.3 h1:q//spBhqp23lC/if8/o8hlyET57P8mCZqrqftzT2WmY= -modernc.org/libc v1.11.3/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU= +modernc.org/libc v1.11.5/go.mod h1:k3HDCP95A6U111Q5TmG3nAyUcp3kR5YFZTeDS9v8vSU= +modernc.org/libc v1.11.6/go.mod h1:ddqmzR6p5i4jIGK1d/EiSw97LBcE3dK24QEwCFvgNgE= +modernc.org/libc v1.11.11/go.mod h1:lXEp9QOOk4qAYOtL3BmMve99S5Owz7Qyowzvg6LiZso= +modernc.org/libc v1.11.13/go.mod h1:ZYawJWlXIzXy2Pzghaf7YfM8OKacP3eZQI81PDLFdY8= +modernc.org/libc v1.11.16/go.mod h1:+DJquzYi+DMRUtWI1YNxrlQO6TcA5+dRRiq8HWBWRC8= +modernc.org/libc v1.11.19/go.mod h1:e0dgEame6mkydy19KKaVPBeEnyJB4LGNb0bBH1EtQ3I= +modernc.org/libc v1.11.24/go.mod h1:FOSzE0UwookyT1TtCJrRkvsOrX2k38HoInhw+cSCUGk= +modernc.org/libc v1.11.26/go.mod h1:SFjnYi9OSd2W7f4ct622o/PAYqk7KHv6GS8NZULIjKY= +modernc.org/libc v1.11.27/go.mod h1:zmWm6kcFXt/jpzeCgfvUNswM0qke8qVwxqZrnddlDiE= +modernc.org/libc v1.11.28/go.mod h1:Ii4V0fTFcbq3qrv3CNn+OGHAvzqMBvC7dBNyC4vHZlg= +modernc.org/libc v1.11.31/go.mod h1:FpBncUkEAtopRNJj8aRo29qUiyx5AvAlAxzlx9GNaVM= +modernc.org/libc v1.11.34/go.mod h1:+Tzc4hnb1iaX/SKAutJmfzES6awxfU1BPvrrJO0pYLg= +modernc.org/libc v1.11.37/go.mod h1:dCQebOwoO1046yTrfUE5nX1f3YpGZQKNcITUYWlrAWo= +modernc.org/libc v1.11.39/go.mod h1:mV8lJMo2S5A31uD0k1cMu7vrJbSA3J3waQJxpV4iqx8= +modernc.org/libc v1.11.42/go.mod h1:yzrLDU+sSjLE+D4bIhS7q1L5UwXDOw99PLSX0BlZvSQ= +modernc.org/libc v1.11.44/go.mod h1:KFq33jsma7F5WXiYelU8quMJasCCTnHK0mkri4yPHgA= +modernc.org/libc v1.11.45/go.mod h1:Y192orvfVQQYFzCNsn+Xt0Hxt4DiO4USpLNXBlXg/tM= +modernc.org/libc v1.11.47/go.mod h1:tPkE4PzCTW27E6AIKIR5IwHAQKCAtudEIeAV1/SiyBg= +modernc.org/libc v1.11.49/go.mod h1:9JrJuK5WTtoTWIFQ7QjX2Mb/bagYdZdscI3xrvHbXjE= +modernc.org/libc v1.11.51/go.mod h1:R9I8u9TS+meaWLdbfQhq2kFknTW0O3aw3kEMqDDxMaM= +modernc.org/libc v1.11.53/go.mod h1:5ip5vWYPAoMulkQ5XlSJTy12Sz5U6blOQiYasilVPsU= +modernc.org/libc v1.11.54/go.mod h1:S/FVnskbzVUrjfBqlGFIPA5m7UwB3n9fojHhCNfSsnw= +modernc.org/libc v1.11.55/go.mod h1:j2A5YBRm6HjNkoSs/fzZrSxCuwWqcMYTDPLNx0URn3M= +modernc.org/libc v1.11.56/go.mod h1:pakHkg5JdMLt2OgRadpPOTnyRXm/uzu+Yyg/LSLdi18= +modernc.org/libc v1.11.58/go.mod h1:ns94Rxv0OWyoQrDqMFfWwka2BcaF6/61CqJRK9LP7S8= +modernc.org/libc v1.11.70/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw= +modernc.org/libc v1.11.71/go.mod h1:DUOmMYe+IvKi9n6Mycyx3DbjfzSKrdr/0Vgt3j7P5gw= +modernc.org/libc v1.11.75/go.mod h1:dGRVugT6edz361wmD9gk6ax1AbDSe0x5vji0dGJiPT0= +modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI= +modernc.org/libc v1.11.83 h1:WmbgzryG15U1WViAd73q2WJGLLMczZCT0YJWjW6A8mo= +modernc.org/libc v1.11.83/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= @@ -909,16 +989,16 @@ modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14= modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM= modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.13.0 h1:cwhUj0jTBgPjk/demWheV+T6xi6ifTfsGIFKFq0g3Ck= -modernc.org/sqlite v1.13.0/go.mod h1:2qO/6jZJrcQaxFUHxOwa6Q6WfiGSsiVj6GXX0Ker+Jg= +modernc.org/sqlite v1.14.1 h1:jthfQCbWKfbK/lvZSjFEpBk0QzIBN6pQbFdDqBMR490= +modernc.org/sqlite v1.14.1/go.mod h1:04Lqa+3PuAEUhAPAPWeDMljT4UYA31nb2DHTFG47L1g= modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= -modernc.org/tcl v1.5.9 h1:DZMfR+RDJRhcrmMEMTJgVIX+Wf5qhfVX0llI0rsc20w= -modernc.org/tcl v1.5.9/go.mod h1:bcwjvBJ2u0exY6K35eAmxXBBij5kXb1dHlAWmfhqThE= +modernc.org/tcl v1.8.13 h1:V0sTNBw0Re86PvXZxuCub3oO9WrSTqALgrwNZNvLFGw= +modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY= modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.1.2 h1:IjjzDsIFbl0wuF2KfwvdyUAJVwxD4iwZ6akLNiDoClM= -modernc.org/z v1.1.2/go.mod h1:sj9T1AGBG0dm6SCVzldPOHWrif6XBpooJtbttMn1+Js= +modernc.org/z v1.2.19 h1:BGyRFWhDVn5LFS5OcX4Yd/MlpRTOc7hOPTdcIpCiUao= +modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY= mvdan.cc/xurls/v2 v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I= mvdan.cc/xurls/v2 v2.3.0/go.mod h1:AjuTy7gEiUArFMjgBBDU4SMxlfUYsRokpJQgNWOt3e4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/testrig/storage.go b/testrig/storage.go index 0d90a7f87..4cc7f5080 100644 --- a/testrig/storage.go +++ b/testrig/storage.go @@ -168,8 +168,8 @@ func (s *inMemStorage) Remove(key string) error { return nil } -func (s *inMemStorage) WalkKeys(opts *storage.WalkKeysOptions) error { - if opts == nil || opts.WalkFn == nil { +func (s *inMemStorage) WalkKeys(opts storage.WalkKeysOptions) error { + if opts.WalkFn == nil { return errors.New("invalid walkfn") } for key := range s.storage { diff --git a/vendor/codeberg.org/gruf/go-errors/data.go b/vendor/codeberg.org/gruf/go-errors/data.go index 3a32fd69e..1531c07d4 100644 --- a/vendor/codeberg.org/gruf/go-errors/data.go +++ b/vendor/codeberg.org/gruf/go-errors/data.go @@ -7,17 +7,22 @@ import ( "codeberg.org/gruf/go-logger" ) -// global logfmt data formatter -var logfmt = logger.TextFormat{Strict: false} +// global logfmt data formatter. +var logfmt = logger.TextFormat{ + Strict: logger.DefaultTextFormat.Strict, + MaxDepth: logger.DefaultTextFormat.MaxDepth, + Levels: nil, + TimeFormat: logger.DefaultTextFormat.TimeFormat, +} -// KV is a structure for setting key-value pairs in ErrorData +// KV is a structure for setting key-value pairs in ErrorData. type KV struct { Key string Value interface{} } // ErrorData defines a way to set and access contextual error data. -// The default implementation of this is thread-safe +// The default implementation of this is thread-safe. type ErrorData interface { // Value will attempt to fetch value for given key in ErrorData Value(string) (interface{}, bool) @@ -29,7 +34,7 @@ type ErrorData interface { String() string } -// NewData returns a new ErrorData implementation +// NewData returns a new ErrorData implementation. func NewData() ErrorData { return &errorData{ data: make(map[string]interface{}, 10), @@ -37,7 +42,7 @@ func NewData() ErrorData { } // errorData is our ErrorData implementation, this is essentially -// just a thread-safe string-interface map implementation +// just a thread-safe string-interface map implementation. type errorData struct { data map[string]interface{} buf bytes.Buffer diff --git a/vendor/codeberg.org/gruf/go-errors/errors.go b/vendor/codeberg.org/gruf/go-errors/errors.go index 283bdb098..b1b41bf02 100644 --- a/vendor/codeberg.org/gruf/go-errors/errors.go +++ b/vendor/codeberg.org/gruf/go-errors/errors.go @@ -105,6 +105,25 @@ func Data(err error) ErrorData { return nil } +// UnwrapAll fully unwraps an error stack to produce a string output. +func UnwrapAll(err error) string { + if err == nil { + return "" + } + + // Start error output + out := err.Error() + err = Unwrap(err) + + // Unwrap and append each + for err != nil { + out += ": " + err.Error() + err = Unwrap(err) + } + + return out +} + // stringError is the simplest ErrorContext implementation type stringError string diff --git a/vendor/codeberg.org/gruf/go-logger/clock.go b/vendor/codeberg.org/gruf/go-logger/clock.go index 5e6f877f0..aed97c339 100644 --- a/vendor/codeberg.org/gruf/go-logger/clock.go +++ b/vendor/codeberg.org/gruf/go-logger/clock.go @@ -12,7 +12,7 @@ var ( clockOnce = sync.Once{} ) -// startClock starts the global nowish clock +// startClock starts the global nowish clock. func startClock() { clockOnce.Do(func() { clock.Start(time.Millisecond * 10) diff --git a/vendor/codeberg.org/gruf/go-logger/default.go b/vendor/codeberg.org/gruf/go-logger/default.go index e2932e733..0da1f6a66 100644 --- a/vendor/codeberg.org/gruf/go-logger/default.go +++ b/vendor/codeberg.org/gruf/go-logger/default.go @@ -10,78 +10,78 @@ var ( instanceOnce = sync.Once{} ) -// Default returns the default Logger instance +// Default returns the default Logger instance. func Default() *Logger { instanceOnce.Do(func() { instance = New(os.Stdout) }) return instance } -// Debug prints the provided arguments with the debug prefix to the global Logger instance +// Debug prints the provided arguments with the debug prefix to the global Logger instance. func Debug(a ...interface{}) { Default().Debug(a...) } -// Debugf prints the provided format string and arguments with the debug prefix to the global Logger instance +// Debugf prints the provided format string and arguments with the debug prefix to the global Logger instance. func Debugf(s string, a ...interface{}) { Default().Debugf(s, a...) } -// Info prints the provided arguments with the info prefix to the global Logger instance +// Info prints the provided arguments with the info prefix to the global Logger instance. func Info(a ...interface{}) { Default().Info(a...) } -// Infof prints the provided format string and arguments with the info prefix to the global Logger instance +// Infof prints the provided format string and arguments with the info prefix to the global Logger instance. func Infof(s string, a ...interface{}) { Default().Infof(s, a...) } -// Warn prints the provided arguments with the warn prefix to the global Logger instance +// Warn prints the provided arguments with the warn prefix to the global Logger instance. func Warn(a ...interface{}) { Default().Warn(a...) } -// Warnf prints the provided format string and arguments with the warn prefix to the global Logger instance +// Warnf prints the provided format string and arguments with the warn prefix to the global Logger instance. func Warnf(s string, a ...interface{}) { Default().Warnf(s, a...) } -// Error prints the provided arguments with the error prefix to the global Logger instance +// Error prints the provided arguments with the error prefix to the global Logger instance. func Error(a ...interface{}) { Default().Error(a...) } -// Errorf prints the provided format string and arguments with the error prefix to the global Logger instance +// Errorf prints the provided format string and arguments with the error prefix to the global Logger instance. func Errorf(s string, a ...interface{}) { Default().Errorf(s, a...) } -// Fatal prints the provided arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1) +// Fatal prints the provided arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1). func Fatal(a ...interface{}) { Default().Fatal(a...) } -// Fatalf prints the provided format string and arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1) +// Fatalf prints the provided format string and arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1). func Fatalf(s string, a ...interface{}) { Default().Fatalf(s, a...) } -// Log prints the provided arguments with the supplied log level to the global Logger instance +// Log prints the provided arguments with the supplied log level to the global Logger instance. func Log(lvl LEVEL, a ...interface{}) { Default().Log(lvl, a...) } -// Logf prints the provided format string and arguments with the supplied log level to the global Logger instance +// Logf prints the provided format string and arguments with the supplied log level to the global Logger instance. func Logf(lvl LEVEL, s string, a ...interface{}) { Default().Logf(lvl, s, a...) } -// Print simply prints provided arguments to the global Logger instance +// Print simply prints provided arguments to the global Logger instance. func Print(a ...interface{}) { Default().Print(a...) } -// Printf simply prints provided the provided format string and arguments to the global Logger instance +// Printf simply prints provided the provided format string and arguments to the global Logger instance. func Printf(s string, a ...interface{}) { Default().Printf(s, a...) } diff --git a/vendor/codeberg.org/gruf/go-logger/entry.go b/vendor/codeberg.org/gruf/go-logger/entry.go index f2fe293aa..aad4b4885 100644 --- a/vendor/codeberg.org/gruf/go-logger/entry.go +++ b/vendor/codeberg.org/gruf/go-logger/entry.go @@ -7,7 +7,7 @@ import ( "codeberg.org/gruf/go-bytes" ) -// Entry defines an entry in the log +// Entry defines an entry in the log, it is NOT safe for concurrent use type Entry struct { ctx context.Context lvl LEVEL @@ -187,13 +187,34 @@ func (e *Entry) Fields(fields map[string]interface{}) *Entry { return e } -// Msg appends the formatted final message to the log and calls .Send() +// Value appends the given value to the log entry formatted as a value, without a key. +func (e *Entry) Value(value interface{}) *Entry { + e.log.Format.AppendValue(e.buf, value) + e.buf.WriteByte(' ') + return e +} + +// Values appends the given values to the log entry formatted as values, without a key. +func (e *Entry) Values(values ...interface{}) *Entry { + e.log.Format.AppendValues(e.buf, values) + e.buf.WriteByte(' ') + return e +} + +// Args appends the given args formatted using the log formatter (usually faster than printf) without any key-value / value formatting. +func (e *Entry) Args(a ...interface{}) *Entry { + e.log.Format.AppendArgs(e.buf, a) + e.buf.WriteByte(' ') + return e +} + +// Msg appends the fmt.Sprint() formatted final message to the log and calls .Send() func (e *Entry) Msg(a ...interface{}) { e.log.Format.AppendMsg(e.buf, a...) e.Send() } -// Msgf appends the formatted final message to the log and calls .Send() +// Msgf appends the fmt.Sprintf() formatted final message to the log and calls .Send() func (e *Entry) Msgf(s string, a ...interface{}) { e.log.Format.AppendMsgf(e.buf, s, a...) e.Send() @@ -210,7 +231,7 @@ func (e *Entry) Send() { return } - // Final new line + // Ensure a final new line if e.buf.B[e.buf.Len()-1] != '\n' { e.buf.WriteByte('\n') } diff --git a/vendor/codeberg.org/gruf/go-logger/format.go b/vendor/codeberg.org/gruf/go-logger/format.go index 214773ff3..234cf0b2c 100644 --- a/vendor/codeberg.org/gruf/go-logger/format.go +++ b/vendor/codeberg.org/gruf/go-logger/format.go @@ -1,9 +1,6 @@ package logger import ( - "fmt" - "reflect" - "strconv" "time" "codeberg.org/gruf/go-bytes" @@ -14,627 +11,78 @@ var _ LogFormat = &TextFormat{} // LogFormat defines a method of formatting log entries type LogFormat interface { + // AppendLevel appends given log level to the log buffer AppendLevel(buf *bytes.Buffer, lvl LEVEL) + + // AppendTimestamp appends given time format string to the log buffer AppendTimestamp(buf *bytes.Buffer, fmtNow string) + + // AppendField appends given key-value pair to the log buffer AppendField(buf *bytes.Buffer, key string, value interface{}) + + // AppendFields appends given key-values pairs to the log buffer AppendFields(buf *bytes.Buffer, fields map[string]interface{}) + + // AppendValue appends given interface formatted as value to the log buffer + AppendValue(buf *bytes.Buffer, value interface{}) + + // AppendValues appends given interfaces formatted as values to the log buffer + AppendValues(buf *bytes.Buffer, slice []interface{}) + + // AppendArgs appends given interfaces raw to the log buffer + AppendArgs(buf *bytes.Buffer, args []interface{}) + + // AppendByteField appends given byte value as key-value pair to the log buffer AppendByteField(buf *bytes.Buffer, key string, value byte) + + // AppendBytesField appends given byte slice value as key-value pair to the log buffer AppendBytesField(buf *bytes.Buffer, key string, value []byte) + + // AppendStringField appends given string value as key-value pair to the log buffer AppendStringField(buf *bytes.Buffer, key string, value string) + + // AppendStringsField appends given string slice value as key-value pair to the log buffer AppendStringsField(buf *bytes.Buffer, key string, value []string) + + // AppendBoolField appends given bool value as key-value pair to the log buffer AppendBoolField(buf *bytes.Buffer, key string, value bool) + + // AppendBoolsField appends given bool slice value as key-value pair to the log buffer AppendBoolsField(buf *bytes.Buffer, key string, value []bool) + + // AppendIntField appends given int value as key-value pair to the log buffer AppendIntField(buf *bytes.Buffer, key string, value int) + + // AppendIntsField appends given int slice value as key-value pair to the log buffer AppendIntsField(buf *bytes.Buffer, key string, value []int) + + // AppendUintField appends given uint value as key-value pair to the log buffer AppendUintField(buf *bytes.Buffer, key string, value uint) + + // AppendUintsField appends given uint slice value as key-value pair to the log buffer AppendUintsField(buf *bytes.Buffer, key string, value []uint) + + // AppendFloatField appends given float value as key-value pair to the log buffer AppendFloatField(buf *bytes.Buffer, key string, value float64) + + // AppendFloatsField appends given float slice value as key-value pair to the log buffer AppendFloatsField(buf *bytes.Buffer, key string, value []float64) + + // AppendTimeField appends given time value as key-value pair to the log buffer AppendTimeField(buf *bytes.Buffer, key string, value time.Time) + + // AppendTimesField appends given time slice value as key-value pair to the log buffer AppendTimesField(buf *bytes.Buffer, key string, value []time.Time) + + // AppendDurationField appends given duration value as key-value pair to the log buffer AppendDurationField(buf *bytes.Buffer, key string, value time.Duration) + + // AppendDurationsField appends given duration slice value as key-value pair to the log buffer AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration) + + // AppendMsg appends given msg as key-value pair to the log buffer using fmt.Sprint(...) formatting AppendMsg(buf *bytes.Buffer, a ...interface{}) + + // AppendMsgf appends given msg format string as key-value pair to the log buffer using fmt.Sprintf(...) formatting AppendMsgf(buf *bytes.Buffer, s string, a ...interface{}) } - -// TextFormat is the default LogFormat implementation, with very similar formatting to logfmt -type TextFormat struct { - // Strict defines whether to use strict key-value pair formatting, - // i.e. should the level, timestamp and msg be formatted as key-value pairs - // or simply be printed as-is - Strict bool - - // Levels defines the map of log LEVELs to level strings this LogFormat will use - Levels Levels -} - -// NewLogFmt returns a newly set LogFmt object, with DefaultLevels() set -func NewLogFmt(strict bool) *TextFormat { - return &TextFormat{ - Strict: strict, - Levels: DefaultLevels(), - } -} - -// appendReflectValue will safely append a reflected value -func appendReflectValue(buf *bytes.Buffer, v reflect.Value, isKey bool) { - switch v.Kind() { - case reflect.Slice: - appendSliceType(buf, v) - case reflect.Map: - appendMapType(buf, v) - case reflect.Struct: - appendStructType(buf, v) - case reflect.Ptr: - if v.IsNil() { - appendNil(buf) - } else { - appendIface(buf, v.Elem().Interface(), isKey) - } - default: - // Just print reflect string - appendString(buf, v.String()) - } -} - -// appendKey should only be used in the case of directly setting key-value pairs, -// not in the case of appendMapType, appendStructType -func appendKey(buf *bytes.Buffer, key string) { - if len(key) > 0 { - // Only write key if here - appendStringUnquoted(buf, key) - buf.WriteByte('=') - } -} - -// appendSlice performs provided fn and writes square brackets [] around it -func appendSlice(buf *bytes.Buffer, fn func()) { - buf.WriteByte('[') - fn() - buf.WriteByte(']') -} - -// appendMap performs provided fn and writes curly braces {} around it -func appendMap(buf *bytes.Buffer, fn func()) { - buf.WriteByte('{') - fn() - buf.WriteByte('}') -} - -// appendStruct performs provided fn and writes curly braces {} around it -func appendStruct(buf *bytes.Buffer, fn func()) { - buf.WriteByte('{') - fn() - buf.WriteByte('}') -} - -// appendNil writes a nil value placeholder to buf -func appendNil(buf *bytes.Buffer) { - buf.WriteString(``) -} - -// appendByte writes a single byte to buf -func appendByte(buf *bytes.Buffer, b byte) { - buf.WriteByte(b) -} - -// appendBytes writes a quoted byte slice to buf -func appendBytes(buf *bytes.Buffer, b []byte) { - buf.WriteByte('"') - buf.Write(b) - buf.WriteByte('"') -} - -// appendBytesUnquoted writes a byte slice to buf as-is -func appendBytesUnquoted(buf *bytes.Buffer, b []byte) { - buf.Write(b) -} - -// appendString writes a quoted string to buf -func appendString(buf *bytes.Buffer, s string) { - buf.WriteByte('"') - buf.WriteString(s) - buf.WriteByte('"') -} - -// appendStringUnquoted writes a string as-is to buf -func appendStringUnquoted(buf *bytes.Buffer, s string) { - buf.WriteString(s) -} - -// appendStringSlice writes a slice of strings to buf -func appendStringSlice(buf *bytes.Buffer, s []string) { - appendSlice(buf, func() { - for _, s := range s { - appendString(buf, s) - buf.WriteByte(',') - } - if len(s) > 0 { - buf.Truncate(1) - } - }) -} - -// appendBool writes a formatted bool to buf -func appendBool(buf *bytes.Buffer, b bool) { - buf.B = strconv.AppendBool(buf.B, b) -} - -// appendBool writes a slice of formatted bools to buf -func appendBoolSlice(buf *bytes.Buffer, b []bool) { - appendSlice(buf, func() { - // Write elements - for _, b := range b { - appendBool(buf, b) - buf.WriteByte(',') - } - - // Drop last comma - if len(b) > 0 { - buf.Truncate(1) - } - }) -} - -// appendInt writes a formatted int to buf -func appendInt(buf *bytes.Buffer, i int64) { - buf.B = strconv.AppendInt(buf.B, i, 10) -} - -// appendIntSlice writes a slice of formatted int to buf -func appendIntSlice(buf *bytes.Buffer, i []int) { - appendSlice(buf, func() { - // Write elements - for _, i := range i { - appendInt(buf, int64(i)) - buf.WriteByte(',') - } - - // Drop last comma - if len(i) > 0 { - buf.Truncate(1) - } - }) -} - -// appendUint writes a formatted uint to buf -func appendUint(buf *bytes.Buffer, u uint64) { - buf.B = strconv.AppendUint(buf.B, u, 10) -} - -// appendUintSlice writes a slice of formatted uint to buf -func appendUintSlice(buf *bytes.Buffer, u []uint) { - appendSlice(buf, func() { - // Write elements - for _, u := range u { - appendUint(buf, uint64(u)) - buf.WriteByte(',') - } - - // Drop last comma - if len(u) > 0 { - buf.Truncate(1) - } - }) -} - -// appendFloat writes a formatted float to buf -func appendFloat(buf *bytes.Buffer, f float64) { - buf.B = strconv.AppendFloat(buf.B, f, 'G', -1, 64) -} - -// appendFloatSlice writes a slice formatted floats to buf -func appendFloatSlice(buf *bytes.Buffer, f []float64) { - appendSlice(buf, func() { - // Write elements - for _, f := range f { - appendFloat(buf, f) - buf.WriteByte(',') - } - - // Drop last comma - if len(f) > 0 { - buf.Truncate(1) - } - }) -} - -// appendTime writes a formatted, quoted time string to buf -func appendTime(buf *bytes.Buffer, t time.Time) { - buf.WriteByte('"') - buf.B = t.AppendFormat(buf.B, time.RFC1123) - buf.WriteByte('"') -} - -// appendTimeUnquoted writes a formatted time string to buf as-is -func appendTimeUnquoted(buf *bytes.Buffer, t time.Time) { - buf.B = t.AppendFormat(buf.B, time.RFC1123) -} - -// appendTimeSlice writes a slice of formatted time strings to buf -func appendTimeSlice(buf *bytes.Buffer, t []time.Time) { - appendSlice(buf, func() { - // Write elements - for _, t := range t { - appendTime(buf, t) - buf.WriteByte(',') - } - - // Drop last comma - if len(t) > 0 { - buf.Truncate(1) - } - }) -} - -// appendDuration writes a formatted, quoted duration string to buf -func appendDuration(buf *bytes.Buffer, d time.Duration) { - appendString(buf, d.String()) -} - -// appendDurationUnquoted writes a formatted duration string to buf as-is -func appendDurationUnquoted(buf *bytes.Buffer, d time.Duration) { - appendStringUnquoted(buf, d.String()) -} - -// appendDurationSlice writes a slice of formatted, quoted duration strings to buf -func appendDurationSlice(buf *bytes.Buffer, d []time.Duration) { - appendSlice(buf, func() { - // Write elements - for _, d := range d { - appendString(buf, d.String()) - buf.WriteByte(',') - } - - // Drop last comma - if len(d) > 0 { - buf.Truncate(1) - } - }) -} - -// appendIface parses and writes a formatted interface value to buf -func appendIface(buf *bytes.Buffer, i interface{}, isKey bool) { - switch i := i.(type) { - case nil: - appendNil(buf) - case byte: - appendByte(buf, i) - case []byte: - if isKey { - // Keys don't get quoted - appendBytesUnquoted(buf, i) - } else { - appendBytes(buf, i) - } - case string: - if isKey { - // Keys don't get quoted - appendStringUnquoted(buf, i) - } else { - appendString(buf, i) - } - case []string: - appendStringSlice(buf, i) - case int: - appendInt(buf, int64(i)) - case int8: - appendInt(buf, int64(i)) - case int16: - appendInt(buf, int64(i)) - case int32: - appendInt(buf, int64(i)) - case int64: - appendInt(buf, i) - case []int: - appendIntSlice(buf, i) - case uint: - appendUint(buf, uint64(i)) - case uint16: - appendUint(buf, uint64(i)) - case uint32: - appendUint(buf, uint64(i)) - case uint64: - appendUint(buf, i) - case []uint: - appendUintSlice(buf, i) - case float32: - appendFloat(buf, float64(i)) - case float64: - appendFloat(buf, i) - case []float64: - appendFloatSlice(buf, i) - case bool: - appendBool(buf, i) - case []bool: - appendBoolSlice(buf, i) - case time.Time: - if isKey { - // Keys don't get quoted - appendTimeUnquoted(buf, i) - } else { - appendTime(buf, i) - } - case *time.Time: - if isKey { - // Keys don't get quoted - appendTimeUnquoted(buf, *i) - } else { - appendTime(buf, *i) - } - case []time.Time: - appendTimeSlice(buf, i) - case time.Duration: - if isKey { - // Keys dont get quoted - appendDurationUnquoted(buf, i) - } else { - appendDuration(buf, i) - } - case []time.Duration: - appendDurationSlice(buf, i) - case map[string]interface{}: - appendIfaceMap(buf, i) - case error: - if isKey { - // Keys don't get quoted - appendStringUnquoted(buf, i.Error()) - } else { - appendString(buf, i.Error()) - } - case fmt.Stringer: - if isKey { - // Keys don't get quoted - appendStringUnquoted(buf, i.String()) - } else { - appendString(buf, i.String()) - } - default: - // If we reached here, we need reflection. - appendReflectValue(buf, reflect.ValueOf(i), isKey) - } -} - -// appendIfaceMap writes a map of key-value pairs (as a set of fields) to buf -func appendIfaceMap(buf *bytes.Buffer, v map[string]interface{}) { - appendMap(buf, func() { - // Write map pairs! - for key, value := range v { - appendStringUnquoted(buf, key) - buf.WriteByte('=') - appendIface(buf, value, false) - buf.WriteByte(' ') - } - - // Drop last space - if len(v) > 0 { - buf.Truncate(1) - } - }) -} - -// appendSliceType writes a slice of unknown type (parsed by reflection) to buf -func appendSliceType(buf *bytes.Buffer, v reflect.Value) { - n := v.Len() - appendSlice(buf, func() { - for i := 0; i < n; i++ { - appendIface(buf, v.Index(i).Interface(), false) - buf.WriteByte(',') - } - - // Drop last comma - if n > 0 { - buf.Truncate(1) - } - }) -} - -// appendMapType writes a map of unknown types (parsed by reflection) to buf -func appendMapType(buf *bytes.Buffer, v reflect.Value) { - // Get a map iterator - r := v.MapRange() - n := v.Len() - - // Now begin creating the map! - appendMap(buf, func() { - // Iterate pairs - for r.Next() { - appendIface(buf, r.Key().Interface(), true) - buf.WriteByte('=') - appendIface(buf, r.Value().Interface(), false) - buf.WriteByte(' ') - } - - // Drop last space - if n > 0 { - buf.Truncate(1) - } - }) -} - -// appendStructType writes a struct (as a set of key-value fields) to buf -func appendStructType(buf *bytes.Buffer, v reflect.Value) { - // Get value type & no. fields - t := v.Type() - n := v.NumField() - w := 0 - - // Iter and write struct fields - appendStruct(buf, func() { - for i := 0; i < n; i++ { - vfield := v.Field(i) - - // Check for unexported fields - if !vfield.CanInterface() { - continue - } - - // Append the struct member as field key-value - appendStringUnquoted(buf, t.Field(i).Name) - buf.WriteByte('=') - appendIface(buf, vfield.Interface(), false) - buf.WriteByte(' ') - - // Iter written count - w++ - } - - // Drop last space - if w > 0 { - buf.Truncate(1) - } - }) -} - -func (f *TextFormat) AppendLevel(buf *bytes.Buffer, lvl LEVEL) { - if f.Strict { - // Strict format, append level key - buf.WriteString(`level=`) - buf.WriteString(f.Levels.LevelString(lvl)) - return - } - - // Write level string - buf.WriteByte('[') - buf.WriteString(f.Levels.LevelString(lvl)) - buf.WriteByte(']') -} - -func (f *TextFormat) AppendTimestamp(buf *bytes.Buffer, now string) { - if f.Strict { - // Strict format, use key and quote - appendStringUnquoted(buf, `time`) - buf.WriteByte('=') - appendString(buf, now) - return - } - - // Write time as-is - appendStringUnquoted(buf, now) -} - -func (f *TextFormat) AppendField(buf *bytes.Buffer, key string, value interface{}) { - appendKey(buf, key) - appendIface(buf, value, false) -} - -func (f *TextFormat) AppendFields(buf *bytes.Buffer, fields map[string]interface{}) { - // Append individual fields - for key, value := range fields { - appendKey(buf, key) - appendIface(buf, value, false) - buf.WriteByte(' ') - } - - // Drop last space - if len(fields) > 0 { - buf.Truncate(1) - } -} - -func (f *TextFormat) AppendByteField(buf *bytes.Buffer, key string, value byte) { - appendKey(buf, key) - appendByte(buf, value) -} - -func (f *TextFormat) AppendBytesField(buf *bytes.Buffer, key string, value []byte) { - appendKey(buf, key) - appendBytes(buf, value) -} - -func (f *TextFormat) AppendStringField(buf *bytes.Buffer, key string, value string) { - appendKey(buf, key) - appendString(buf, value) -} - -func (f *TextFormat) AppendStringsField(buf *bytes.Buffer, key string, value []string) { - appendKey(buf, key) - appendStringSlice(buf, value) -} - -func (f *TextFormat) AppendBoolField(buf *bytes.Buffer, key string, value bool) { - appendKey(buf, key) - appendBool(buf, value) -} - -func (f *TextFormat) AppendBoolsField(buf *bytes.Buffer, key string, value []bool) { - appendKey(buf, key) - appendBoolSlice(buf, value) -} - -func (f *TextFormat) AppendIntField(buf *bytes.Buffer, key string, value int) { - appendKey(buf, key) - appendInt(buf, int64(value)) -} - -func (f *TextFormat) AppendIntsField(buf *bytes.Buffer, key string, value []int) { - appendKey(buf, key) - appendIntSlice(buf, value) -} - -func (f *TextFormat) AppendUintField(buf *bytes.Buffer, key string, value uint) { - appendKey(buf, key) - appendUint(buf, uint64(value)) -} - -func (f *TextFormat) AppendUintsField(buf *bytes.Buffer, key string, value []uint) { - appendKey(buf, key) - appendUintSlice(buf, value) -} - -func (f *TextFormat) AppendFloatField(buf *bytes.Buffer, key string, value float64) { - appendKey(buf, key) - appendFloat(buf, value) -} - -func (f *TextFormat) AppendFloatsField(buf *bytes.Buffer, key string, value []float64) { - appendKey(buf, key) - appendFloatSlice(buf, value) -} - -func (f *TextFormat) AppendTimeField(buf *bytes.Buffer, key string, value time.Time) { - appendKey(buf, key) - appendTime(buf, value) -} - -func (f *TextFormat) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time) { - appendKey(buf, key) - appendTimeSlice(buf, value) -} - -func (f *TextFormat) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration) { - appendKey(buf, key) - appendDuration(buf, value) -} - -func (f *TextFormat) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration) { - appendKey(buf, key) - appendDurationSlice(buf, value) -} - -func (f *TextFormat) AppendMsg(buf *bytes.Buffer, a ...interface{}) { - if f.Strict { - // Strict format, use key and quote - buf.WriteString(`msg="`) - fmt.Fprint(buf, a...) - buf.WriteByte('"') - return - } - - // Write message as-is - fmt.Fprint(buf, a...) -} - -func (f *TextFormat) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{}) { - if f.Strict { - // Strict format, use key and quote - buf.WriteString(`msg="`) - fmt.Fprintf(buf, s, a...) - buf.WriteByte('"') - return - } - - // Write message as-is - fmt.Fprintf(buf, s, a...) -} diff --git a/vendor/codeberg.org/gruf/go-logger/format_text.go b/vendor/codeberg.org/gruf/go-logger/format_text.go new file mode 100644 index 000000000..e2380884b --- /dev/null +++ b/vendor/codeberg.org/gruf/go-logger/format_text.go @@ -0,0 +1,915 @@ +package logger + +import ( + stdfmt "fmt" + "reflect" + "strconv" + "time" + "unsafe" + + "codeberg.org/gruf/go-bytes" +) + +// DefaultTextFormat is the default TextFormat instance +var DefaultTextFormat = TextFormat{ + Strict: false, + MaxDepth: 5, + Levels: DefaultLevels(), + TimeFormat: time.RFC1123, +} + +// TextFormat is the default LogFormat implementation, with very similar formatting to logfmt +type TextFormat struct { + // Strict defines whether to use strict key-value pair formatting, i.e. should the level + // timestamp and msg be formatted as key-value pairs (with forced quoting for msg) + Strict bool + + // MaxDepth specifies the max depth of fields the formatter will iterate + MaxDepth uint8 + + // Levels defines the map of log LEVELs to level strings + Levels Levels + + // TimeFormat specifies the time formatting to use + TimeFormat string +} + +// fmt returns a new format instance based on receiver TextFormat and given buffer +func (f TextFormat) fmt(buf *bytes.Buffer) format { + return format{ + isKey: false, + depth: 0, + txt: f, + buf: buf, + } +} + +func (f TextFormat) AppendLevel(buf *bytes.Buffer, lvl LEVEL) { + if f.Strict { + // Strict format, append level key + buf.WriteString(`level=`) + buf.WriteString(f.Levels.LevelString(lvl)) + return + } + + // Write level string + buf.WriteByte('[') + buf.WriteString(f.Levels.LevelString(lvl)) + buf.WriteByte(']') +} + +func (f TextFormat) AppendTimestamp(buf *bytes.Buffer, now string) { + if f.Strict { + // Strict format, use key and quote + buf.WriteString(`time=`) + appendString(f.fmt(buf), now) + return + } + + // Write time as-is + buf.WriteString(now) +} + +func (f TextFormat) AppendField(buf *bytes.Buffer, key string, value interface{}) { + appendKey(buf, key) + appendIfaceOrRValue(f.fmt(buf), value) +} + +func (f TextFormat) AppendFields(buf *bytes.Buffer, fields map[string]interface{}) { + fmt := f.fmt(buf) + + // Append individual fields + for key, value := range fields { + appendKey(buf, key) + appendIfaceOrRValue(fmt, value) + buf.WriteByte(' ') + } + + // Drop last space + if len(fields) > 0 { + buf.Truncate(1) + } +} + +func (f TextFormat) AppendValue(buf *bytes.Buffer, value interface{}) { + appendIfaceOrRValue(f.fmt(buf).IsKey(true), value) +} + +func (f TextFormat) AppendValues(buf *bytes.Buffer, values []interface{}) { + // Prepare formatter + fmt := f.fmt(buf).IsKey(true) + + // Append each of the values + for _, value := range values { + appendIfaceOrRValue(fmt, value) + buf.WriteByte(' ') + } + + // Drop last space + if len(values) > 0 { + buf.Truncate(1) + } +} + +func (f TextFormat) AppendArgs(buf *bytes.Buffer, args []interface{}) { + // Prepare formatter + fmt := f.fmt(buf).IsKey(true).IsRaw(true) + + // Append each of the values + for _, arg := range args { + appendIfaceOrRValue(fmt, arg) + buf.WriteByte(' ') + } + + // Drop last space + if len(args) > 0 { + buf.Truncate(1) + } +} + +func (f TextFormat) AppendByteField(buf *bytes.Buffer, key string, value byte) { + appendKey(buf, key) + appendByte(f.fmt(buf), value) +} + +func (f TextFormat) AppendBytesField(buf *bytes.Buffer, key string, value []byte) { + appendKey(buf, key) + appendBytes(f.fmt(buf), value) +} + +func (f TextFormat) AppendStringField(buf *bytes.Buffer, key string, value string) { + appendKey(buf, key) + appendString(f.fmt(buf), value) +} + +func (f TextFormat) AppendStringsField(buf *bytes.Buffer, key string, value []string) { + appendKey(buf, key) + appendStringSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendBoolField(buf *bytes.Buffer, key string, value bool) { + appendKey(buf, key) + appendBool(f.fmt(buf), value) +} + +func (f TextFormat) AppendBoolsField(buf *bytes.Buffer, key string, value []bool) { + appendKey(buf, key) + appendBoolSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendIntField(buf *bytes.Buffer, key string, value int) { + appendKey(buf, key) + appendInt(f.fmt(buf), int64(value)) +} + +func (f TextFormat) AppendIntsField(buf *bytes.Buffer, key string, value []int) { + appendKey(buf, key) + appendIntSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendUintField(buf *bytes.Buffer, key string, value uint) { + appendKey(buf, key) + appendUint(f.fmt(buf), uint64(value)) +} + +func (f TextFormat) AppendUintsField(buf *bytes.Buffer, key string, value []uint) { + appendKey(buf, key) + appendUintSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendFloatField(buf *bytes.Buffer, key string, value float64) { + appendKey(buf, key) + appendFloat(f.fmt(buf), value) +} + +func (f TextFormat) AppendFloatsField(buf *bytes.Buffer, key string, value []float64) { + appendKey(buf, key) + appendFloatSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendTimeField(buf *bytes.Buffer, key string, value time.Time) { + appendKey(buf, key) + appendTime(f.fmt(buf), value) +} + +func (f TextFormat) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time) { + appendKey(buf, key) + appendTimeSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration) { + appendKey(buf, key) + appendDuration(f.fmt(buf), value) +} + +func (f TextFormat) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration) { + appendKey(buf, key) + appendDurationSlice(f.fmt(buf), value) +} + +func (f TextFormat) AppendMsg(buf *bytes.Buffer, a ...interface{}) { + if f.Strict { + // Strict format, use key and quote + buf.WriteString(`msg=`) + buf.B = strconv.AppendQuote(buf.B, stdfmt.Sprint(a...)) + return + } + + // Write message as-is + stdfmt.Fprint(buf, a...) +} + +func (f TextFormat) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{}) { + if f.Strict { + // Strict format, use key and quote + buf.WriteString(`msg=`) + buf.B = strconv.AppendQuote(buf.B, stdfmt.Sprintf(s, a...)) + return + } + + // Write message as-is + stdfmt.Fprintf(buf, s, a...) +} + +// format is the object passed among the append___ formatting functions +type format struct { + raw bool + isKey bool + depth uint8 + txt TextFormat + buf *bytes.Buffer +} + +// IsKey returns format instance with key set to value +func (f format) IsKey(is bool) format { + return format{ + raw: f.raw, + isKey: is, + depth: f.depth, + txt: f.txt, + buf: f.buf, + } +} + +// IsRaw returns format instance with raw set to value +func (f format) IsRaw(is bool) format { + return format{ + raw: is, + isKey: f.isKey, + depth: f.depth, + txt: f.txt, + buf: f.buf, + } +} + +// IncrDepth returns format instance with depth incremented +func (f format) IncrDepth() format { + return format{ + raw: f.raw, + isKey: f.isKey, + depth: f.depth + 1, + txt: f.txt, + buf: f.buf, + } +} + +// appendByte writes a single byte to buf +func appendByte(fmt format, b byte) { + fmt.buf.WriteByte(b) +} + +// appendBytes writes a quoted byte slice to buf +func appendBytes(fmt format, b []byte) { + if !fmt.isKey && b == nil { + // Values CAN be nil formatted + appendNilType(fmt, `[]byte`) + } else { + appendString(fmt, bytes.BytesToString(b)) + } +} + +// appendString writes an escaped, double-quoted string to buf +func appendString(fmt format, s string) { + if !fmt.raw { + // Only handle quoting if NOT raw + if !strconv.CanBackquote(s) || !fmt.isKey { + // All non-keys and multiline keys get quoted + escaped + fmt.buf.B = strconv.AppendQuote(fmt.buf.B, s) + return + } else if containsSpaceOrTab(s) { + // Key containing spaces/tabs, quote this + fmt.buf.WriteByte('"') + fmt.buf.WriteString(s) + fmt.buf.WriteByte('"') + return + } + } + + // Safe to leave unquoted + fmt.buf.WriteString(s) +} + +// appendStringSlice writes a slice of strings to buf +func appendStringSlice(fmt format, s []string) { + // Check for nil slice + if s == nil { + appendNilType(fmt, `[]string`) + return + } + + fmt.buf.WriteByte('[') + + // Prepare formatter + fmt = fmt.IsKey(false) + + // Write elements + for _, s := range s { + appendString(fmt, s) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(s) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendBool writes a formatted bool to buf +func appendBool(fmt format, b bool) { + fmt.buf.B = strconv.AppendBool(fmt.buf.B, b) +} + +// appendBool writes a slice of formatted bools to buf +func appendBoolSlice(fmt format, b []bool) { + // Check for nil slice + if b == nil { + appendNilType(fmt, `[]bool`) + return + } + + fmt.buf.WriteByte('[') + + // Write elements + for _, b := range b { + appendBool(fmt, b) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(b) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendInt writes a formatted int to buf +func appendInt(fmt format, i int64) { + fmt.buf.B = strconv.AppendInt(fmt.buf.B, i, 10) +} + +// appendIntSlice writes a slice of formatted int to buf +func appendIntSlice(fmt format, i []int) { + // Check for nil slice + if i == nil { + appendNilType(fmt, `[]int`) + return + } + + fmt.buf.WriteByte('[') + + // Write elements + for _, i := range i { + appendInt(fmt, int64(i)) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(i) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendUint writes a formatted uint to buf +func appendUint(fmt format, u uint64) { + fmt.buf.B = strconv.AppendUint(fmt.buf.B, u, 10) +} + +// appendUintSlice writes a slice of formatted uint to buf +func appendUintSlice(fmt format, u []uint) { + // Check for nil slice + if u == nil { + appendNilType(fmt, `[]uint`) + return + } + + fmt.buf.WriteByte('[') + + // Write elements + for _, u := range u { + appendUint(fmt, uint64(u)) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(u) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendFloat writes a formatted float to buf +func appendFloat(fmt format, f float64) { + fmt.buf.B = strconv.AppendFloat(fmt.buf.B, f, 'G', -1, 64) +} + +// appendFloatSlice writes a slice formatted floats to buf +func appendFloatSlice(fmt format, f []float64) { + // Check for nil slice + if f == nil { + appendNilType(fmt, `[]float64`) + return + } + + fmt.buf.WriteByte('[') + + // Write elements + for _, f := range f { + appendFloat(fmt, f) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(f) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendTime writes a formatted, quoted time string to buf +func appendTime(fmt format, t time.Time) { + appendString(fmt.IsKey(true), t.Format(fmt.txt.TimeFormat)) +} + +// appendTimeSlice writes a slice of formatted time strings to buf +func appendTimeSlice(fmt format, t []time.Time) { + // Check for nil slice + if t == nil { + appendNilType(fmt, `[]time.Time`) + return + } + + fmt.buf.WriteByte('[') + + // Prepare formatter + fmt = fmt.IsKey(true) + + // Write elements + for _, t := range t { + appendString(fmt, t.Format(fmt.txt.TimeFormat)) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(t) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendDuration writes a formatted, quoted duration string to buf +func appendDuration(fmt format, d time.Duration) { + appendString(fmt.IsKey(true), d.String()) +} + +// appendDurationSlice writes a slice of formatted, quoted duration strings to buf +func appendDurationSlice(fmt format, d []time.Duration) { + // Check for nil slice + if d == nil { + appendNilType(fmt, `[]time.Duration`) + return + } + + fmt.buf.WriteByte('[') + + // Prepare formatter + fmt = fmt.IsKey(true) + + // Write elements + for _, d := range d { + appendString(fmt, d.String()) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(d) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendComplex writes a formatted complex128 to buf +func appendComplex(fmt format, c complex128) { + appendFloat(fmt, real(c)) + fmt.buf.WriteByte('+') + appendFloat(fmt, imag(c)) + fmt.buf.WriteByte('i') +} + +// appendComplexSlice writes a slice of formatted complex128s to buf +func appendComplexSlice(fmt format, c []complex128) { + // Check for nil slice + if c == nil { + appendNilType(fmt, `[]complex128`) + return + } + + fmt.buf.WriteByte('[') + + // Write elements + for _, c := range c { + appendComplex(fmt, c) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if len(c) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// notNil will safely check if 'v' is nil without dealing with weird Go interface nil bullshit. +func notNil(i interface{}) bool { + // cast to get fat pointer + e := *(*struct { + typeOf unsafe.Pointer // ignored + valueOf unsafe.Pointer + })(unsafe.Pointer(&i)) + + // check if value part is nil + return (e.valueOf != nil) +} + +// appendNilType will append a formatted nil of type 't' +func appendNilType(fmt format, t string) { + fmt.buf.WriteByte('(') + fmt.buf.WriteString(t) + fmt.buf.WriteString(`)()`) +} + +// appendNilValue will append a formatted nil of type fetched from value 'v' +func appendNilRValue(fmt format, v reflect.Value) { + appendNilType(fmt, v.Type().String()) +} + +// appendIfaceOrReflectValue will attempt to append as interface, falling back to reflection +func appendIfaceOrRValue(fmt format, i interface{}) { + // Check we haven't hit max + if fmt.depth >= fmt.txt.MaxDepth { + fmt.buf.WriteString("...") + return + } + + // Incr the depth + fmt = fmt.IncrDepth() + + // Attempt to append interface, fallback to reflect + if !appendIface(fmt, i) { + appendRValue(fmt, reflect.ValueOf(i)) + } +} + +// appendReflectValueOrIface will attempt to interface the reflect.Value, falling back to using this directly +func appendRValueOrIface(fmt format, v reflect.Value) { + // Check we haven't hit max + if fmt.depth >= fmt.txt.MaxDepth { + fmt.buf.WriteString("...") + return + } + + // Incr the depth + fmt = fmt.IncrDepth() + + // Attempt to interface reflect value, fallback to handling value itself + if !v.CanInterface() || !appendIface(fmt, v.Interface()) { + appendRValue(fmt, v) + } +} + +// appendIface parses and writes a formatted interface value to buf +func appendIface(fmt format, i interface{}) bool { + switch i := i.(type) { + case nil: + fmt.buf.WriteString(``) + case byte: + appendByte(fmt, i) + case []byte: + appendBytes(fmt, i) + case string: + appendString(fmt, i) + case []string: + appendStringSlice(fmt, i) + case int: + appendInt(fmt, int64(i)) + case int8: + appendInt(fmt, int64(i)) + case int16: + appendInt(fmt, int64(i)) + case int32: + appendInt(fmt, int64(i)) + case int64: + appendInt(fmt, i) + case []int: + appendIntSlice(fmt, i) + case uint: + appendUint(fmt, uint64(i)) + case uint16: + appendUint(fmt, uint64(i)) + case uint32: + appendUint(fmt, uint64(i)) + case uint64: + appendUint(fmt, i) + case []uint: + appendUintSlice(fmt, i) + case float32: + appendFloat(fmt, float64(i)) + case float64: + appendFloat(fmt, i) + case []float64: + appendFloatSlice(fmt, i) + case bool: + appendBool(fmt, i) + case []bool: + appendBoolSlice(fmt, i) + case time.Time: + appendTime(fmt, i) + case []time.Time: + appendTimeSlice(fmt, i) + case time.Duration: + appendDuration(fmt, i) + case []time.Duration: + appendDurationSlice(fmt, i) + case complex64: + appendComplex(fmt, complex128(i)) + case complex128: + appendComplex(fmt, i) + case []complex128: + appendComplexSlice(fmt, i) + case map[string]interface{}: + appendIfaceMap(fmt, i) + case error: + if notNil(i) /* use safer nil check */ { + appendString(fmt, i.Error()) + } else { + appendNilType(fmt, reflect.TypeOf(i).String()) + } + case stdfmt.Stringer: + if notNil(i) /* use safer nil check */ { + appendString(fmt, i.String()) + } else { + appendNilType(fmt, reflect.TypeOf(i).String()) + } + default: + return false // could not handle + } + + return true +} + +// appendReflectValue will safely append a reflected value +func appendRValue(fmt format, v reflect.Value) { + switch v.Kind() { + case reflect.Float32, reflect.Float64: + appendFloat(fmt, v.Float()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + appendInt(fmt, v.Int()) + case reflect.Uint8: + appendByte(fmt, uint8(v.Uint())) + case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + appendUint(fmt, v.Uint()) + case reflect.Bool: + appendBool(fmt, v.Bool()) + case reflect.Array: + appendArrayType(fmt, v) + case reflect.Slice: + appendSliceType(fmt, v) + case reflect.Map: + appendMapType(fmt, v) + case reflect.Struct: + appendStructType(fmt, v) + case reflect.Ptr: + if v.IsNil() { + appendNilRValue(fmt, v) + } else { + appendRValue(fmt, v.Elem()) + } + case reflect.UnsafePointer: + fmt.buf.WriteString("(unsafe.Pointer)") + fmt.buf.WriteByte('(') + if u := v.Pointer(); u != 0 { + fmt.buf.WriteString("0x") + fmt.buf.B = strconv.AppendUint(fmt.buf.B, uint64(u), 16) + } else { + fmt.buf.WriteString(``) + } + fmt.buf.WriteByte(')') + case reflect.Uintptr: + fmt.buf.WriteString("(uintptr)") + fmt.buf.WriteByte('(') + if u := v.Uint(); u != 0 { + fmt.buf.WriteString("0x") + fmt.buf.B = strconv.AppendUint(fmt.buf.B, u, 16) + } else { + fmt.buf.WriteString(``) + } + fmt.buf.WriteByte(')') + case reflect.String: + appendString(fmt, v.String()) + case reflect.Complex64, reflect.Complex128: + appendComplex(fmt, v.Complex()) + case reflect.Func, reflect.Chan, reflect.Interface: + if v.IsNil() { + appendNilRValue(fmt, v) + } else { + fmt.buf.WriteString(v.String()) + } + default: + fmt.buf.WriteString(v.String()) + } +} + +// appendIfaceMap writes a map of key-value pairs (as a set of fields) to buf +func appendIfaceMap(fmt format, v map[string]interface{}) { + // Catch nil map + if v == nil { + appendNilType(fmt, `map[string]interface{}`) + return + } + + fmt.buf.WriteByte('{') + + // Prepare formatters + fmtKey := fmt.IsKey(true) + fmtVal := fmt.IsKey(false) + + // Write map pairs! + for key, value := range v { + appendString(fmtKey, key) + fmt.buf.WriteByte('=') + appendIfaceOrRValue(fmtVal, value) + fmt.buf.WriteByte(' ') + } + + // Drop last space + if len(v) > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte('}') +} + +// appendArrayType writes an array of unknown type (parsed by reflection) to buf, unlike appendSliceType does NOT catch nil slice +func appendArrayType(fmt format, v reflect.Value) { + // get no. elements + n := v.Len() + + fmt.buf.WriteByte('[') + + // Prepare formatter + fmt = fmt.IsKey(false) + + // Write values + for i := 0; i < n; i++ { + appendRValueOrIface(fmt, v.Index(i)) + fmt.buf.WriteByte(',') + } + + // Drop last comma + if n > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte(']') +} + +// appendSliceType writes a slice of unknown type (parsed by reflection) to buf +func appendSliceType(fmt format, v reflect.Value) { + if v.IsNil() { + appendNilRValue(fmt, v) + } else { + appendArrayType(fmt, v) + } +} + +// appendMapType writes a map of unknown types (parsed by reflection) to buf +func appendMapType(fmt format, v reflect.Value) { + // Catch nil map + if v.IsNil() { + appendNilRValue(fmt, v) + return + } + + // Get a map iterator + r := v.MapRange() + n := v.Len() + + fmt.buf.WriteByte('{') + + // Prepare formatters + fmtKey := fmt.IsKey(true) + fmtVal := fmt.IsKey(false) + + // Iterate pairs + for r.Next() { + appendRValueOrIface(fmtKey, r.Key()) + fmt.buf.WriteByte('=') + appendRValueOrIface(fmtVal, r.Value()) + fmt.buf.WriteByte(' ') + } + + // Drop last space + if n > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte('}') +} + +// appendStructType writes a struct (as a set of key-value fields) to buf +func appendStructType(fmt format, v reflect.Value) { + // Get value type & no. fields + t := v.Type() + n := v.NumField() + w := 0 + + fmt.buf.WriteByte('{') + + // Prepare formatters + fmtKey := fmt.IsKey(true) + fmtVal := fmt.IsKey(false) + + // Iterate fields + for i := 0; i < n; i++ { + vfield := v.Field(i) + + if !vfield.CanInterface() { + // This is an unexported field + appendRValue(fmtVal, vfield) + } else { + // This is an exported field! + appendString(fmtKey, t.Field(i).Name) + fmt.buf.WriteByte('=') + appendRValueOrIface(fmtVal, vfield) + } + + // Iter written count + fmt.buf.WriteByte(' ') + w++ + } + + // Drop last space + if w > 0 { + fmt.buf.Truncate(1) + } + + fmt.buf.WriteByte('}') +} + +// appendKey should only be used in the case of directly setting key-value pairs, +// not in the case of appendMapType, appendStructType +func appendKey(buf *bytes.Buffer, key string) { + if len(key) > 0 { + if containsSpaceOrTab(key) { + // Key containing spaces/tabs, quote this + buf.WriteByte('"') + buf.WriteString(key) + buf.WriteByte('"') + } else { + // Key is safe to leave unquoted + buf.WriteString(key) + } + + // Write final '=' + buf.WriteByte('=') + } +} + +// containsSpaceOrTab checks if "s" contains space or tabs +func containsSpaceOrTab(s string) bool { + for _, r := range s { + if r == ' ' || r == '\t' { + return true + } + } + return false +} diff --git a/vendor/codeberg.org/gruf/go-logger/level.go b/vendor/codeberg.org/gruf/go-logger/level.go index cb0073240..76c9ed2b3 100644 --- a/vendor/codeberg.org/gruf/go-logger/level.go +++ b/vendor/codeberg.org/gruf/go-logger/level.go @@ -21,11 +21,11 @@ type Levels map[LEVEL]string // DefaultLevels returns the default set of log levels func DefaultLevels() Levels { return Levels{ - DEBUG: "debug", - INFO: "info", - WARN: "warn", - ERROR: "error", - FATAL: "fatal", + DEBUG: "DEBUG", + INFO: "INFO", + WARN: "WARN", + ERROR: "ERROR", + FATAL: "FATAL", } } diff --git a/vendor/codeberg.org/gruf/go-logger/logger.go b/vendor/codeberg.org/gruf/go-logger/logger.go index 25d573df1..895d3690f 100644 --- a/vendor/codeberg.org/gruf/go-logger/logger.go +++ b/vendor/codeberg.org/gruf/go-logger/logger.go @@ -43,7 +43,7 @@ type Logger struct { // New returns a new Logger instance with defaults func New(out io.Writer) *Logger { - return NewWith(0 /* all */, true, NewLogFmt(false), 512, out) + return NewWith(0 /* all */, true, DefaultTextFormat, 512, out) } // NewWith returns a new Logger instance with supplied configuration diff --git a/vendor/codeberg.org/gruf/go-logger/writer.go b/vendor/codeberg.org/gruf/go-logger/writer.go new file mode 100644 index 000000000..72321f518 --- /dev/null +++ b/vendor/codeberg.org/gruf/go-logger/writer.go @@ -0,0 +1,29 @@ +package logger + +import ( + "io" + "io/ioutil" + "sync" +) + +// AddSafety wraps an io.Writer to provide mutex locking protection +func AddSafety(w io.Writer) io.Writer { + if w == nil { + w = ioutil.Discard + } else if sw, ok := w.(*safeWriter); ok { + return sw + } + return &safeWriter{wr: w} +} + +// safeWriter wraps an io.Writer to provide mutex locking on write +type safeWriter struct { + wr io.Writer + mu sync.Mutex +} + +func (w *safeWriter) Write(b []byte) (int, error) { + w.mu.Lock() + defer w.mu.Unlock() + return w.wr.Write(b) +} diff --git a/vendor/codeberg.org/gruf/go-mutexes/LICENSE b/vendor/codeberg.org/gruf/go-mutexes/LICENSE index 0ad25db4b..b7c4417ac 100644 --- a/vendor/codeberg.org/gruf/go-mutexes/LICENSE +++ b/vendor/codeberg.org/gruf/go-mutexes/LICENSE @@ -1,661 +1,9 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 +MIT License - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Copyright (c) 2021 gruf - Preamble +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/codeberg.org/gruf/go-store/kv/store.go b/vendor/codeberg.org/gruf/go-store/kv/store.go index d25b3fb04..148e3f33d 100644 --- a/vendor/codeberg.org/gruf/go-store/kv/store.go +++ b/vendor/codeberg.org/gruf/go-store/kv/store.go @@ -196,7 +196,7 @@ func (st *KVStore) Iterator(matchFn func(string) bool) (*KVIterator, error) { } // Walk keys in the storage - err := st.storage.WalkKeys(&storage.WalkKeysOptions{WalkFn: walkFn}) + err := st.storage.WalkKeys(storage.WalkKeysOptions{WalkFn: walkFn}) if err != nil { st.mutex.RUnlock() return nil, err diff --git a/vendor/codeberg.org/gruf/go-store/storage/block.go b/vendor/codeberg.org/gruf/go-store/storage/block.go index eb51a4cd3..112b67d80 100644 --- a/vendor/codeberg.org/gruf/go-store/storage/block.go +++ b/vendor/codeberg.org/gruf/go-store/storage/block.go @@ -569,7 +569,7 @@ func (st *BlockStorage) Remove(key string) error { } // WalkKeys implements Storage.WalkKeys() -func (st *BlockStorage) WalkKeys(opts *WalkKeysOptions) error { +func (st *BlockStorage) WalkKeys(opts WalkKeysOptions) error { // Acquire path builder pb := util.GetPathBuilder() defer util.PutPathBuilder(pb) diff --git a/vendor/codeberg.org/gruf/go-store/storage/disk.go b/vendor/codeberg.org/gruf/go-store/storage/disk.go index 6b295755f..cbc365eed 100644 --- a/vendor/codeberg.org/gruf/go-store/storage/disk.go +++ b/vendor/codeberg.org/gruf/go-store/storage/disk.go @@ -251,7 +251,7 @@ func (st *DiskStorage) Remove(key string) error { } // WalkKeys implements Storage.WalkKeys() -func (st *DiskStorage) WalkKeys(opts *WalkKeysOptions) error { +func (st *DiskStorage) WalkKeys(opts WalkKeysOptions) error { // Acquire path builder pb := util.GetPathBuilder() defer util.PutPathBuilder(pb) diff --git a/vendor/codeberg.org/gruf/go-store/storage/memory.go b/vendor/codeberg.org/gruf/go-store/storage/memory.go new file mode 100644 index 000000000..e30aef571 --- /dev/null +++ b/vendor/codeberg.org/gruf/go-store/storage/memory.go @@ -0,0 +1,131 @@ +package storage + +import ( + "io" + "sync" + + "codeberg.org/gruf/go-bytes" + "codeberg.org/gruf/go-store/util" +) + +// MemoryStorage is a storage implementation that simply stores key-value +// pairs in a Go map in-memory. The map is protected by a mutex. +type MemoryStorage struct { + fs map[string][]byte + mu sync.Mutex +} + +// OpenMemory opens a new MemoryStorage instance with internal map of 'size'. +func OpenMemory(size int) *MemoryStorage { + return &MemoryStorage{ + fs: make(map[string][]byte, size), + mu: sync.Mutex{}, + } +} + +// Clean implements Storage.Clean(). +func (st *MemoryStorage) Clean() error { + return nil +} + +// ReadBytes implements Storage.ReadBytes(). +func (st *MemoryStorage) ReadBytes(key string) ([]byte, error) { + // Safely check store + st.mu.Lock() + b, ok := st.fs[key] + st.mu.Unlock() + + // Return early if not exist + if !ok { + return nil, ErrNotFound + } + + // Create return copy + return bytes.Copy(b), nil +} + +// ReadStream implements Storage.ReadStream(). +func (st *MemoryStorage) ReadStream(key string) (io.ReadCloser, error) { + // Safely check store + st.mu.Lock() + b, ok := st.fs[key] + st.mu.Unlock() + + // Return early if not exist + if !ok { + return nil, ErrNotFound + } + + // Create io.ReadCloser from 'b' copy + b = bytes.Copy(b) + r := bytes.NewReader(b) + return util.NopReadCloser(r), nil +} + +// WriteBytes implements Storage.WriteBytes(). +func (st *MemoryStorage) WriteBytes(key string, b []byte) error { + // Safely check store + st.mu.Lock() + _, ok := st.fs[key] + + // Check for already exist + if ok { + st.mu.Unlock() + return ErrAlreadyExists + } + + // Write + unlock + st.fs[key] = bytes.Copy(b) + st.mu.Unlock() + return nil +} + +// WriteStream implements Storage.WriteStream(). +func (st *MemoryStorage) WriteStream(key string, r io.Reader) error { + // Read all from reader + b, err := io.ReadAll(r) + if err != nil { + return err + } + + // Write to storage + return st.WriteBytes(key, b) +} + +// Stat implements Storage.Stat(). +func (st *MemoryStorage) Stat(key string) (bool, error) { + st.mu.Lock() + _, ok := st.fs[key] + st.mu.Unlock() + return ok, nil +} + +// Remove implements Storage.Remove(). +func (st *MemoryStorage) Remove(key string) error { + // Safely check store + st.mu.Lock() + _, ok := st.fs[key] + + // Check in store + if !ok { + st.mu.Unlock() + return ErrNotFound + } + + // Delete + unlock + delete(st.fs, key) + st.mu.Unlock() + return nil +} + +// WalkKeys implements Storage.WalkKeys(). +func (st *MemoryStorage) WalkKeys(opts WalkKeysOptions) error { + // Safely walk storage keys + st.mu.Lock() + for key := range st.fs { + opts.WalkFn(entry(key)) + } + st.mu.Unlock() + + return nil +} diff --git a/vendor/codeberg.org/gruf/go-store/storage/storage.go b/vendor/codeberg.org/gruf/go-store/storage/storage.go index 61f722111..b160267a4 100644 --- a/vendor/codeberg.org/gruf/go-store/storage/storage.go +++ b/vendor/codeberg.org/gruf/go-store/storage/storage.go @@ -41,7 +41,7 @@ type Storage interface { Remove(key string) error // WalkKeys walks the keys in the storage - WalkKeys(opts *WalkKeysOptions) error + WalkKeys(opts WalkKeysOptions) error } // WalkKeysOptions defines how to walk the keys in a storage implementation diff --git a/vendor/github.com/coreos/go-oidc/v3/oidc/jwks.go b/vendor/github.com/coreos/go-oidc/v3/oidc/jwks.go index 6a162689b..a272b7ab2 100644 --- a/vendor/github.com/coreos/go-oidc/v3/oidc/jwks.go +++ b/vendor/github.com/coreos/go-oidc/v3/oidc/jwks.go @@ -18,8 +18,8 @@ import ( // exposed for providers that don't support discovery or to prevent round trips to the // discovery URL. // -// The returned KeySet is a long lived verifier that caches keys based on cache-control -// headers. Reuse a common remote key set instead of creating new ones as needed. +// The returned KeySet is a long lived verifier that caches keys based on any +// keys change. Reuse a common remote key set instead of creating new ones as needed. func NewRemoteKeySet(ctx context.Context, jwksURL string) *RemoteKeySet { return newRemoteKeySet(ctx, jwksURL, time.Now) } @@ -39,7 +39,7 @@ type RemoteKeySet struct { now func() time.Time // guard all other fields - mu sync.Mutex + mu sync.RWMutex // inflight suppresses parallel execution of updateKeys and allows // multiple goroutines to wait for its result. @@ -131,8 +131,8 @@ func (r *RemoteKeySet) verify(ctx context.Context, jws *jose.JSONWebSignature) ( } func (r *RemoteKeySet) keysFromCache() (keys []jose.JSONWebKey) { - r.mu.Lock() - defer r.mu.Unlock() + r.mu.RLock() + defer r.mu.RUnlock() return r.cachedKeys } diff --git a/vendor/github.com/coreos/go-oidc/v3/oidc/oidc.go b/vendor/github.com/coreos/go-oidc/v3/oidc/oidc.go index 9726f13bd..3e1d80e08 100644 --- a/vendor/github.com/coreos/go-oidc/v3/oidc/oidc.go +++ b/vendor/github.com/coreos/go-oidc/v3/oidc/oidc.go @@ -17,7 +17,6 @@ import ( "time" "golang.org/x/oauth2" - jose "gopkg.in/square/go-jose.v2" ) const ( @@ -40,6 +39,10 @@ var ( errInvalidAtHash = errors.New("access token hash does not match value in ID token") ) +type contextKey int + +var issuerURLKey contextKey + // ClientContext returns a new Context that carries the provided HTTP client. // // This method sets the same context key used by the golang.org/x/oauth2 package, @@ -56,7 +59,7 @@ func ClientContext(ctx context.Context, client *http.Client) context.Context { } // cloneContext copies a context's bag-of-values into a new context that isn't -// associated with its cancelation. This is used to initialize remote keys sets +// associated with its cancellation. This is used to initialize remote keys sets // which run in the background and aren't associated with the initial context. func cloneContext(ctx context.Context) context.Context { cp := context.Background() @@ -66,6 +69,25 @@ func cloneContext(ctx context.Context) context.Context { return cp } +// InsecureIssuerURLContext allows discovery to work when the issuer_url reported +// by upstream is mismatched with the discovery URL. This is meant for integration +// with off-spec providers such as Azure. +// +// discoveryBaseURL := "https://login.microsoftonline.com/organizations/v2.0" +// issuerURL := "https://login.microsoftonline.com/my-tenantid/v2.0" +// +// ctx := oidc.InsecureIssuerURLContext(parentContext, issuerURL) +// +// // Provider will be discovered with the discoveryBaseURL, but use issuerURL +// // for future issuer validation. +// provider, err := oidc.NewProvider(ctx, discoveryBaseURL) +// +// This is insecure because validating the correct issuer is critical for multi-tenant +// proivders. Any overrides here MUST be carefully reviewed. +func InsecureIssuerURLContext(ctx context.Context, issuerURL string) context.Context { + return context.WithValue(ctx, issuerURLKey, issuerURL) +} + func doRequest(ctx context.Context, req *http.Request) (*http.Response, error) { client := http.DefaultClient if c, ok := ctx.Value(oauth2.HTTPClient).(*http.Client); ok { @@ -88,11 +110,6 @@ type Provider struct { remoteKeySet KeySet } -type cachedKeys struct { - keys []jose.JSONWebKey - expiry time.Time -} - type providerJSON struct { Issuer string `json:"issuer"` AuthURL string `json:"authorization_endpoint"` @@ -148,7 +165,11 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) { return nil, fmt.Errorf("oidc: failed to decode provider discovery object: %v", err) } - if p.Issuer != issuer { + issuerURL, skipIssuerValidation := ctx.Value(issuerURLKey).(string) + if !skipIssuerValidation { + issuerURL = issuer + } + if p.Issuer != issuerURL && !skipIssuerValidation { return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer) } var algs []string @@ -158,7 +179,7 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) { } } return &Provider{ - issuer: p.Issuer, + issuer: issuerURL, authURL: p.AuthURL, tokenURL: p.TokenURL, userInfoURL: p.UserInfoURL, @@ -398,9 +419,9 @@ type stringAsBool bool func (sb *stringAsBool) UnmarshalJSON(b []byte) error { switch string(b) { case "true", `"true"`: - *sb = stringAsBool(true) + *sb = true case "false", `"false"`: - *sb = stringAsBool(false) + *sb = false default: return errors.New("invalid value for boolean") } @@ -419,7 +440,7 @@ func (a *audience) UnmarshalJSON(b []byte) error { if err := json.Unmarshal(b, &auds); err != nil { return err } - *a = audience(auds) + *a = auds return nil } diff --git a/vendor/github.com/coreos/go-oidc/v3/oidc/verify.go b/vendor/github.com/coreos/go-oidc/v3/oidc/verify.go index 5c4d6582c..dc6b56dfe 100644 --- a/vendor/github.com/coreos/go-oidc/v3/oidc/verify.go +++ b/vendor/github.com/coreos/go-oidc/v3/oidc/verify.go @@ -171,20 +171,6 @@ func resolveDistributedClaim(ctx context.Context, verifier *IDTokenVerifier, src return token.claims, nil } -func parseClaim(raw []byte, name string, v interface{}) error { - var parsed map[string]json.RawMessage - if err := json.Unmarshal(raw, &parsed); err != nil { - return err - } - - val, ok := parsed[name] - if !ok { - return fmt.Errorf("claim doesn't exist: %s", name) - } - - return json.Unmarshal([]byte(val), v) -} - // Verify parses a raw ID Token, verifies it's been signed by the provider, performs // any additional checks depending on the Config, and returns the payload. // diff --git a/vendor/github.com/gin-contrib/sessions/.travis.yml b/vendor/github.com/gin-contrib/sessions/.travis.yml deleted file mode 100644 index 85e4724e9..000000000 --- a/vendor/github.com/gin-contrib/sessions/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: go -sudo: false - -matrix: - fast_finish: true - include: - - go: 1.10.x - - go: 1.11.x - env: GO111MODULE=on - - go: 1.12.x - env: GO111MODULE=on - - go: 1.13.x - - go: master - env: GO111MODULE=on - -git: - depth: 10 - -services: - - redis - - memcached - - mongodb - -before_install: - - go get github.com/campoy/embedmd - -install: - - if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else go get -t -v .; fi - - if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi - -script: - - embedmd -d *.md - - go test -v -covermode=atomic -coverprofile=coverage.out ./... - -after_success: - - bash <(curl -s https://codecov.io/bash) - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/acc2c57482e94b44f557 - on_success: change - on_failure: always - on_start: false diff --git a/vendor/github.com/gin-contrib/sessions/README.md b/vendor/github.com/gin-contrib/sessions/README.md index 94e445250..7d5c2305a 100644 --- a/vendor/github.com/gin-contrib/sessions/README.md +++ b/vendor/github.com/gin-contrib/sessions/README.md @@ -1,6 +1,7 @@ # sessions -[![Build Status](https://travis-ci.org/gin-contrib/sessions.svg)](https://travis-ci.org/gin-contrib/sessions) +[![Run CI Lint](https://github.com/gin-contrib/sessions/actions/workflows/lint.yml/badge.svg)](https://github.com/gin-contrib/sessions/actions/workflows/lint.yml) +[![Run Testing](https://github.com/gin-contrib/sessions/actions/workflows/testing.yml/badge.svg)](https://github.com/gin-contrib/sessions/actions/workflows/testing.yml) [![codecov](https://codecov.io/gh/gin-contrib/sessions/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/sessions) [![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/sessions)](https://goreportcard.com/report/github.com/gin-contrib/sessions) [![GoDoc](https://godoc.org/github.com/gin-contrib/sessions?status.svg)](https://godoc.org/github.com/gin-contrib/sessions) @@ -13,6 +14,7 @@ Gin middleware for session management with multi-backend support: - [memcached](#memcached) - [MongoDB](#mongodb) - [memstore](#memstore) +- [PostgreSQL](#postgresql) ## Usage @@ -21,7 +23,7 @@ Gin middleware for session management with multi-backend support: Download and install it: ```bash -$ go get github.com/gin-contrib/sessions +go get github.com/gin-contrib/sessions ``` Import it in your code: @@ -38,27 +40,27 @@ import "github.com/gin-contrib/sessions" package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/cookie" - "github.com/gin-gonic/gin" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/cookie" + "github.com/gin-gonic/gin" ) func main() { - r := gin.Default() - store := cookie.NewStore([]byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + r := gin.Default() + store := cookie.NewStore([]byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/hello", func(c *gin.Context) { - session := sessions.Default(c) + r.GET("/hello", func(c *gin.Context) { + session := sessions.Default(c) - if session.Get("hello") != "world" { - session.Set("hello", "world") - session.Save() - } + if session.Get("hello") != "world" { + session.Set("hello", "world") + session.Save() + } - c.JSON(200, gin.H{"hello": session.Get("hello")}) - }) - r.Run(":8000") + c.JSON(200, gin.H{"hello": session.Get("hello")}) + }) + r.Run(":8000") } ``` @@ -68,109 +70,107 @@ func main() { package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/cookie" - "github.com/gin-gonic/gin" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/cookie" + "github.com/gin-gonic/gin" ) func main() { - r := gin.Default() - store := cookie.NewStore([]byte("secret")) - sessionNames := []string{"a", "b"} - r.Use(sessions.SessionsMany(sessionNames, store)) + r := gin.Default() + store := cookie.NewStore([]byte("secret")) + sessionNames := []string{"a", "b"} + r.Use(sessions.SessionsMany(sessionNames, store)) - r.GET("/hello", func(c *gin.Context) { - sessionA := sessions.DefaultMany(c, "a") - sessionB := sessions.DefaultMany(c, "b") + r.GET("/hello", func(c *gin.Context) { + sessionA := sessions.DefaultMany(c, "a") + sessionB := sessions.DefaultMany(c, "b") - if sessionA.Get("hello") != "world!" { - sessionA.Set("hello", "world!") - sessionA.Save() - } + if sessionA.Get("hello") != "world!" { + sessionA.Set("hello", "world!") + sessionA.Save() + } - if sessionB.Get("hello") != "world?" { - sessionB.Set("hello", "world?") - sessionB.Save() - } + if sessionB.Get("hello") != "world?" { + sessionB.Set("hello", "world?") + sessionB.Save() + } - c.JSON(200, gin.H{ - "a": sessionA.Get("hello"), - "b": sessionB.Get("hello"), - }) - }) - r.Run(":8000") + c.JSON(200, gin.H{ + "a": sessionA.Get("hello"), + "b": sessionB.Get("hello"), + }) + }) + r.Run(":8000") } ``` -## Backend examples +## Backend Examples ### cookie-based -[embedmd]:# (example/cookie/main.go go) ```go package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/cookie" - "github.com/gin-gonic/gin" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/cookie" + "github.com/gin-gonic/gin" ) func main() { - r := gin.Default() - store := cookie.NewStore([]byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + r := gin.Default() + store := cookie.NewStore([]byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/incr", func(c *gin.Context) { - session := sessions.Default(c) - var count int - v := session.Get("count") - if v == nil { - count = 0 - } else { - count = v.(int) - count++ - } - session.Set("count", count) - session.Save() - c.JSON(200, gin.H{"count": count}) - }) - r.Run(":8000") + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") } ``` ### Redis -[embedmd]:# (example/redis/main.go go) ```go package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/redis" - "github.com/gin-gonic/gin" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/redis" + "github.com/gin-gonic/gin" ) func main() { - r := gin.Default() - store, _ := redis.NewStore(10, "tcp", "localhost:6379", "", []byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + r := gin.Default() + store, _ := redis.NewStore(10, "tcp", "localhost:6379", "", []byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/incr", func(c *gin.Context) { - session := sessions.Default(c) - var count int - v := session.Get("count") - if v == nil { - count = 0 - } else { - count = v.(int) - count++ - } - session.Set("count", count) - session.Save() - c.JSON(200, gin.H{"count": count}) - }) - r.Run(":8000") + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") } ``` @@ -178,134 +178,174 @@ func main() { #### ASCII Protocol -[embedmd]:# (example/memcached/ascii.go go) ```go package main import ( - "github.com/bradfitz/gomemcache/memcache" - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/memcached" - "github.com/gin-gonic/gin" + "github.com/bradfitz/gomemcache/memcache" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/memcached" + "github.com/gin-gonic/gin" ) func main() { - r := gin.Default() - store := memcached.NewStore(memcache.New("localhost:11211"), "", []byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + r := gin.Default() + store := memcached.NewStore(memcache.New("localhost:11211"), "", []byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/incr", func(c *gin.Context) { - session := sessions.Default(c) - var count int - v := session.Get("count") - if v == nil { - count = 0 - } else { - count = v.(int) - count++ - } - session.Set("count", count) - session.Save() - c.JSON(200, gin.H{"count": count}) - }) - r.Run(":8000") + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") } ``` #### Binary protocol (with optional SASL authentication) -[embedmd]:# (example/memcached/binary.go go) ```go package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/memcached" - "github.com/gin-gonic/gin" - "github.com/memcachier/mc" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/memcached" + "github.com/gin-gonic/gin" + "github.com/memcachier/mc" ) func main() { - r := gin.Default() - client := mc.NewMC("localhost:11211", "username", "password") - store := memcached.NewMemcacheStore(client, "", []byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + r := gin.Default() + client := mc.NewMC("localhost:11211", "username", "password") + store := memcached.NewMemcacheStore(client, "", []byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/incr", func(c *gin.Context) { - session := sessions.Default(c) - var count int - v := session.Get("count") - if v == nil { - count = 0 - } else { - count = v.(int) - count++ - } - session.Set("count", count) - session.Save() - c.JSON(200, gin.H{"count": count}) - }) - r.Run(":8000") + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") } ``` ### MongoDB -[embedmd]:# (example/mongo/main.go go) ```go package main import ( - "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/mongo" - "github.com/gin-gonic/gin" - "github.com/globalsign/mgo" + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/mongo" + "github.com/gin-gonic/gin" + "github.com/globalsign/mgo" ) func main() { - r := gin.Default() - session, err := mgo.Dial("localhost:27017/test") - if err != nil { - // handle err - } + r := gin.Default() + session, err := mgo.Dial("localhost:27017/test") + if err != nil { + // handle err + } - c := session.DB("").C("sessions") - store := mongo.NewStore(c, 3600, true, []byte("secret")) - r.Use(sessions.Sessions("mysession", store)) + c := session.DB("").C("sessions") + store := mongo.NewStore(c, 3600, true, []byte("secret")) + r.Use(sessions.Sessions("mysession", store)) - r.GET("/incr", func(c *gin.Context) { - session := sessions.Default(c) - var count int - v := session.Get("count") - if v == nil { - count = 0 - } else { - count = v.(int) - count++ - } - session.Set("count", count) - session.Save() - c.JSON(200, gin.H{"count": count}) - }) - r.Run(":8000") + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") } ``` ### memstore -[embedmd]:# (example/memstore/main.go go) ```go package main import ( + "github.com/gin-contrib/sessions" + "github.com/gin-contrib/sessions/memstore" + "github.com/gin-gonic/gin" +) + +func main() { + r := gin.Default() + store := memstore.NewStore([]byte("secret")) + r.Use(sessions.Sessions("mysession", store)) + + r.GET("/incr", func(c *gin.Context) { + session := sessions.Default(c) + var count int + v := session.Get("count") + if v == nil { + count = 0 + } else { + count = v.(int) + count++ + } + session.Set("count", count) + session.Save() + c.JSON(200, gin.H{"count": count}) + }) + r.Run(":8000") +} +``` + +### PostgreSQL + +```go +package main + +import ( + "database/sql" "github.com/gin-contrib/sessions" - "github.com/gin-contrib/sessions/memstore" + "github.com/gin-contrib/sessions/postgres" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() - store := memstore.NewStore([]byte("secret")) + db, err := sql.Open("postgres", "postgresql://username:password@localhost:5432/database") + if err != nil { + // handle err + } + + store, err := postgres.NewStore(db, []byte("secret")) + if err != nil { + // handle err + } + r.Use(sessions.Sessions("mysession", store)) r.GET("/incr", func(c *gin.Context) { @@ -325,5 +365,3 @@ func main() { r.Run(":8000") } ``` - - diff --git a/vendor/github.com/gin-contrib/sessions/sessions.go b/vendor/github.com/gin-contrib/sessions/sessions.go index 8972e2321..fe116e8ef 100644 --- a/vendor/github.com/gin-contrib/sessions/sessions.go +++ b/vendor/github.com/gin-contrib/sessions/sessions.go @@ -22,6 +22,8 @@ type Store interface { // Wraps thinly gorilla-session methods. // Session stores the values and optional configuration for a session. type Session interface { + // ID of the session, generated by stores. It should not be used for user data. + ID() string // Get returns the session value associated to the given key. Get(key interface{}) interface{} // Set sets the session value associated to the given key. @@ -74,6 +76,10 @@ type session struct { writer http.ResponseWriter } +func (s *session) ID() string { + return s.Session().ID +} + func (s *session) Get(key interface{}) interface{} { return s.Session().Values[key] } diff --git a/vendor/github.com/gin-gonic/gin/.golangci.yml b/vendor/github.com/gin-gonic/gin/.golangci.yml deleted file mode 100644 index 78a4259a1..000000000 --- a/vendor/github.com/gin-gonic/gin/.golangci.yml +++ /dev/null @@ -1,22 +0,0 @@ -run: - timeout: 5m -linters: - enable: - - gofmt - - misspell - - revive -issues: - exclude-rules: - - linters: - - structcheck - - unused - text: "`data` is unused" - - linters: - - staticcheck - text: "SA1019:" - - linters: - - revive - text: "var-naming:" - - linters: - - revive - text: "exported:" diff --git a/vendor/github.com/gin-gonic/gin/.travis.yml b/vendor/github.com/gin-gonic/gin/.travis.yml new file mode 100644 index 000000000..bcc21414d --- /dev/null +++ b/vendor/github.com/gin-gonic/gin/.travis.yml @@ -0,0 +1,48 @@ +language: go + +matrix: + fast_finish: true + include: + - go: 1.13.x + - go: 1.13.x + env: + - TESTTAGS=nomsgpack + - go: 1.14.x + - go: 1.14.x + env: + - TESTTAGS=nomsgpack + - go: 1.15.x + - go: 1.15.x + env: + - TESTTAGS=nomsgpack + - go: master + +git: + depth: 10 + +before_install: + - if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi + +install: + - if [[ "${GO111MODULE}" = "on" ]]; then go mod download; fi + - if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi + - if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi + +go_import_path: github.com/gin-gonic/gin + +script: + - make vet + - make fmt-check + - make misspell-check + - make test + +after_success: + - bash <(curl -s https://codecov.io/bash) + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/7f95bf605c4d356372f4 + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: false # default: false diff --git a/vendor/github.com/gin-gonic/gin/CHANGELOG.md b/vendor/github.com/gin-gonic/gin/CHANGELOG.md index 308af74c3..4c806a5a7 100644 --- a/vendor/github.com/gin-gonic/gin/CHANGELOG.md +++ b/vendor/github.com/gin-gonic/gin/CHANGELOG.md @@ -1,5 +1,35 @@ # Gin ChangeLog +## Gin v1.7.7 + +### BUGFIXES + +* Fixed X-Forwarded-For unsafe handling of CVE-2020-28483 [#2844](https://github.com/gin-gonic/gin/pull/2844), closed issue [#2862](https://github.com/gin-gonic/gin/issues/2862). +* Tree: updated the code logic for `latestNode` [#2897](https://github.com/gin-gonic/gin/pull/2897), closed issue [#2894](https://github.com/gin-gonic/gin/issues/2894) [#2878](https://github.com/gin-gonic/gin/issues/2878). +* Tree: fixed the misplacement of adding slashes [#2847](https://github.com/gin-gonic/gin/pull/2847), closed issue [#2843](https://github.com/gin-gonic/gin/issues/2843). +* Tree: fixed tsr with mixed static and wildcard paths [#2924](https://github.com/gin-gonic/gin/pull/2924), closed issue [#2918](https://github.com/gin-gonic/gin/issues/2918). + +### ENHANCEMENTS + +* TrustedProxies: make it backward-compatible [#2887](https://github.com/gin-gonic/gin/pull/2887), closed issue [#2819](https://github.com/gin-gonic/gin/issues/2819). +* TrustedPlatform: provide custom options for another CDN services [#2906](https://github.com/gin-gonic/gin/pull/2906). + +### DOCS + +* NoMethod: added usage annotation ([#2832](https://github.com/gin-gonic/gin/pull/2832#issuecomment-929954463)). + +## Gin v1.7.6 + +### BUGFIXES + +* bump new release to fix v1.7.5 release error by using v1.7.4 codes. + +## Gin v1.7.4 + +### BUGFIXES + +* bump new release to fix checksum mismatch + ## Gin v1.7.3 ### BUGFIXES diff --git a/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md b/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md index d1c723c67..97daa808f 100644 --- a/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md +++ b/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md @@ -8,6 +8,6 @@ - With pull requests: - Open your pull request against `master` - Your pull request should have no more than two commits, if not you should squash them. - - It should pass all tests in the available continuous integration systems such as GitHub Actions. + - It should pass all tests in the available continuous integration systems such as TravisCI. - You should add/modify tests to cover your proposed code changes. - If your pull request contains a new feature, please document it on the README. diff --git a/vendor/github.com/gin-gonic/gin/Makefile b/vendor/github.com/gin-gonic/gin/Makefile index 5d55b444c..1a9919395 100644 --- a/vendor/github.com/gin-gonic/gin/Makefile +++ b/vendor/github.com/gin-gonic/gin/Makefile @@ -1,6 +1,5 @@ GO ?= go GOFMT ?= gofmt "-s" -GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2) PACKAGES ?= $(shell $(GO) list ./...) VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/) GOFILES := $(shell find . -name "*.go") @@ -68,10 +67,5 @@ misspell: .PHONY: tools tools: - @if [ $(GO_VERSION) -gt 15 ]; then \ - $(GO) install golang.org/x/lint/golint@latest; \ - $(GO) install github.com/client9/misspell/cmd/misspell@latest; \ - elif [ $(GO_VERSION) -lt 16 ]; then \ - $(GO) install golang.org/x/lint/golint; \ - $(GO) install github.com/client9/misspell/cmd/misspell; \ - fi + go install golang.org/x/lint/golint; \ + go install github.com/client9/misspell/cmd/misspell; diff --git a/vendor/github.com/gin-gonic/gin/README.md b/vendor/github.com/gin-gonic/gin/README.md index 198bf0119..9bf459b09 100644 --- a/vendor/github.com/gin-gonic/gin/README.md +++ b/vendor/github.com/gin-gonic/gin/README.md @@ -2,7 +2,7 @@ -[![Build Status](https://github.com/gin-gonic/gin/workflows/Run%20Tests/badge.svg?branch=master)](https://github.com/gin-gonic/gin/actions?query=branch%3Amaster) +[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin) [![codecov](https://codecov.io/gh/gin-gonic/gin/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-gonic/gin) [![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)](https://goreportcard.com/report/github.com/gin-gonic/gin) [![GoDoc](https://pkg.go.dev/badge/github.com/gin-gonic/gin?status.svg)](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc) @@ -23,8 +23,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [Quick start](#quick-start) - [Benchmarks](#benchmarks) - [Gin v1. stable](#gin-v1-stable) - - [Build with jsoniter/go-json](#build-with-json-replacement) - - [Build without `MsgPack` rendering feature](#build-without-msgpack-rendering-feature) + - [Build with jsoniter](#build-with-jsoniter) - [API Examples](#api-examples) - [Using GET, POST, PUT, PATCH, DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options) - [Parameters in path](#parameters-in-path) @@ -78,6 +77,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [http2 server push](#http2-server-push) - [Define format for the log of routes](#define-format-for-the-log-of-routes) - [Set and get a cookie](#set-and-get-a-cookie) + - [Don't trust all proxies](#don't-trust-all-proxies) - [Testing](#testing) - [Users](#users) @@ -183,28 +183,13 @@ Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httpr - [x] Battle tested. - [x] API frozen, new releases will not break your code. -## Build with json replacement +## Build with [jsoniter](https://github.com/json-iterator/go) -Gin uses `encoding/json` as default json package but you can change it by build from other tags. +Gin uses `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags. -[jsoniter](https://github.com/json-iterator/go) ```sh $ go build -tags=jsoniter . ``` -[go-json](https://github.com/goccy/go-json) -```sh -$ go build -tags=go_json . -``` - -## Build without `MsgPack` rendering feature - -Gin enables `MsgPack` rendering feature by default. But you can disable this feature by specifying `nomsgpack` build tag. - -```sh -$ go build -tags=nomsgpack . -``` - -This is useful to reduce the binary size of executable files. See the [detail information](https://github.com/gin-gonic/gin/pull/1852). ## API Examples @@ -256,15 +241,14 @@ func main() { // For each matched request Context will hold the route definition router.POST("/user/:name/*action", func(c *gin.Context) { - b := c.FullPath() == "/user/:name/*action" // true - c.String(http.StatusOK, "%t", b) + c.FullPath() == "/user/:name/*action" // true }) // This handler will add a new router for /user/groups. // Exact routes are resolved before param routes, regardless of the order they were defined. // Routes starting with /user/groups are never interpreted as /user/:name/... routes router.GET("/user/groups", func(c *gin.Context) { - c.String(http.StatusOK, "The available groups are [...]") + c.String(http.StatusOK, "The available groups are [...]", name) }) router.Run(":8080") @@ -703,7 +687,7 @@ func main() { // Example for binding XML ( // // - // manu + // user // 123 // ) router.POST("/loginXML", func(c *gin.Context) { @@ -942,7 +926,7 @@ func main() { route.GET("/:name/:id", func(c *gin.Context) { var person Person if err := c.ShouldBindUri(&person); err != nil { - c.JSON(400, gin.H{"msg": err.Error()}) + c.JSON(400, gin.H{"msg": err}) return } c.JSON(200, gin.H{"name": person.Name, "uuid": person.ID}) @@ -2022,61 +2006,6 @@ enough to call binding at once. can be called by `c.ShouldBind()` multiple times without any damage to performance (See [#1341](https://github.com/gin-gonic/gin/pull/1341)). -### Bind form-data request with custom struct and custom tag - -```go -const ( - customerTag = "url" - defaultMemory = 32 << 20 -) - -type customerBinding struct {} - -func (customerBinding) Name() string { - return "form" -} - -func (customerBinding) Bind(req *http.Request, obj interface{}) error { - if err := req.ParseForm(); err != nil { - return err - } - if err := req.ParseMultipartForm(defaultMemory); err != nil { - if err != http.ErrNotMultipart { - return err - } - } - if err := binding.MapFormWithTag(obj, req.Form, customerTag); err != nil { - return err - } - return validate(obj) -} - -func validate(obj interface{}) error { - if binding.Validator == nil { - return nil - } - return binding.Validator.ValidateStruct(obj) -} - -// Now we can do this!!! -// FormA is a external type that we can't modify it's tag -type FormA struct { - FieldA string `url:"field_a"` -} - -func ListHandler(s *Service) func(ctx *gin.Context) { - return func(ctx *gin.Context) { - var urlBinding = customerBinding{} - var opt FormA - err := ctx.MustBindWith(&opt, urlBinding) - if err != nil { - ... - } - ... - } -} -``` - ### http2 server push http.Pusher is supported only **go1.8+**. See the [golang blog](https://blog.golang.org/h2push) for detail information. @@ -2202,11 +2131,17 @@ Gin lets you specify which headers to hold the real client IP (if any), as well as specifying which proxies (or direct clients) you trust to specify one of these headers. -The `TrustedProxies` slice on your `gin.Engine` specifes network addresses or -network CIDRs from where clients which their request headers related to client +Use function `SetTrustedProxies()` on your `gin.Engine` to specify network addresses +or network CIDRs from where clients which their request headers related to client IP can be trusted. They can be IPv4 addresses, IPv4 CIDRs, IPv6 addresses or IPv6 CIDRs. +**Attention:** Gin trust all proxies by default if you don't specify a trusted +proxy using the function above, **this is NOT safe**. At the same time, if you don't +use any proxy, you can disable this feature by using `Engine.SetTrustedProxies(nil)`, +then `Context.ClientIP()` will return the remote address directly to avoid some +unnecessary computation. + ```go import ( "fmt" @@ -2217,7 +2152,7 @@ import ( func main() { router := gin.Default() - router.TrustedProxies = []string{"192.168.1.2"} + router.SetTrustedProxies([]string{"192.168.1.2"}) router.GET("/", func(c *gin.Context) { // If the client is 192.168.1.2, use the X-Forwarded-For @@ -2230,6 +2165,34 @@ func main() { } ``` +**Notice:** If you are using a CDN service, you can set the `Engine.TrustedPlatform` +to skip TrustedProxies check, it has a higher priority than TrustedProxies. +Look at the example below: +```go +import ( + "fmt" + + "github.com/gin-gonic/gin" +) + +func main() { + + router := gin.Default() + // Use predefined header gin.PlatformXXX + router.TrustedPlatform = gin.PlatformGoogleAppEngine + // Or set your own trusted request header for another trusted proxy service + // Don't set it to any suspect request header, it's unsafe + router.TrustedPlatform = "X-CDN-IP" + + router.GET("/", func(c *gin.Context) { + // If you set TrustedPlatform, ClientIP() will resolve the + // corresponding header and return IP directly + fmt.Printf("ClientIP: %s\n", c.ClientIP()) + }) + router.Run() +} +``` + ## Testing The `net/http/httptest` package is preferable way for HTTP testing. @@ -2287,4 +2250,3 @@ Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framewor * [picfit](https://github.com/thoas/picfit): An image resizing server written in Go. * [brigade](https://github.com/brigadecore/brigade): Event-based Scripting for Kubernetes. * [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system. - diff --git a/vendor/github.com/gin-gonic/gin/binding/binding.go b/vendor/github.com/gin-gonic/gin/binding/binding.go index deb71661b..5caeb581a 100644 --- a/vendor/github.com/gin-gonic/gin/binding/binding.go +++ b/vendor/github.com/gin-gonic/gin/binding/binding.go @@ -49,7 +49,7 @@ type BindingUri interface { // StructValidator is the minimal interface which needs to be implemented in // order for it to be used as the validator engine for ensuring the correctness // of the request. Gin provides a default implementation for this using -// https://github.com/go-playground/validator/tree/v10.6.1. +// https://github.com/go-playground/validator/tree/v8.18.2. type StructValidator interface { // ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right. // If the received type is a slice|array, the validation should be performed travel on every element. @@ -65,7 +65,7 @@ type StructValidator interface { } // Validator is the default validator which implements the StructValidator -// interface. It uses https://github.com/go-playground/validator/tree/v10.6.1 +// interface. It uses https://github.com/go-playground/validator/tree/v8.18.2 // under the hood. var Validator StructValidator = &defaultValidator{} diff --git a/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go b/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go index 234244707..9afa3dcf6 100644 --- a/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go +++ b/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go @@ -47,7 +47,7 @@ type BindingUri interface { // StructValidator is the minimal interface which needs to be implemented in // order for it to be used as the validator engine for ensuring the correctness // of the request. Gin provides a default implementation for this using -// https://github.com/go-playground/validator/tree/v10.6.1. +// https://github.com/go-playground/validator/tree/v8.18.2. type StructValidator interface { // ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right. // If the received type is not a struct, any validation should be skipped and nil must be returned. @@ -62,7 +62,7 @@ type StructValidator interface { } // Validator is the default validator which implements the StructValidator -// interface. It uses https://github.com/go-playground/validator/tree/v10.6.1 +// interface. It uses https://github.com/go-playground/validator/tree/v8.18.2 // under the hood. var Validator StructValidator = &defaultValidator{} diff --git a/vendor/github.com/gin-gonic/gin/binding/default_validator.go b/vendor/github.com/gin-gonic/gin/binding/default_validator.go index 87fc4c665..c57a120fc 100644 --- a/vendor/github.com/gin-gonic/gin/binding/default_validator.go +++ b/vendor/github.com/gin-gonic/gin/binding/default_validator.go @@ -20,27 +20,15 @@ type defaultValidator struct { type sliceValidateError []error -// Error concatenates all error elements in sliceValidateError into a single string separated by \n. func (err sliceValidateError) Error() string { - n := len(err) - switch n { - case 0: - return "" - default: - var b strings.Builder - if err[0] != nil { - fmt.Fprintf(&b, "[%d]: %s", 0, err[0].Error()) + var errMsgs []string + for i, e := range err { + if e == nil { + continue } - if n > 1 { - for i := 1; i < n; i++ { - if err[i] != nil { - b.WriteString("\n") - fmt.Fprintf(&b, "[%d]: %s", i, err[i].Error()) - } - } - } - return b.String() + errMsgs = append(errMsgs, fmt.Sprintf("[%d]: %s", i, e.Error())) } + return strings.Join(errMsgs, "\n") } var _ StructValidator = &defaultValidator{} @@ -83,7 +71,7 @@ func (v *defaultValidator) validateStruct(obj interface{}) error { // Engine returns the underlying validator engine which powers the default // Validator instance. This is useful if you want to register custom validations // or struct level validations. See validator GoDoc for more info - -// https://pkg.go.dev/github.com/go-playground/validator/v10 +// https://godoc.org/gopkg.in/go-playground/validator.v8 func (v *defaultValidator) Engine() interface{} { v.lazyinit() return v.validate diff --git a/vendor/github.com/gin-gonic/gin/binding/form.go b/vendor/github.com/gin-gonic/gin/binding/form.go index 040af9e20..b93c34cf4 100644 --- a/vendor/github.com/gin-gonic/gin/binding/form.go +++ b/vendor/github.com/gin-gonic/gin/binding/form.go @@ -22,8 +22,10 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error { if err := req.ParseForm(); err != nil { return err } - if err := req.ParseMultipartForm(defaultMemory); err != nil && err != http.ErrNotMultipart { - return err + if err := req.ParseMultipartForm(defaultMemory); err != nil { + if err != http.ErrNotMultipart { + return err + } } if err := mapForm(obj, req.Form); err != nil { return err diff --git a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go index f8b4b1239..2f4e45b40 100644 --- a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go +++ b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go @@ -16,17 +16,9 @@ import ( "github.com/gin-gonic/gin/internal/json" ) -var ( - errUnknownType = errors.New("unknown type") +var errUnknownType = errors.New("unknown type") - // ErrConvertMapStringSlice can not covert to map[string][]string - ErrConvertMapStringSlice = errors.New("can not convert to map slices of strings") - - // ErrConvertToMapString can not convert to map[string]string - ErrConvertToMapString = errors.New("can not convert to map of strings") -) - -func mapURI(ptr interface{}, m map[string][]string) error { +func mapUri(ptr interface{}, m map[string][]string) error { return mapFormByTag(ptr, m, "uri") } @@ -34,10 +26,6 @@ func mapForm(ptr interface{}, form map[string][]string) error { return mapFormByTag(ptr, form, "form") } -func MapFormWithTag(ptr interface{}, form map[string][]string, tag string) error { - return mapFormByTag(ptr, form, tag) -} - var emptyField = reflect.StructField{} func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error { @@ -83,7 +71,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag return false, nil } - vKind := value.Kind() + var vKind = value.Kind() if vKind == reflect.Ptr { var isNew bool @@ -121,7 +109,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag if sf.PkgPath != "" && !sf.Anonymous { // unexported continue } - ok, err := mapping(value.Field(i), sf, setter, tag) + ok, err := mapping(value.Field(i), tValue.Field(i), setter, tag) if err != nil { return false, err } @@ -210,7 +198,7 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel case reflect.Int64: switch value.Interface().(type) { case time.Duration: - return setTimeDuration(val, value) + return setTimeDuration(val, value, field) } return setIntField(val, 64, value) case reflect.Uint: @@ -310,6 +298,7 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val t := time.Unix(tv/int64(d), tv%int64(d)) value.Set(reflect.ValueOf(t)) return nil + } if val == "" { @@ -359,7 +348,7 @@ func setSlice(vals []string, value reflect.Value, field reflect.StructField) err return nil } -func setTimeDuration(val string, value reflect.Value) error { +func setTimeDuration(val string, value reflect.Value, field reflect.StructField) error { d, err := time.ParseDuration(val) if err != nil { return err @@ -382,7 +371,7 @@ func setFormMap(ptr interface{}, form map[string][]string) error { if el.Kind() == reflect.Slice { ptrMap, ok := ptr.(map[string][]string) if !ok { - return ErrConvertMapStringSlice + return errors.New("cannot convert to map slices of strings") } for k, v := range form { ptrMap[k] = v @@ -393,7 +382,7 @@ func setFormMap(ptr interface{}, form map[string][]string) error { ptrMap, ok := ptr.(map[string]string) if !ok { - return ErrConvertToMapString + return errors.New("cannot convert to map of strings") } for k, v := range form { ptrMap[k] = v[len(v)-1] // pick last diff --git a/vendor/github.com/gin-gonic/gin/binding/header.go b/vendor/github.com/gin-gonic/gin/binding/header.go index b99302af8..179ce4ea2 100644 --- a/vendor/github.com/gin-gonic/gin/binding/header.go +++ b/vendor/github.com/gin-gonic/gin/binding/header.go @@ -29,6 +29,6 @@ type headerSource map[string][]string var _ setter = headerSource(nil) -func (hs headerSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (bool, error) { +func (hs headerSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSetted bool, err error) { return setByForm(value, field, hs, textproto.CanonicalMIMEHeaderKey(tagValue), opt) } diff --git a/vendor/github.com/gin-gonic/gin/binding/json.go b/vendor/github.com/gin-gonic/gin/binding/json.go index 45aaa4948..d62e07059 100644 --- a/vendor/github.com/gin-gonic/gin/binding/json.go +++ b/vendor/github.com/gin-gonic/gin/binding/json.go @@ -6,7 +6,7 @@ package binding import ( "bytes" - "errors" + "fmt" "io" "net/http" @@ -32,7 +32,7 @@ func (jsonBinding) Name() string { func (jsonBinding) Bind(req *http.Request, obj interface{}) error { if req == nil || req.Body == nil { - return errors.New("invalid request") + return fmt.Errorf("invalid request") } return decodeJSON(req.Body, obj) } diff --git a/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go index 69c0a5443..f85a1aa60 100644 --- a/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go +++ b/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go @@ -15,16 +15,8 @@ type multipartRequest http.Request var _ setter = (*multipartRequest)(nil) -var ( - // ErrMultiFileHeader multipart.FileHeader invalid - ErrMultiFileHeader = errors.New("unsupported field type for multipart.FileHeader") - - // ErrMultiFileHeaderLenInvalid array for []*multipart.FileHeader len invalid - ErrMultiFileHeaderLenInvalid = errors.New("unsupported len of array for []*multipart.FileHeader") -) - // TrySet tries to set a value by the multipart request with the binding a form file -func (r *multipartRequest) TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (bool, error) { +func (r *multipartRequest) TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error) { if files := r.MultipartForm.File[key]; len(files) != 0 { return setByMultipartFormFile(value, field, files) } @@ -57,12 +49,12 @@ func setByMultipartFormFile(value reflect.Value, field reflect.StructField, file case reflect.Array: return setArrayOfMultipartFormFiles(value, field, files) } - return false, ErrMultiFileHeader + return false, errors.New("unsupported field type for multipart.FileHeader") } func setArrayOfMultipartFormFiles(value reflect.Value, field reflect.StructField, files []*multipart.FileHeader) (isSetted bool, err error) { if value.Len() != len(files) { - return false, ErrMultiFileHeaderLenInvalid + return false, errors.New("unsupported len of array for []*multipart.FileHeader") } for i := range files { setted, err := setByMultipartFormFile(value.Index(i), field, files[i:i+1]) diff --git a/vendor/github.com/gin-gonic/gin/binding/protobuf.go b/vendor/github.com/gin-gonic/gin/binding/protobuf.go index a4e471535..f9ece928d 100644 --- a/vendor/github.com/gin-gonic/gin/binding/protobuf.go +++ b/vendor/github.com/gin-gonic/gin/binding/protobuf.go @@ -5,11 +5,10 @@ package binding import ( - "errors" "io/ioutil" "net/http" - "google.golang.org/protobuf/proto" + "github.com/golang/protobuf/proto" ) type protobufBinding struct{} @@ -27,11 +26,7 @@ func (b protobufBinding) Bind(req *http.Request, obj interface{}) error { } func (protobufBinding) BindBody(body []byte, obj interface{}) error { - msg, ok := obj.(proto.Message) - if !ok { - return errors.New("obj is not ProtoMessage") - } - if err := proto.Unmarshal(body, msg); err != nil { + if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil { return err } // Here it's same to return validate(obj), but util now we can't add diff --git a/vendor/github.com/gin-gonic/gin/binding/uri.go b/vendor/github.com/gin-gonic/gin/binding/uri.go index a3c0df515..f91ec3819 100644 --- a/vendor/github.com/gin-gonic/gin/binding/uri.go +++ b/vendor/github.com/gin-gonic/gin/binding/uri.go @@ -11,7 +11,7 @@ func (uriBinding) Name() string { } func (uriBinding) BindUri(m map[string][]string, obj interface{}) error { - if err := mapURI(obj, m); err != nil { + if err := mapUri(obj, m); err != nil { return err } return validate(obj) diff --git a/vendor/github.com/gin-gonic/gin/context.go b/vendor/github.com/gin-gonic/gin/context.go index 62849488b..220d1bc7b 100644 --- a/vendor/github.com/gin-gonic/gin/context.go +++ b/vendor/github.com/gin-gonic/gin/context.go @@ -40,8 +40,7 @@ const ( // BodyBytesKey indicates a default body bytes key. const BodyBytesKey = "_gin-gonic/gin/bodybyteskey" -// abortIndex represents a typical value used in abort functions. -const abortIndex int8 = math.MaxInt8 >> 1 +const abortIndex int8 = math.MaxInt8 / 2 // Context is the most important part of gin. It allows us to pass variables between middleware, // manage the flow, validate the JSON of a request and render a JSON response for example. @@ -55,8 +54,9 @@ type Context struct { index int8 fullPath string - engine *Engine - params *Params + engine *Engine + params *Params + skippedNodes *[]skippedNode // This mutex protect Keys map mu sync.RWMutex @@ -88,17 +88,18 @@ type Context struct { func (c *Context) reset() { c.Writer = &c.writermem - c.Params = c.Params[:0] + c.Params = c.Params[0:0] c.handlers = nil c.index = -1 c.fullPath = "" c.Keys = nil - c.Errors = c.Errors[:0] + c.Errors = c.Errors[0:0] c.Accepted = nil c.queryCache = nil c.formCache = nil *c.params = (*c.params)[:0] + *c.skippedNodes = (*c.skippedNodes)[:0] } // Copy returns a copy of the current context that can be safely used outside the request's scope. @@ -383,15 +384,6 @@ func (c *Context) Param(key string) string { return c.Params.ByName(key) } -// AddParam adds param to context and -// replaces path param key with given value for e2e testing purposes -// Example Route: "/user/:id" -// AddParam("id", 1) -// Result: "/user/1" -func (c *Context) AddParam(key, value string) { - c.Params = append(c.Params, Param{Key: key, Value: value}) -} - // Query returns the keyed url query value if it exists, // otherwise it returns an empty string `("")`. // It is shortcut for `c.Request.URL.Query().Get(key)` @@ -400,9 +392,9 @@ func (c *Context) AddParam(key, value string) { // c.Query("name") == "Manu" // c.Query("value") == "" // c.Query("wtf") == "" -func (c *Context) Query(key string) (value string) { - value, _ = c.GetQuery(key) - return +func (c *Context) Query(key string) string { + value, _ := c.GetQuery(key) + return value } // DefaultQuery returns the keyed url query value if it exists, @@ -436,9 +428,9 @@ func (c *Context) GetQuery(key string) (string, bool) { // QueryArray returns a slice of strings for a given query key. // The length of the slice depends on the number of params with the given key. -func (c *Context) QueryArray(key string) (values []string) { - values, _ = c.GetQueryArray(key) - return +func (c *Context) QueryArray(key string) []string { + values, _ := c.GetQueryArray(key) + return values } func (c *Context) initQueryCache() { @@ -453,16 +445,18 @@ func (c *Context) initQueryCache() { // GetQueryArray returns a slice of strings for a given query key, plus // a boolean value whether at least one value exists for the given key. -func (c *Context) GetQueryArray(key string) (values []string, ok bool) { +func (c *Context) GetQueryArray(key string) ([]string, bool) { c.initQueryCache() - values, ok = c.queryCache[key] - return + if values, ok := c.queryCache[key]; ok && len(values) > 0 { + return values, true + } + return []string{}, false } // QueryMap returns a map for a given query key. -func (c *Context) QueryMap(key string) (dicts map[string]string) { - dicts, _ = c.GetQueryMap(key) - return +func (c *Context) QueryMap(key string) map[string]string { + dicts, _ := c.GetQueryMap(key) + return dicts } // GetQueryMap returns a map for a given query key, plus a boolean value @@ -474,9 +468,9 @@ func (c *Context) GetQueryMap(key string) (map[string]string, bool) { // PostForm returns the specified key from a POST urlencoded form or multipart form // when it exists, otherwise it returns an empty string `("")`. -func (c *Context) PostForm(key string) (value string) { - value, _ = c.GetPostForm(key) - return +func (c *Context) PostForm(key string) string { + value, _ := c.GetPostForm(key) + return value } // DefaultPostForm returns the specified key from a POST urlencoded form or multipart form @@ -505,9 +499,9 @@ func (c *Context) GetPostForm(key string) (string, bool) { // PostFormArray returns a slice of strings for a given form key. // The length of the slice depends on the number of params with the given key. -func (c *Context) PostFormArray(key string) (values []string) { - values, _ = c.GetPostFormArray(key) - return +func (c *Context) PostFormArray(key string) []string { + values, _ := c.GetPostFormArray(key) + return values } func (c *Context) initFormCache() { @@ -525,16 +519,18 @@ func (c *Context) initFormCache() { // GetPostFormArray returns a slice of strings for a given form key, plus // a boolean value whether at least one value exists for the given key. -func (c *Context) GetPostFormArray(key string) (values []string, ok bool) { +func (c *Context) GetPostFormArray(key string) ([]string, bool) { c.initFormCache() - values, ok = c.formCache[key] - return + if values := c.formCache[key]; len(values) > 0 { + return values, true + } + return []string{}, false } // PostFormMap returns a map for a given form key. -func (c *Context) PostFormMap(key string) (dicts map[string]string) { - dicts, _ = c.GetPostFormMap(key) - return +func (c *Context) PostFormMap(key string) map[string]string { + dicts, _ := c.GetPostFormMap(key) + return dicts } // GetPostFormMap returns a map for a given form key, plus a boolean value @@ -732,20 +728,16 @@ func (c *Context) ShouldBindBodyWith(obj interface{}, bb binding.BindingBody) (e return bb.BindBody(body, obj) } -// ClientIP implements a best effort algorithm to return the real client IP. +// ClientIP implements one best effort algorithm to return the real client IP. // It called c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not. -// If it's it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]). -// If the headers are nots syntactically valid OR the remote IP does not correspong to a trusted proxy, +// If it is it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]). +// If the headers are not syntactically valid OR the remote IP does not correspond to a trusted proxy, // the remote IP (coming form Request.RemoteAddr) is returned. func (c *Context) ClientIP() string { - // Check if we're running on a trusted platform - switch c.engine.TrustedPlatform { - case PlatformGoogleAppEngine: - if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" { - return addr - } - case PlatformCloudflare: - if addr := c.requestHeader("CF-Connecting-IP"); addr != "" { + // Check if we're running on a trusted platform, continue running backwards if error + if c.engine.TrustedPlatform != "" { + // Developers can define their own header of Trusted Platform or use predefined constants + if addr := c.requestHeader(c.engine.TrustedPlatform); addr != "" { return addr } } @@ -765,7 +757,7 @@ func (c *Context) ClientIP() string { if trusted && c.engine.ForwardedByClientIP && c.engine.RemoteIPHeaders != nil { for _, headerName := range c.engine.RemoteIPHeaders { - ip, valid := validateHeader(c.requestHeader(headerName)) + ip, valid := c.engine.validateHeader(c.requestHeader(headerName)) if valid { return ip } @@ -774,10 +766,21 @@ func (c *Context) ClientIP() string { return remoteIP.String() } +func (e *Engine) isTrustedProxy(ip net.IP) bool { + if e.trustedCIDRs != nil { + for _, cidr := range e.trustedCIDRs { + if cidr.Contains(ip) { + return true + } + } + } + return false +} + // RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port). // It also checks if the remoteIP is a trusted proxy or not. // In order to perform this validation, it will see if the IP is contained within at least one of the CIDR blocks -// defined in Engine.TrustedProxies +// defined by Engine.SetTrustedProxies() func (c *Context) RemoteIP() (net.IP, bool) { ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Request.RemoteAddr)) if err != nil { @@ -788,35 +791,25 @@ func (c *Context) RemoteIP() (net.IP, bool) { return nil, false } - if c.engine.trustedCIDRs != nil { - for _, cidr := range c.engine.trustedCIDRs { - if cidr.Contains(remoteIP) { - return remoteIP, true - } - } - } - - return remoteIP, false + return remoteIP, c.engine.isTrustedProxy(remoteIP) } -func validateHeader(header string) (clientIP string, valid bool) { +func (e *Engine) validateHeader(header string) (clientIP string, valid bool) { if header == "" { return "", false } items := strings.Split(header, ",") - for i, ipStr := range items { - ipStr = strings.TrimSpace(ipStr) + for i := len(items) - 1; i >= 0; i-- { + ipStr := strings.TrimSpace(items[i]) ip := net.ParseIP(ipStr) if ip == nil { return "", false } - // We need to return the first IP in the list, but, - // we should not early return since we need to validate that - // the rest of the header is syntactically valid - if i == 0 { - clientIP = ipStr - valid = true + // X-Forwarded-For is appended by proxy + // Check IPs in reverse order and stop when find untrusted proxy + if (i == 0) || (!e.isTrustedProxy(ip)) { + return ipStr, true } } return @@ -1166,28 +1159,22 @@ func (c *Context) SetAccepted(formats ...string) { /***** GOLANG.ORG/X/NET/CONTEXT *****/ /************************************/ -// Deadline returns that there is no deadline (ok==false) when c.Request has no Context. +// Deadline always returns that there is no deadline (ok==false), +// maybe you want to use Request.Context().Deadline() instead. func (c *Context) Deadline() (deadline time.Time, ok bool) { - if c.Request == nil || c.Request.Context() == nil { - return - } - return c.Request.Context().Deadline() + return } -// Done returns nil (chan which will wait forever) when c.Request has no Context. +// Done always returns nil (chan which will wait forever), +// if you want to abort your work when the connection was closed +// you should use Request.Context().Done() instead. func (c *Context) Done() <-chan struct{} { - if c.Request == nil || c.Request.Context() == nil { - return nil - } - return c.Request.Context().Done() + return nil } -// Err returns nil when c.Request has no Context. +// Err always returns nil, maybe you want to use Request.Context().Err() instead. func (c *Context) Err() error { - if c.Request == nil || c.Request.Context() == nil { - return nil - } - return c.Request.Context().Err() + return nil } // Value returns the value associated with this context for key, or nil @@ -1198,12 +1185,8 @@ func (c *Context) Value(key interface{}) interface{} { return c.Request } if keyAsString, ok := key.(string); ok { - if val, exists := c.Get(keyAsString); exists { - return val - } + val, _ := c.Get(keyAsString) + return val } - if c.Request == nil || c.Request.Context() == nil { - return nil - } - return c.Request.Context().Value(key) + return nil } diff --git a/vendor/github.com/gin-gonic/gin/debug.go b/vendor/github.com/gin-gonic/gin/debug.go index ed313868e..9bacc6857 100644 --- a/vendor/github.com/gin-gonic/gin/debug.go +++ b/vendor/github.com/gin-gonic/gin/debug.go @@ -95,7 +95,9 @@ at initialization. ie. before any route is registered or the router is listening } func debugPrintError(err error) { - if err != nil && IsDebugging() { - fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err) + if err != nil { + if IsDebugging() { + fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err) + } } } diff --git a/vendor/github.com/gin-gonic/gin/fs.go b/vendor/github.com/gin-gonic/gin/fs.go index e5f3d602a..007d9b755 100644 --- a/vendor/github.com/gin-gonic/gin/fs.go +++ b/vendor/github.com/gin-gonic/gin/fs.go @@ -17,7 +17,7 @@ type neuteredReaddirFile struct { http.File } -// Dir returns a http.FileSystem that can be used by http.FileServer(). It is used internally +// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally // in router.Static(). // if listDirectory == true, then it works the same as http.Dir() otherwise it returns // a filesystem that prevents http.FileServer() to list the directory files. diff --git a/vendor/github.com/gin-gonic/gin/gin.go b/vendor/github.com/gin-gonic/gin/gin.go index 6ab2be66d..58e76f41f 100644 --- a/vendor/github.com/gin-gonic/gin/gin.go +++ b/vendor/github.com/gin-gonic/gin/gin.go @@ -11,6 +11,7 @@ import ( "net/http" "os" "path" + "reflect" "strings" "sync" @@ -27,6 +28,8 @@ var ( var defaultPlatform string +var defaultTrustedCIDRs = []*net.IPNet{{IP: net.IP{0x0, 0x0, 0x0, 0x0}, Mask: net.IPMask{0x0, 0x0, 0x0, 0x0}}} // 0.0.0.0/0 + // HandlerFunc defines the handler used by gin middleware as return value. type HandlerFunc func(*Context) @@ -56,10 +59,10 @@ type RoutesInfo []RouteInfo const ( // When running on Google App Engine. Trust X-Appengine-Remote-Addr // for determining the client's IP - PlatformGoogleAppEngine = "google-app-engine" + PlatformGoogleAppEngine = "X-Appengine-Remote-Addr" // When using Cloudflare's CDN. Trust CF-Connecting-IP for determining // the client's IP - PlatformCloudflare = "cloudflare" + PlatformCloudflare = "CF-Connecting-IP" ) // Engine is the framework's instance, it contains the muxer, middleware and configuration settings. @@ -119,15 +122,9 @@ type Engine struct { // List of headers used to obtain the client IP when // `(*gin.Engine).ForwardedByClientIP` is `true` and // `(*gin.Context).Request.RemoteAddr` is matched by at least one of the - // network origins of `(*gin.Engine).TrustedProxies`. + // network origins of list defined by `(*gin.Engine).SetTrustedProxies()`. RemoteIPHeaders []string - // List of network origins (IPv4 addresses, IPv4 CIDRs, IPv6 addresses or - // IPv6 CIDRs) from which to trust request's headers that contain - // alternative client IP when `(*gin.Engine).ForwardedByClientIP` is - // `true`. - TrustedProxies []string - // If set to a constant of value gin.Platform*, trusts the headers set by // that platform, for example to determine the client IP TrustedPlatform string @@ -147,6 +144,8 @@ type Engine struct { pool sync.Pool trees methodTrees maxParams uint16 + maxSections uint16 + trustedProxies []string trustedCIDRs []*net.IPNet } @@ -174,7 +173,6 @@ func New() *Engine { HandleMethodNotAllowed: false, ForwardedByClientIP: true, RemoteIPHeaders: []string{"X-Forwarded-For", "X-Real-IP"}, - TrustedProxies: []string{"0.0.0.0/0"}, TrustedPlatform: defaultPlatform, UseRawPath: false, RemoveExtraSlash: false, @@ -183,6 +181,8 @@ func New() *Engine { trees: make(methodTrees, 0, 9), delims: render.Delims{Left: "{{", Right: "}}"}, secureJSONPrefix: "while(1);", + trustedProxies: []string{"0.0.0.0/0"}, + trustedCIDRs: defaultTrustedCIDRs, } engine.RouterGroup.engine = engine engine.pool.New = func() interface{} { @@ -201,7 +201,8 @@ func Default() *Engine { func (engine *Engine) allocateContext() *Context { v := make(Params, 0, engine.maxParams) - return &Context{engine: engine, params: &v} + skippedNodes := make([]skippedNode, 0, engine.maxSections) + return &Context{engine: engine, params: &v, skippedNodes: &skippedNodes} } // Delims sets template left and right delims and returns a Engine instance. @@ -264,7 +265,7 @@ func (engine *Engine) NoRoute(handlers ...HandlerFunc) { engine.rebuild404Handlers() } -// NoMethod sets the handlers called when... TODO. +// NoMethod sets the handlers called when Engine.HandleMethodNotAllowed = true. func (engine *Engine) NoMethod(handlers ...HandlerFunc) { engine.noMethod = handlers engine.rebuild405Handlers() @@ -307,6 +308,10 @@ func (engine *Engine) addRoute(method, path string, handlers HandlersChain) { if paramsCount := countParams(path); paramsCount > engine.maxParams { engine.maxParams = paramsCount } + + if sectionsCount := countSections(path); sectionsCount > engine.maxSections { + engine.maxSections = sectionsCount + } } // Routes returns a slice of registered routes, including some useful information, such as: @@ -341,9 +346,9 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo { func (engine *Engine) Run(addr ...string) (err error) { defer func() { debugPrintError(err) }() - err = engine.parseTrustedProxies() - if err != nil { - return err + if engine.isUnsafeTrustedProxies() { + debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + + "Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.") } address := resolveAddress(addr) @@ -353,12 +358,12 @@ func (engine *Engine) Run(addr ...string) (err error) { } func (engine *Engine) prepareTrustedCIDRs() ([]*net.IPNet, error) { - if engine.TrustedProxies == nil { + if engine.trustedProxies == nil { return nil, nil } - cidr := make([]*net.IPNet, 0, len(engine.TrustedProxies)) - for _, trustedProxy := range engine.TrustedProxies { + cidr := make([]*net.IPNet, 0, len(engine.trustedProxies)) + for _, trustedProxy := range engine.trustedProxies { if !strings.Contains(trustedProxy, "/") { ip := parseIP(trustedProxy) if ip == nil { @@ -381,13 +386,25 @@ func (engine *Engine) prepareTrustedCIDRs() ([]*net.IPNet, error) { return cidr, nil } -// SetTrustedProxies set Engine.TrustedProxies +// SetTrustedProxies set a list of network origins (IPv4 addresses, +// IPv4 CIDRs, IPv6 addresses or IPv6 CIDRs) from which to trust +// request's headers that contain alternative client IP when +// `(*gin.Engine).ForwardedByClientIP` is `true`. `TrustedProxies` +// feature is enabled by default, and it also trusts all proxies +// by default. If you want to disable this feature, use +// Engine.SetTrustedProxies(nil), then Context.ClientIP() will +// return the remote address directly. func (engine *Engine) SetTrustedProxies(trustedProxies []string) error { - engine.TrustedProxies = trustedProxies + engine.trustedProxies = trustedProxies return engine.parseTrustedProxies() } -// parseTrustedProxies parse Engine.TrustedProxies to Engine.trustedCIDRs +// isUnsafeTrustedProxies compares Engine.trustedCIDRs and defaultTrustedCIDRs, it's not safe if equal (returns true) +func (engine *Engine) isUnsafeTrustedProxies() bool { + return reflect.DeepEqual(engine.trustedCIDRs, defaultTrustedCIDRs) +} + +// parseTrustedProxies parse Engine.trustedProxies to Engine.trustedCIDRs func (engine *Engine) parseTrustedProxies() error { trustedCIDRs, err := engine.prepareTrustedCIDRs() engine.trustedCIDRs = trustedCIDRs @@ -415,9 +432,9 @@ func (engine *Engine) RunTLS(addr, certFile, keyFile string) (err error) { debugPrint("Listening and serving HTTPS on %s\n", addr) defer func() { debugPrintError(err) }() - err = engine.parseTrustedProxies() - if err != nil { - return err + if engine.isUnsafeTrustedProxies() { + debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + + "Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.") } err = http.ListenAndServeTLS(addr, certFile, keyFile, engine) @@ -431,9 +448,9 @@ func (engine *Engine) RunUnix(file string) (err error) { debugPrint("Listening and serving HTTP on unix:/%s", file) defer func() { debugPrintError(err) }() - err = engine.parseTrustedProxies() - if err != nil { - return err + if engine.isUnsafeTrustedProxies() { + debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + + "Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.") } listener, err := net.Listen("unix", file) @@ -454,9 +471,9 @@ func (engine *Engine) RunFd(fd int) (err error) { debugPrint("Listening and serving HTTP on fd@%d", fd) defer func() { debugPrintError(err) }() - err = engine.parseTrustedProxies() - if err != nil { - return err + if engine.isUnsafeTrustedProxies() { + debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + + "Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.") } f := os.NewFile(uintptr(fd), fmt.Sprintf("fd@%d", fd)) @@ -475,9 +492,9 @@ func (engine *Engine) RunListener(listener net.Listener) (err error) { debugPrint("Listening and serving HTTP on listener what's bind with address@%s", listener.Addr()) defer func() { debugPrintError(err) }() - err = engine.parseTrustedProxies() - if err != nil { - return err + if engine.isUnsafeTrustedProxies() { + debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + + "Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.") } err = http.Serve(listener, engine) @@ -528,7 +545,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) { } root := t[i].root // Find route in tree - value := root.getValue(rPath, c.params, unescape) + value := root.getValue(rPath, c.params, c.skippedNodes, unescape) if value.params != nil { c.Params = *value.params } @@ -539,7 +556,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) { c.writermem.WriteHeaderNow() return } - if httpMethod != http.MethodConnect && rPath != "/" { + if httpMethod != "CONNECT" && rPath != "/" { if value.tsr && engine.RedirectTrailingSlash { redirectTrailingSlash(c) return @@ -556,7 +573,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) { if tree.method == httpMethod { continue } - if value := tree.root.getValue(rPath, nil, unescape); value.handlers != nil { + if value := tree.root.getValue(rPath, nil, c.skippedNodes, unescape); value.handlers != nil { c.handlers = engine.allNoMethod serveError(c, http.StatusMethodNotAllowed, default405Body) return diff --git a/vendor/github.com/gin-gonic/gin/internal/json/go_json.go b/vendor/github.com/gin-gonic/gin/internal/json/go_json.go deleted file mode 100644 index da960571a..000000000 --- a/vendor/github.com/gin-gonic/gin/internal/json/go_json.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Bo-Yi Wu. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -//go:build go_json -// +build go_json - -package json - -import json "github.com/goccy/go-json" - -var ( - // Marshal is exported by gin/json package. - Marshal = json.Marshal - // Unmarshal is exported by gin/json package. - Unmarshal = json.Unmarshal - // MarshalIndent is exported by gin/json package. - MarshalIndent = json.MarshalIndent - // NewDecoder is exported by gin/json package. - NewDecoder = json.NewDecoder - // NewEncoder is exported by gin/json package. - NewEncoder = json.NewEncoder -) diff --git a/vendor/github.com/gin-gonic/gin/internal/json/json.go b/vendor/github.com/gin-gonic/gin/internal/json/json.go index 75b602240..172aeb241 100644 --- a/vendor/github.com/gin-gonic/gin/internal/json/json.go +++ b/vendor/github.com/gin-gonic/gin/internal/json/json.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a MIT style // license that can be found in the LICENSE file. -//go:build !jsoniter && !go_json -// +build !jsoniter,!go_json +//go:build !jsoniter +// +build !jsoniter package json diff --git a/vendor/github.com/gin-gonic/gin/logger.go b/vendor/github.com/gin-gonic/gin/logger.go index 22138a8d3..d361b74d3 100644 --- a/vendor/github.com/gin-gonic/gin/logger.go +++ b/vendor/github.com/gin-gonic/gin/logger.go @@ -138,7 +138,8 @@ var defaultLogFormatter = func(param LogFormatterParams) string { } if param.Latency > time.Minute { - param.Latency = param.Latency.Truncate(time.Second) + // Truncate in a golang < 1.8 safe way + param.Latency = param.Latency - param.Latency%time.Second } return fmt.Sprintf("[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %#v\n%s", param.TimeStamp.Format("2006/01/02 - 15:04:05"), diff --git a/vendor/github.com/gin-gonic/gin/mode.go b/vendor/github.com/gin-gonic/gin/mode.go index 4d199df30..c8813aff2 100644 --- a/vendor/github.com/gin-gonic/gin/mode.go +++ b/vendor/github.com/gin-gonic/gin/mode.go @@ -41,10 +41,8 @@ var DefaultWriter io.Writer = os.Stdout // DefaultErrorWriter is the default io.Writer used by Gin to debug errors var DefaultErrorWriter io.Writer = os.Stderr -var ( - ginMode = debugCode - modeName = DebugMode -) +var ginMode = debugCode +var modeName = DebugMode func init() { mode := os.Getenv(EnvGinMode) diff --git a/vendor/github.com/gin-gonic/gin/recovery.go b/vendor/github.com/gin-gonic/gin/recovery.go index 3101fe28a..563f5aaa8 100644 --- a/vendor/github.com/gin-gonic/gin/recovery.go +++ b/vendor/github.com/gin-gonic/gin/recovery.go @@ -34,7 +34,7 @@ func Recovery() HandlerFunc { return RecoveryWithWriter(DefaultErrorWriter) } -// CustomRecovery returns a middleware that recovers from any panics and calls the provided handle func to handle it. +//CustomRecovery returns a middleware that recovers from any panics and calls the provided handle func to handle it. func CustomRecovery(handle RecoveryFunc) HandlerFunc { return RecoveryWithWriter(DefaultErrorWriter, handle) } @@ -165,7 +165,7 @@ func function(pc uintptr) []byte { return name } -// timeFormat returns a customized time string for logger. func timeFormat(t time.Time) string { - return t.Format("2006/01/02 - 15:04:05") + timeString := t.Format("2006/01/02 - 15:04:05") + return timeString } diff --git a/vendor/github.com/gin-gonic/gin/render/json.go b/vendor/github.com/gin-gonic/gin/render/json.go index 3ebcee970..418630939 100644 --- a/vendor/github.com/gin-gonic/gin/render/json.go +++ b/vendor/github.com/gin-gonic/gin/render/json.go @@ -46,11 +46,9 @@ type PureJSON struct { Data interface{} } -var ( - jsonContentType = []string{"application/json; charset=utf-8"} - jsonpContentType = []string{"application/javascript; charset=utf-8"} - jsonASCIIContentType = []string{"application/json"} -) +var jsonContentType = []string{"application/json; charset=utf-8"} +var jsonpContentType = []string{"application/javascript; charset=utf-8"} +var jsonAsciiContentType = []string{"application/json"} // Render (JSON) writes data with custom ContentType. func (r JSON) Render(w http.ResponseWriter) (err error) { @@ -102,7 +100,8 @@ func (r SecureJSON) Render(w http.ResponseWriter) error { // if the jsonBytes is array values if bytes.HasPrefix(jsonBytes, bytesconv.StringToBytes("[")) && bytes.HasSuffix(jsonBytes, bytesconv.StringToBytes("]")) { - if _, err = w.Write(bytesconv.StringToBytes(r.Prefix)); err != nil { + _, err = w.Write(bytesconv.StringToBytes(r.Prefix)) + if err != nil { return err } } @@ -129,19 +128,20 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) { } callback := template.JSEscapeString(r.Callback) - if _, err = w.Write(bytesconv.StringToBytes(callback)); err != nil { + _, err = w.Write(bytesconv.StringToBytes(callback)) + if err != nil { return err } - - if _, err = w.Write(bytesconv.StringToBytes("(")); err != nil { + _, err = w.Write(bytesconv.StringToBytes("(")) + if err != nil { return err } - - if _, err = w.Write(ret); err != nil { + _, err = w.Write(ret) + if err != nil { return err } - - if _, err = w.Write(bytesconv.StringToBytes(");")); err != nil { + _, err = w.Write(bytesconv.StringToBytes(");")) + if err != nil { return err } @@ -176,7 +176,7 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) { // WriteContentType (AsciiJSON) writes JSON ContentType. func (r AsciiJSON) WriteContentType(w http.ResponseWriter) { - writeContentType(w, jsonASCIIContentType) + writeContentType(w, jsonAsciiContentType) } // Render (PureJSON) writes custom ContentType and encodes the given interface object. diff --git a/vendor/github.com/gin-gonic/gin/render/msgpack.go b/vendor/github.com/gin-gonic/gin/render/msgpack.go index 7f17ca4d9..6ef5b6e51 100644 --- a/vendor/github.com/gin-gonic/gin/render/msgpack.go +++ b/vendor/github.com/gin-gonic/gin/render/msgpack.go @@ -13,8 +13,6 @@ import ( "github.com/ugorji/go/codec" ) -// Check interface implemented here to support go build tag nomsgpack. -// See: https://github.com/gin-gonic/gin/pull/1852/ var ( _ Render = MsgPack{} ) diff --git a/vendor/github.com/gin-gonic/gin/render/protobuf.go b/vendor/github.com/gin-gonic/gin/render/protobuf.go index 1d2aa871c..15aca9959 100644 --- a/vendor/github.com/gin-gonic/gin/render/protobuf.go +++ b/vendor/github.com/gin-gonic/gin/render/protobuf.go @@ -7,7 +7,7 @@ package render import ( "net/http" - "google.golang.org/protobuf/proto" + "github.com/golang/protobuf/proto" ) // ProtoBuf contains the given interface object. diff --git a/vendor/github.com/gin-gonic/gin/routergroup.go b/vendor/github.com/gin-gonic/gin/routergroup.go index bb24bd523..15d9930d3 100644 --- a/vendor/github.com/gin-gonic/gin/routergroup.go +++ b/vendor/github.com/gin-gonic/gin/routergroup.go @@ -11,11 +11,6 @@ import ( "strings" ) -var ( - // reg match english letters for http method name - regEnLetter = regexp.MustCompile("^[A-Z]+$") -) - // IRouter defines all router handle interface includes single and group router. type IRouter interface { IRoutes @@ -92,7 +87,7 @@ func (group *RouterGroup) handle(httpMethod, relativePath string, handlers Handl // frequently used, non-standardized or custom methods (e.g. for internal // communication with a proxy). func (group *RouterGroup) Handle(httpMethod, relativePath string, handlers ...HandlerFunc) IRoutes { - if matched := regEnLetter.MatchString(httpMethod); !matched { + if matches, err := regexp.MatchString("^[A-Z]+$", httpMethod); !matches || err != nil { panic("http method " + httpMethod + " is not valid") } return group.handle(httpMethod, relativePath, handlers) @@ -214,7 +209,9 @@ func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileS func (group *RouterGroup) combineHandlers(handlers HandlersChain) HandlersChain { finalSize := len(group.Handlers) + len(handlers) - assert1(finalSize < int(abortIndex), "too many handlers") + if finalSize >= int(abortIndex) { + panic("too many handlers") + } mergedHandlers := make(HandlersChain, finalSize) copy(mergedHandlers, group.Handlers) copy(mergedHandlers[len(group.Handlers):], handlers) diff --git a/vendor/github.com/gin-gonic/gin/tree.go b/vendor/github.com/gin-gonic/gin/tree.go index fb0a5935c..158a33908 100644 --- a/vendor/github.com/gin-gonic/gin/tree.go +++ b/vendor/github.com/gin-gonic/gin/tree.go @@ -17,6 +17,7 @@ import ( var ( strColon = []byte(":") strStar = []byte("*") + strSlash = []byte("/") ) // Param is a single URL parameter, consisting of a key and a value. @@ -30,8 +31,8 @@ type Param struct { // It is therefore safe to read values by the index. type Params []Param -// Get returns the value of the first Param which key matches the given name and a boolean true. -// If no matching Param is found, an empty string is returned and a boolean false . +// Get returns the value of the first Param which key matches the given name. +// If no matching Param is found, an empty string is returned. func (ps Params) Get(name string) (string, bool) { for _, entry := range ps { if entry.Key == name { @@ -98,10 +99,16 @@ func countParams(path string) uint16 { return n } +func countSections(path string) uint16 { + s := bytesconv.StringToBytes(path) + return uint16(bytes.Count(s, strSlash)) +} + type nodeType uint8 const ( - root nodeType = iota + 1 + static nodeType = iota // default + root param catchAll ) @@ -393,16 +400,19 @@ type nodeValue struct { fullPath string } +type skippedNode struct { + path string + node *node + paramsCount int16 +} + // Returns the handle registered with the given path (key). The values of // wildcards are saved to a map. // If no handle can be found, a TSR (trailing slash redirect) recommendation is // made if a handle exists with an extra (without the) trailing slash for the // given path. -func (n *node) getValue(path string, params *Params, unescape bool) (value nodeValue) { - var ( - skippedPath string - latestNode = n // Caching the latest node - ) +func (n *node) getValue(path string, params *Params, skippedNodes *[]skippedNode, unescape bool) (value nodeValue) { + var globalParamsCount int16 walk: // Outer loop for walking the tree for { @@ -417,15 +427,20 @@ walk: // Outer loop for walking the tree if c == idxc { // strings.HasPrefix(n.children[len(n.children)-1].path, ":") == n.wildChild if n.wildChild { - skippedPath = prefix + path - latestNode = &node{ - path: n.path, - wildChild: n.wildChild, - nType: n.nType, - priority: n.priority, - children: n.children, - handlers: n.handlers, - fullPath: n.fullPath, + index := len(*skippedNodes) + *skippedNodes = (*skippedNodes)[:index+1] + (*skippedNodes)[index] = skippedNode{ + path: prefix + path, + node: &node{ + path: n.path, + wildChild: n.wildChild, + nType: n.nType, + priority: n.priority, + children: n.children, + handlers: n.handlers, + fullPath: n.fullPath, + }, + paramsCount: globalParamsCount, } } @@ -433,15 +448,26 @@ walk: // Outer loop for walking the tree continue walk } } - // If the path at the end of the loop is not equal to '/' and the current node has no child nodes - // the current node needs to be equal to the latest matching node - matched := path != "/" && !n.wildChild - if matched { - n = latestNode - } - // If there is no wildcard pattern, recommend a redirection if !n.wildChild { + // If the path at the end of the loop is not equal to '/' and the current node has no child nodes + // the current node needs to roll back to last vaild skippedNode + if path != "/" { + for l := len(*skippedNodes); l > 0; { + skippedNode := (*skippedNodes)[l-1] + *skippedNodes = (*skippedNodes)[:l-1] + if strings.HasSuffix(skippedNode.path, path) { + path = skippedNode.path + n = skippedNode.node + if value.params != nil { + *value.params = (*value.params)[:skippedNode.paramsCount] + } + globalParamsCount = skippedNode.paramsCount + continue walk + } + } + } + // Nothing found. // We can recommend to redirect to the same URL without a // trailing slash if a leaf exists for that path. @@ -451,18 +477,12 @@ walk: // Outer loop for walking the tree // Handle wildcard child, which is always at the end of the array n = n.children[len(n.children)-1] + globalParamsCount++ switch n.nType { case param: // fix truncate the parameter // tree_test.go line: 204 - if matched { - path = prefix + path - // The saved path is used after the prefix route is intercepted by matching - if n.indices == "/" { - path = skippedPath[1:] - } - } // Find param end (either '/' or path end) end := 0 @@ -548,9 +568,22 @@ walk: // Outer loop for walking the tree if path == prefix { // If the current path does not equal '/' and the node does not have a registered handle and the most recently matched node has a child node - // the current node needs to be equal to the latest matching node - if latestNode.wildChild && n.handlers == nil && path != "/" { - n = latestNode.children[len(latestNode.children)-1] + // the current node needs to roll back to last vaild skippedNode + if n.handlers == nil && path != "/" { + for l := len(*skippedNodes); l > 0; { + skippedNode := (*skippedNodes)[l-1] + *skippedNodes = (*skippedNodes)[:l-1] + if strings.HasSuffix(skippedNode.path, path) { + path = skippedNode.path + n = skippedNode.node + if value.params != nil { + *value.params = (*value.params)[:skippedNode.paramsCount] + } + globalParamsCount = skippedNode.paramsCount + continue walk + } + } + // n = latestNode.children[len(latestNode.children)-1] } // We should have reached the node containing the handle. // Check if this node has a handle registered. @@ -581,25 +614,29 @@ walk: // Outer loop for walking the tree return } - if path != "/" && len(skippedPath) > 0 && strings.HasSuffix(skippedPath, path) { - path = skippedPath - // Reduce the number of cycles - n, latestNode = latestNode, n - // skippedPath cannot execute - // example: - // * /:cc/cc - // call /a/cc expectations:match/200 Actual:match/200 - // call /a/dd expectations:unmatch/404 Actual: panic - // call /addr/dd/aa expectations:unmatch/404 Actual: panic - // skippedPath: It can only be executed if the secondary route is not found - skippedPath = "" - continue walk - } - // Nothing found. We can recommend to redirect to the same URL with an // extra trailing slash if a leaf exists for that path value.tsr = path == "/" || - (len(prefix) == len(path)+1 && n.handlers != nil) + (len(prefix) == len(path)+1 && prefix[len(path)] == '/' && + path == prefix[:len(prefix)-1] && n.handlers != nil) + + // roll back to last valid skippedNode + if !value.tsr && path != "/" { + for l := len(*skippedNodes); l > 0; { + skippedNode := (*skippedNodes)[l-1] + *skippedNodes = (*skippedNodes)[:l-1] + if strings.HasSuffix(skippedNode.path, path) { + path = skippedNode.path + n = skippedNode.node + if value.params != nil { + *value.params = (*value.params)[:skippedNode.paramsCount] + } + globalParamsCount = skippedNode.paramsCount + continue walk + } + } + } + return } } diff --git a/vendor/github.com/gin-gonic/gin/version.go b/vendor/github.com/gin-gonic/gin/version.go index 535bfc827..4b69b9b91 100644 --- a/vendor/github.com/gin-gonic/gin/version.go +++ b/vendor/github.com/gin-gonic/gin/version.go @@ -5,4 +5,4 @@ package gin // Version is the current gin framework's version. -const Version = "v1.7.3" +const Version = "v1.7.7" diff --git a/vendor/github.com/go-errors/errors/.travis.yml b/vendor/github.com/go-errors/errors/.travis.yml index fddfc4e3a..77a6bccf7 100644 --- a/vendor/github.com/go-errors/errors/.travis.yml +++ b/vendor/github.com/go-errors/errors/.travis.yml @@ -5,3 +5,4 @@ go: - "1.10.x" - "1.13.x" - "1.14.x" + - "1.16.x" diff --git a/vendor/github.com/go-errors/errors/README.md b/vendor/github.com/go-errors/errors/README.md index d03882f1b..2ee13f117 100644 --- a/vendor/github.com/go-errors/errors/README.md +++ b/vendor/github.com/go-errors/errors/README.md @@ -78,3 +78,4 @@ This package is licensed under the MIT license, see LICENSE.MIT for details. >. errors.AsError(errors.Wrap(err)).ErrorStack() > ``` * v1.4.0 *BREAKING* v1.4.0 reverted all changes from v1.3.0 and is identical to v1.2.0 +* v1.4.1 no code change, but now without an unnecessary cover.out file. diff --git a/vendor/github.com/go-errors/errors/cover.out b/vendor/github.com/go-errors/errors/cover.out deleted file mode 100644 index ab18b0519..000000000 --- a/vendor/github.com/go-errors/errors/cover.out +++ /dev/null @@ -1,89 +0,0 @@ -mode: set -github.com/go-errors/errors/stackframe.go:27.51,30.25 2 1 -github.com/go-errors/errors/stackframe.go:33.2,38.8 3 1 -github.com/go-errors/errors/stackframe.go:30.25,32.3 1 0 -github.com/go-errors/errors/stackframe.go:43.47,44.31 1 1 -github.com/go-errors/errors/stackframe.go:47.2,47.48 1 1 -github.com/go-errors/errors/stackframe.go:44.31,46.3 1 1 -github.com/go-errors/errors/stackframe.go:52.42,56.16 3 1 -github.com/go-errors/errors/stackframe.go:60.2,60.60 1 1 -github.com/go-errors/errors/stackframe.go:56.16,58.3 1 0 -github.com/go-errors/errors/stackframe.go:64.55,67.16 2 1 -github.com/go-errors/errors/stackframe.go:71.2,72.61 2 1 -github.com/go-errors/errors/stackframe.go:76.2,76.66 1 1 -github.com/go-errors/errors/stackframe.go:67.16,69.3 1 0 -github.com/go-errors/errors/stackframe.go:72.61,74.3 1 0 -github.com/go-errors/errors/stackframe.go:79.56,91.63 3 1 -github.com/go-errors/errors/stackframe.go:95.2,95.53 1 1 -github.com/go-errors/errors/stackframe.go:100.2,101.18 2 1 -github.com/go-errors/errors/stackframe.go:91.63,94.3 2 1 -github.com/go-errors/errors/stackframe.go:95.53,98.3 2 1 -github.com/go-errors/errors/error.go:70.32,73.23 2 1 -github.com/go-errors/errors/error.go:80.2,85.3 3 1 -github.com/go-errors/errors/error.go:74.2,75.10 1 1 -github.com/go-errors/errors/error.go:76.2,77.28 1 1 -github.com/go-errors/errors/error.go:92.43,95.23 2 1 -github.com/go-errors/errors/error.go:104.2,109.3 3 1 -github.com/go-errors/errors/error.go:96.2,97.11 1 1 -github.com/go-errors/errors/error.go:98.2,99.10 1 1 -github.com/go-errors/errors/error.go:100.2,101.28 1 1 -github.com/go-errors/errors/error.go:115.39,117.19 1 1 -github.com/go-errors/errors/error.go:121.2,121.29 1 1 -github.com/go-errors/errors/error.go:125.2,125.43 1 1 -github.com/go-errors/errors/error.go:129.2,129.14 1 1 -github.com/go-errors/errors/error.go:117.19,119.3 1 1 -github.com/go-errors/errors/error.go:121.29,123.3 1 1 -github.com/go-errors/errors/error.go:125.43,127.3 1 1 -github.com/go-errors/errors/error.go:135.53,137.2 1 1 -github.com/go-errors/errors/error.go:140.34,142.2 1 1 -github.com/go-errors/errors/error.go:146.34,149.42 2 1 -github.com/go-errors/errors/error.go:153.2,153.20 1 1 -github.com/go-errors/errors/error.go:149.42,151.3 1 1 -github.com/go-errors/errors/error.go:158.39,160.2 1 1 -github.com/go-errors/errors/error.go:164.46,165.23 1 1 -github.com/go-errors/errors/error.go:173.2,173.19 1 1 -github.com/go-errors/errors/error.go:165.23,168.32 2 1 -github.com/go-errors/errors/error.go:168.32,170.4 1 1 -github.com/go-errors/errors/error.go:177.37,178.42 1 1 -github.com/go-errors/errors/error.go:181.2,181.41 1 1 -github.com/go-errors/errors/error.go:178.42,180.3 1 1 -github.com/go-errors/errors/parse_panic.go:10.39,12.2 1 1 -github.com/go-errors/errors/parse_panic.go:16.46,24.34 5 1 -github.com/go-errors/errors/parse_panic.go:70.2,70.43 1 1 -github.com/go-errors/errors/parse_panic.go:73.2,73.55 1 0 -github.com/go-errors/errors/parse_panic.go:24.34,27.23 2 1 -github.com/go-errors/errors/parse_panic.go:27.23,28.42 1 1 -github.com/go-errors/errors/parse_panic.go:28.42,31.5 2 1 -github.com/go-errors/errors/parse_panic.go:31.6,33.5 1 0 -github.com/go-errors/errors/parse_panic.go:35.5,35.29 1 1 -github.com/go-errors/errors/parse_panic.go:35.29,36.86 1 1 -github.com/go-errors/errors/parse_panic.go:36.86,38.5 1 1 -github.com/go-errors/errors/parse_panic.go:40.5,40.32 1 1 -github.com/go-errors/errors/parse_panic.go:40.32,41.18 1 1 -github.com/go-errors/errors/parse_panic.go:45.4,46.46 2 1 -github.com/go-errors/errors/parse_panic.go:51.4,53.23 2 1 -github.com/go-errors/errors/parse_panic.go:57.4,58.18 2 1 -github.com/go-errors/errors/parse_panic.go:62.4,63.17 2 1 -github.com/go-errors/errors/parse_panic.go:41.18,43.10 2 1 -github.com/go-errors/errors/parse_panic.go:46.46,49.5 2 1 -github.com/go-errors/errors/parse_panic.go:53.23,55.5 1 0 -github.com/go-errors/errors/parse_panic.go:58.18,60.5 1 0 -github.com/go-errors/errors/parse_panic.go:63.17,65.10 2 1 -github.com/go-errors/errors/parse_panic.go:70.43,72.3 1 1 -github.com/go-errors/errors/parse_panic.go:80.85,82.29 2 1 -github.com/go-errors/errors/parse_panic.go:85.2,85.15 1 1 -github.com/go-errors/errors/parse_panic.go:88.2,90.63 2 1 -github.com/go-errors/errors/parse_panic.go:94.2,94.53 1 1 -github.com/go-errors/errors/parse_panic.go:99.2,101.36 2 1 -github.com/go-errors/errors/parse_panic.go:105.2,106.15 2 1 -github.com/go-errors/errors/parse_panic.go:109.2,112.49 3 1 -github.com/go-errors/errors/parse_panic.go:116.2,117.16 2 1 -github.com/go-errors/errors/parse_panic.go:121.2,126.8 1 1 -github.com/go-errors/errors/parse_panic.go:82.29,84.3 1 0 -github.com/go-errors/errors/parse_panic.go:85.15,87.3 1 1 -github.com/go-errors/errors/parse_panic.go:90.63,93.3 2 1 -github.com/go-errors/errors/parse_panic.go:94.53,97.3 2 1 -github.com/go-errors/errors/parse_panic.go:101.36,103.3 1 0 -github.com/go-errors/errors/parse_panic.go:106.15,108.3 1 0 -github.com/go-errors/errors/parse_panic.go:112.49,114.3 1 1 -github.com/go-errors/errors/parse_panic.go:117.16,119.3 1 0 diff --git a/vendor/github.com/goccy/go-json/.codecov.yml b/vendor/github.com/goccy/go-json/.codecov.yml deleted file mode 100644 index e98134570..000000000 --- a/vendor/github.com/goccy/go-json/.codecov.yml +++ /dev/null @@ -1,32 +0,0 @@ -codecov: - require_ci_to_pass: yes - -coverage: - precision: 2 - round: down - range: "70...100" - - status: - project: - default: - target: 70% - threshold: 2% - patch: off - changes: no - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "header,diff" - behavior: default - require_changes: no - -ignore: - - internal/encoder/vm_color - - internal/encoder/vm_color_indent diff --git a/vendor/github.com/goccy/go-json/.gitignore b/vendor/github.com/goccy/go-json/.gitignore deleted file mode 100644 index 378283829..000000000 --- a/vendor/github.com/goccy/go-json/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -cover.html -cover.out diff --git a/vendor/github.com/goccy/go-json/.golangci.yml b/vendor/github.com/goccy/go-json/.golangci.yml deleted file mode 100644 index 44ae40f69..000000000 --- a/vendor/github.com/goccy/go-json/.golangci.yml +++ /dev/null @@ -1,75 +0,0 @@ -run: - skip-files: - - encode_optype.go - - ".*_test\\.go$" - -linters-settings: - govet: - enable-all: true - disable: - - shadow - -linters: - enable-all: true - disable: - - dogsled - - dupl - - exhaustive - - exhaustivestruct - - errorlint - - forbidigo - - funlen - - gci - - gochecknoglobals - - gochecknoinits - - gocognit - - gocritic - - gocyclo - - godot - - godox - - goerr113 - - gofumpt - - gomnd - - gosec - - ifshort - - lll - - makezero - - nakedret - - nestif - - nlreturn - - paralleltest - - testpackage - - thelper - - wrapcheck - - interfacer - - lll - - nakedret - - nestif - - nlreturn - - testpackage - - wsl - -issues: - exclude-rules: - # not needed - - path: /*.go - text: "ST1003: should not use underscores in package names" - linters: - - stylecheck - - path: /*.go - text: "don't use an underscore in package name" - linters: - - golint - - path: rtype.go - linters: - - golint - - stylecheck - - path: error.go - linters: - - staticcheck - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-issues-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 diff --git a/vendor/github.com/goccy/go-json/CHANGELOG.md b/vendor/github.com/goccy/go-json/CHANGELOG.md deleted file mode 100644 index f69c8144c..000000000 --- a/vendor/github.com/goccy/go-json/CHANGELOG.md +++ /dev/null @@ -1,260 +0,0 @@ -# v0.7.8 - 2021/09/01 - -* Fix mapassign_faststr for indirect struct type ( #283 ) -* Fix encoding of not empty interface type ( #284 ) -* Fix encoding of empty struct interface type ( #286 ) - -# v0.7.7 - 2021/08/25 - -* Fix invalid utf8 on stream decoder ( #279 ) -* Fix buffer length bug on string stream decoder ( #280 ) - -Thank you @orisano !! - -# v0.7.6 - 2021/08/13 - -* Fix nil slice assignment ( #276 ) -* Improve error message ( #277 ) - -# v0.7.5 - 2021/08/12 - -* Fix encoding of embedded struct with tags ( #265 ) -* Fix encoding of embedded struct that isn't first field ( #272 ) -* Fix decoding of binary type with escaped char ( #273 ) - -# v0.7.4 - 2021/07/06 - -* Fix encoding of indirect layout structure ( #264 ) - -# v0.7.3 - 2021/06/29 - -* Fix encoding of pointer type in empty interface ( #262 ) - -# v0.7.2 - 2021/06/26 - -### Fix decoder - -* Add decoder for func type to fix decoding of nil function value ( #257 ) -* Fix stream decoding of []byte type ( #258 ) - -### Performance - -* Improve decoding performance of map[string]interface{} type ( use `mapassign_faststr` ) ( #256 ) -* Improve encoding performance of empty interface type ( remove recursive calling of `vm.Run` ) ( #259 ) - -### Benchmark - -* Add bytedance/sonic as benchmark target ( #254 ) - -# v0.7.1 - 2021/06/18 - -### Fix decoder - -* Fix error when unmarshal empty array ( #253 ) - -# v0.7.0 - 2021/06/12 - -### Support context for MarshalJSON and UnmarshalJSON ( #248 ) - -* json.MarshalContext(context.Context, interface{}, ...json.EncodeOption) ([]byte, error) -* json.NewEncoder(io.Writer).EncodeContext(context.Context, interface{}, ...json.EncodeOption) error -* json.UnmarshalContext(context.Context, []byte, interface{}, ...json.DecodeOption) error -* json.NewDecoder(io.Reader).DecodeContext(context.Context, interface{}) error - -```go -type MarshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -type UnmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} -``` - -### Add DecodeFieldPriorityFirstWin option ( #242 ) - -In the default behavior, go-json, like encoding/json, will reflect the result of the last evaluation when a field with the same name exists. I've added new options to allow you to change this behavior. `json.DecodeFieldPriorityFirstWin` option reflects the result of the first evaluation if a field with the same name exists. This behavior has a performance advantage as it allows the subsequent strings to be skipped if all fields have been evaluated. - -### Fix encoder - -* Fix indent number contains recursive type ( #249 ) -* Fix encoding of using empty interface as map key ( #244 ) - -### Fix decoder - -* Fix decoding fields containing escaped characters ( #237 ) - -### Refactor - -* Move some tests to subdirectory ( #243 ) -* Refactor package layout for decoder ( #238 ) - -# v0.6.1 - 2021/06/02 - -### Fix encoder - -* Fix value of totalLength for encoding ( #236 ) - -# v0.6.0 - 2021/06/01 - -### Support Colorize option for encoding (#233) - -```go -b, err := json.MarshalWithOption(v, json.Colorize(json.DefaultColorScheme)) -if err != nil { - ... -} -fmt.Println(string(b)) // print colored json -``` - -### Refactor - -* Fix opcode layout - Adjust memory layout of the opcode to 128 bytes in a 64-bit environment ( #230 ) -* Refactor encode option ( #231 ) -* Refactor escape string ( #232 ) - -# v0.5.1 - 2021/5/20 - -### Optimization - -* Add type addrShift to enable bigger encoder/decoder cache ( #213 ) - -### Fix decoder - -* Keep original reference of slice element ( #229 ) - -### Refactor - -* Refactor Debug mode for encoding ( #226 ) -* Generate VM sources for encoding ( #227 ) -* Refactor validator for null/true/false for decoding ( #221 ) - -# v0.5.0 - 2021/5/9 - -### Supports using omitempty and string tags at the same time ( #216 ) - -### Fix decoder - -* Fix stream decoder for unicode char ( #215 ) -* Fix decoding of slice element ( #219 ) -* Fix calculating of buffer length for stream decoder ( #220 ) - -### Refactor - -* replace skipWhiteSpace goto by loop ( #212 ) - -# v0.4.14 - 2021/5/4 - -### Benchmark - -* Add valyala/fastjson to benchmark ( #193 ) -* Add benchmark task for CI ( #211 ) - -### Fix decoder - -* Fix decoding of slice with unmarshal json type ( #198 ) -* Fix decoding of null value for interface type that does not implement Unmarshaler ( #205 ) -* Fix decoding of null value to []byte by json.Unmarshal ( #206 ) -* Fix decoding of backslash char at the end of string ( #207 ) -* Fix stream decoder for null/true/false value ( #208 ) -* Fix stream decoder for slow reader ( #211 ) - -### Performance - -* If cap of slice is enough, reuse slice data for compatibility with encoding/json ( #200 ) - -# v0.4.13 - 2021/4/20 - -### Fix json.Compact and json.Indent - -* Support validation the input buffer for json.Compact and json.Indent ( #189 ) -* Optimize json.Compact and json.Indent ( improve memory footprint ) ( #190 ) - -# v0.4.12 - 2021/4/15 - -### Fix encoder - -* Fix unnecessary indent for empty slice type ( #181 ) -* Fix encoding of omitempty feature for the slice or interface type ( #183 ) -* Fix encoding custom types zero values with omitempty when marshaller exists ( #187 ) - -### Fix decoder - -* Fix decoder for invalid top level value ( #184 ) -* Fix decoder for invalid number value ( #185 ) - -# v0.4.11 - 2021/4/3 - -* Improve decoder performance for interface type - -# v0.4.10 - 2021/4/2 - -### Fix encoder - -* Fixed a bug when encoding slice and map containing recursive structures -* Fixed a logic to determine if indirect reference - -# v0.4.9 - 2021/3/29 - -### Add debug mode - -If you use `json.MarshalWithOption(v, json.Debug())` and `panic` occurred in `go-json`, produces debug information to console. - -### Support a new feature to compatible with encoding/json - -- invalid UTF-8 is coerced to valid UTF-8 ( without performance down ) - -### Fix encoder - -- Fixed handling of MarshalJSON of function type - -### Fix decoding of slice of pointer type - -If there is a pointer value, go-json will use it. (This behavior is necessary to achieve the ability to prioritize pre-filled values). However, since slices are reused internally, there was a bug that referred to the previous pointer value. Therefore, it is not necessary to refer to the pointer value in advance for the slice element, so we explicitly initialize slice element by `nil`. - -# v0.4.8 - 2021/3/21 - -### Reduce memory usage at compile time - -* go-json have used about 2GB of memory at compile time, but now it can compile with about less than 550MB. - -### Fix any encoder's bug - -* Add many test cases for encoder -* Fix composite type ( slice/array/map ) -* Fix pointer types -* Fix encoding of MarshalJSON or MarshalText or json.Number type - -### Refactor encoder - -* Change package layout for reducing memory usage at compile -* Remove anonymous and only operation -* Remove root property from encodeCompileContext and opcode - -### Fix CI - -* Add Go 1.16 -* Remove Go 1.13 -* Fix `make cover` task - -### Number/Delim/Token/RawMessage use the types defined in encoding/json by type alias - -# v0.4.7 - 2021/02/22 - -### Fix decoder - -* Fix decoding of deep recursive structure -* Fix decoding of embedded unexported pointer field -* Fix invalid test case -* Fix decoding of invalid value -* Fix decoding of prefilled value -* Fix not being able to return UnmarshalTypeError when it should be returned -* Fix decoding of null value -* Fix decoding of type of null string -* Use pre allocated pointer if exists it at decoding - -### Reduce memory usage at compile - -* Integrate int/int8/int16/int32/int64 and uint/uint8/uint16/uint32/uint64 operation to reduce memory usage at compile - -### Remove unnecessary optype diff --git a/vendor/github.com/goccy/go-json/LICENSE b/vendor/github.com/goccy/go-json/LICENSE deleted file mode 100644 index 6449c8bff..000000000 --- a/vendor/github.com/goccy/go-json/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Masaaki Goshima - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/goccy/go-json/Makefile b/vendor/github.com/goccy/go-json/Makefile deleted file mode 100644 index 363563ab9..000000000 --- a/vendor/github.com/goccy/go-json/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -PKG := github.com/goccy/go-json - -BIN_DIR := $(CURDIR)/bin -PKGS := $(shell go list ./... | grep -v internal/cmd|grep -v test) -COVER_PKGS := $(foreach pkg,$(PKGS),$(subst $(PKG),.,$(pkg))) - -COMMA := , -EMPTY := -SPACE := $(EMPTY) $(EMPTY) -COVERPKG_OPT := $(subst $(SPACE),$(COMMA),$(COVER_PKGS)) - -$(BIN_DIR): - @mkdir -p $(BIN_DIR) - -.PHONY: cover -cover: - go test -coverpkg=$(COVERPKG_OPT) -coverprofile=cover.out ./... - -.PHONY: cover-html -cover-html: cover - go tool cover -html=cover.out - -.PHONY: lint -lint: golangci-lint - golangci-lint run - -golangci-lint: | $(BIN_DIR) - @{ \ - set -e; \ - GOLANGCI_LINT_TMP_DIR=$$(mktemp -d); \ - cd $$GOLANGCI_LINT_TMP_DIR; \ - go mod init tmp; \ - GOBIN=$(BIN_DIR) go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.36.0; \ - rm -rf $$GOLANGCI_LINT_TMP_DIR; \ - } - -.PHONY: generate -generate: - go generate ./internal/... diff --git a/vendor/github.com/goccy/go-json/README.md b/vendor/github.com/goccy/go-json/README.md deleted file mode 100644 index 418854e52..000000000 --- a/vendor/github.com/goccy/go-json/README.md +++ /dev/null @@ -1,529 +0,0 @@ -# go-json - -![Go](https://github.com/goccy/go-json/workflows/Go/badge.svg) -[![GoDoc](https://godoc.org/github.com/goccy/go-json?status.svg)](https://pkg.go.dev/github.com/goccy/go-json?tab=doc) -[![codecov](https://codecov.io/gh/goccy/go-json/branch/master/graph/badge.svg)](https://codecov.io/gh/goccy/go-json) - -Fast JSON encoder/decoder compatible with encoding/json for Go - - - -# Roadmap - -``` -* version ( expected release date ) - -* v0.7.0 - | - | while maintaining compatibility with encoding/json, we will add convenient APIs - | - v -* v1.0.0 -``` - -We are accepting requests for features that will be implemented between v0.7.0 and v.1.0.0. -If you have the API you need, please submit your issue [here](https://github.com/goccy/go-json/issues). -For example, I'm thinking of supporting `context.Context` of `json.Marshaler` and decoding using JSON Path. - -# Features - -- Drop-in replacement of `encoding/json` -- Fast ( See [Benchmark section](https://github.com/goccy/go-json#benchmarks) ) -- Flexible customization with options -- Coloring the encoded string -- Can propagate context.Context to `MarshalJSON` or `UnmarshalJSON` - -# Installation - -``` -go get github.com/goccy/go-json -``` - -# How to use - -Replace import statement from `encoding/json` to `github.com/goccy/go-json` - -``` --import "encoding/json" -+import "github.com/goccy/go-json" -``` - -# JSON library comparison - -| name | encoder | decoder | compatible with `encoding/json` | -| :----: | :------: | :-----: | :-----------------------------: | -| encoding/json | yes | yes | N/A | -| [json-iterator/go](https://github.com/json-iterator/go) | yes | yes | partial | -| [easyjson](https://github.com/mailru/easyjson) | yes | yes | no | -| [gojay](https://github.com/francoispqt/gojay) | yes | yes | no | -| [segmentio/encoding/json](https://github.com/segmentio/encoding/tree/master/json) | yes | yes | partial | -| [jettison](https://github.com/wI2L/jettison) | yes | no | no | -| [simdjson-go](https://github.com/minio/simdjson-go) | no | yes | no | -| goccy/go-json | yes | yes | yes | - -- `json-iterator/go` isn't compatible with `encoding/json` in many ways (e.g. https://github.com/json-iterator/go/issues/229 ), but it hasn't been supported for a long time. -- `segmentio/encoding/json` is well supported for encoders, but some are not supported for decoder APIs such as `Token` ( streaming decode ) - -## Other libraries - -- [jingo](https://github.com/bet365/jingo) - -I tried the benchmark but it didn't work. -Also, it seems to panic when it receives an unexpected value because there is no error handling... - -- [ffjson](https://github.com/pquerna/ffjson) - -Benchmarking gave very slow results. -It seems that it is assumed that the user will use the buffer pool properly. -Also, development seems to have already stopped - -# Benchmarks - -``` -$ cd benchmarks -$ go test -bench . -``` - -## Encode - - - - -## Decode - - - - - - -# Fuzzing - -[go-json-fuzz](https://github.com/goccy/go-json-fuzz) is the repository for fuzzing tests. -If you run the test in this repository and find a bug, please commit to corpus to go-json-fuzz and report the issue to [go-json](https://github.com/goccy/go-json/issues). - -# How it works - -`go-json` is very fast in both encoding and decoding compared to other libraries. -It's easier to implement by using automatic code generation for performance or by using a dedicated interface, but `go-json` dares to stick to compatibility with `encoding/json` and is the simple interface. Despite this, we are developing with the aim of being the fastest library. - -Here, we explain the various speed-up techniques implemented by `go-json`. - -## Basic technique - -The techniques listed here are the ones used by most of the libraries listed above. - -### Buffer reuse - -Since the only value required for the result of `json.Marshal(interface{}) ([]byte, error)` is `[]byte`, the only value that must be allocated during encoding is the return value `[]byte` . - -Also, as the number of allocations increases, the performance will be affected, so the number of allocations should be kept as low as possible when creating `[]byte`. - -Therefore, there is a technique to reduce the number of times a new buffer must be allocated by reusing the buffer used for the previous encoding by using `sync.Pool`. - -Finally, you allocate a buffer that is as long as the resulting buffer and copy the contents into it, you only need to allocate the buffer once in theory. - -```go -type buffer struct { - data []byte -} - -var bufPool = sync.Pool{ - New: func() interface{} { - return &buffer{data: make([]byte, 0, 1024)} - }, -} - -buf := bufPool.Get().(*buffer) -data := encode(buf.data) // reuse buf.data - -newBuf := make([]byte, len(data)) -copy(newBuf, buf) - -buf.data = data -bufPool.Put(buf) -``` - -### Elimination of reflection - -As you know, the reflection operation is very slow. - -Therefore, using the fact that the address position where the type information is stored is fixed for each binary ( we call this `typeptr` ), -we can use the address in the type information to call a pre-built optimized process. - -For example, you can get the address to the type information from `interface{}` as follows and you can use that information to call a process that does not have reflection. - -To process without reflection, pass a pointer (`unsafe.Pointer`) to the value is stored. - -```go - -type emptyInterface struct { - typ unsafe.Pointer - ptr unsafe.Pointer -} - -var typeToEncoder = map[uintptr]func(unsafe.Pointer)([]byte, error){} - -func Marshal(v interface{}) ([]byte, error) { - iface := (*emptyInterface)(unsafe.Pointer(&v) - typeptr := uintptr(iface.typ) - if enc, exists := typeToEncoder[typeptr]; exists { - return enc(iface.ptr) - } - ... -} -``` - -※ In reality, `typeToEncoder` can be referenced by multiple goroutines, so exclusive control is required. - -## Unique speed-up technique - -## Encoder - -### Do not escape arguments of `Marshal` - -`json.Marshal` and `json.Unmarshal` receive `interface{}` value and they perform type determination dynamically to process. -In normal case, you need to use the `reflect` library to determine the type dynamically, but since `reflect.Type` is defined as `interface`, when you call the method of `reflect.Type`, The reflect's argument is escaped. - -Therefore, the arguments for `Marshal` and `Unmarshal` are always escape to the heap. -However, `go-json` can use the feature of `reflect.Type` while avoiding escaping. - -`reflect.Type` is defined as `interface`, but in reality `reflect.Type` is implemented only by the structure `rtype` defined in the `reflect` package. -For this reason, to date `reflect.Type` is the same as `*reflect.rtype`. - -Therefore, by directly handling `*reflect.rtype`, which is an implementation of `reflect.Type`, it is possible to avoid escaping because it changes from `interface` to using `struct`. - -The technique for working with `*reflect.rtype` directly from `go-json` is implemented at [rtype.go](https://github.com/goccy/go-json/blob/master/internal/runtime/rtype.go) - -Also, the same technique is cut out as a library ( https://github.com/goccy/go-reflect ) - -Initially this feature was the default behavior of `go-json`. -But after careful testing, I found that I passed a large value to `json.Marshal()` and if the argument could not be assigned to the stack, it could not be properly escaped to the heap (a bug in the Go compiler). - -Therefore, this feature will be provided as an **optional** until this issue is resolved. - -To use it, add `NoEscape` like `MarshalNoEscape()` - -### Encoding using opcode sequence - -I explained that you can use `typeptr` to call a pre-built process from type information. - -In other libraries, this dedicated process is processed by making it an function calling like anonymous function, but function calls are inherently slow processes and should be avoided as much as possible. - -Therefore, `go-json` adopted the Instruction-based execution processing system, which is also used to implement virtual machines for programming language. - -If it is the first type to encode, create the opcode ( instruction ) sequence required for encoding. -From the second time onward, use `typeptr` to get the cached pre-built opcode sequence and encode it based on it. An example of the opcode sequence is shown below. - -```go -json.Marshal(struct{ - X int `json:"x"` - Y string `json:"y"` -}{X: 1, Y: "hello"}) -``` - -When encoding a structure like the one above, create a sequence of opcodes like this: - -``` -- opStructFieldHead ( `{` ) -- opStructFieldInt ( `"x": 1,` ) -- opStructFieldString ( `"y": "hello"` ) -- opStructEnd ( `}` ) -- opEnd -``` - -※ When processing each operation, write the letters on the right. - -In addition, each opcode is managed by the following structure ( -Pseudo code ). - -```go -type opType int -const ( - opStructFieldHead opType = iota - opStructFieldInt - opStructFieldStirng - opStructEnd - opEnd -) -type opcode struct { - op opType - key []byte - next *opcode -} -``` - -The process of encoding using the opcode sequence is roughly implemented as follows. - -```go -func encode(code *opcode, b []byte, p unsafe.Pointer) ([]byte, error) { - for { - switch code.op { - case opStructFieldHead: - b = append(b, '{') - code = code.next - case opStructFieldInt: - b = append(b, code.key...) - b = appendInt((*int)(unsafe.Pointer(uintptr(p)+code.offset))) - code = code.next - case opStructFieldString: - b = append(b, code.key...) - b = appendString((*string)(unsafe.Pointer(uintptr(p)+code.offset))) - code = code.next - case opStructEnd: - b = append(b, '}') - code = code.next - case opEnd: - goto END - } - } -END: - return b, nil -} -``` - -In this way, the huge `switch-case` is used to encode by manipulating the linked list opcodes to avoid unnecessary function calls. - -### Opcode sequence optimization - -One of the advantages of encoding using the opcode sequence is the ease of optimization. -The opcode sequence mentioned above is actually converted into the following optimized operations and used. - -``` -- opStructFieldHeadInt ( `{"x": 1,` ) -- opStructEndString ( `"y": "hello"}` ) -- opEnd -``` - -It has been reduced from 5 opcodes to 3 opcodes ! -Reducing the number of opcodees means reducing the number of branches with `switch-case`. -In other words, the closer the number of operations is to 1, the faster the processing can be performed. - -In `go-json`, optimization to reduce the number of opcodes itself like the above and it speeds up by preparing opcodes with optimized paths. - -### Change recursive call from CALL to JMP - -Recursive processing is required during encoding if the type is defined recursively as follows: - -```go -type T struct { - X int - U *U -} - -type U struct { - T *T -} - -b, err := json.Marshal(&T{ - X: 1, - U: &U{ - T: &T{ - X: 2, - }, - }, -}) -fmt.Println(string(b)) // {"X":1,"U":{"T":{"X":2,"U":null}}} -``` - -In `go-json`, recursive processing is processed by the operation type of ` opStructFieldRecursive`. - -In this operation, after acquiring the opcode sequence used for recursive processing, the function is **not** called recursively as it is, but the necessary values ​​are saved by itself and implemented by moving to the next operation. - -The technique of implementing recursive processing with the `JMP` operation while avoiding the `CALL` operation is a famous technique for implementing a high-speed virtual machine. - -For more details, please refer to [the article](https://engineering.mercari.com/blog/entry/1599563768-081104c850) ( but Japanese only ). - -### Dispatch by typeptr from map to slice - -When retrieving the data cached from the type information by `typeptr`, we usually use map. -Map requires exclusive control, so use `sync.Map` for a naive implementation. - -However, this is slow, so it's a good idea to use the `atomic` package for exclusive control as implemented by `segmentio/encoding/json` ( https://github.com/segmentio/encoding/blob/master/json/codec.go#L41-L55 ). - -This implementation slows down the set instead of speeding up the get, but it works well because of the nature of the library, it encodes much more for the same type. - -However, as a result of profiling, I noticed that `runtime.mapaccess2` accounts for a significant percentage of the execution time. So I thought if I could change the lookup from map to slice. - -There is an API named `typelinks` defined in the `runtime` package that the `reflect` package uses internally. -This allows you to get all the type information defined in the binary at runtime. - -The fact that all type information can be acquired means that by constructing slices in advance with the acquired total number of type information, it is possible to look up with the value of `typeptr` without worrying about out-of-range access. - -However, if there is too much type information, it will use a lot of memory, so by default we will only use this optimization if the slice size fits within **2Mib** . - -If this approach is not available, it will fall back to the `atomic` based process described above. - -If you want to know more, please refer to the implementation [here](https://github.com/goccy/go-json/blob/master/internal/runtime/type.go#L36-L100) - -## Decoder - -### Dispatch by typeptr from map to slice - -Like the encoder, the decoder also uses typeptr to call the dedicated process. - -### Faster termination character inspection using NUL character - -In order to decode, you have to traverse the input buffer character by position. -At that time, if you check whether the buffer has reached the end, it will be very slow. - -`buf` : `[]byte` type variable. holds the string passed to the decoder -`cursor` : `int64` type variable. holds the current read position - -```go -buflen := len(buf) -for ; cursor < buflen; cursor++ { // compare cursor and buflen at all times, it is so slow. - switch buf[cursor] { - case ' ', '\n', '\r', '\t': - } -} -``` - -Therefore, by adding the `NUL` (`\000`) character to the end of the read buffer as shown below, it is possible to check the termination character at the same time as other characters. - -```go -for { - switch buf[cursor] { - case ' ', '\n', '\r', '\t': - case '\000': - return nil - } - cursor++ -} -``` - -### Use Boundary Check Elimination - -Due to the `NUL` character optimization, the Go compiler does a boundary check every time, even though `buf[cursor]` does not cause out-of-range access. - -Therefore, `go-json` eliminates boundary check by fetching characters for hotspot by pointer operation. For example, the following code. - -```go -func char(ptr unsafe.Pointer, offset int64) byte { - return *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(offset))) -} - -p := (*sliceHeader)(&unsafe.Pointer(buf)).data -for { - switch char(p, cursor) { - case ' ', '\n', '\r', '\t': - case '\000': - return nil - } - cursor++ -} -``` - -### Checking the existence of fields of struct using Bitmaps - -I found by the profiling result, in the struct decode, lookup process for field was taking a long time. - -For example, consider decoding a string like `{"a":1,"b":2,"c":3}` into the following structure: - -```go -type T struct { - A int `json:"a"` - B int `json:"b"` - C int `json:"c"` -} -``` - -At this time, it was found that it takes a lot of time to acquire the decoding process corresponding to the field from the field name as shown below during the decoding process. - -```go -fieldName := decodeKey(buf, cursor) // "a" or "b" or "c" -decoder, exists := fieldToDecoderMap[fieldName] // so slow -if exists { - decoder(buf, cursor) -} else { - skipValue(buf, cursor) -} -``` - -To improve this process, `json-iterator/go` is optimized so that it can be branched by switch-case when the number of fields in the structure is 10 or less (switch-case is faster than map). However, there is a risk of hash collision because the value hashed by the FNV algorithm is used for conditional branching. Also, `gojay` processes this part at high speed by letting the library user yourself write `switch-case`. - - -`go-json` considers and implements a new approach that is different from these. I call this **bitmap field optimization**. - -The range of values ​​per character can be represented by `[256]byte`. Also, if the number of fields in the structure is 8 or less, `int8` type can represent the state of each field. -In other words, it has the following structure. - -- Base ( 8bit ): `00000000` -- Key "a": `00000001` ( assign key "a" to the first bit ) -- Key "b": `00000010` ( assign key "b" to the second bit ) -- Key "c": `00000100` ( assign key "c" to the third bit ) - -Bitmap structure is the following - -``` - | key index(0) | ------------------------- - 0 | 00000000 | - 1 | 00000000 | -~~ | | -97 (a) | 00000001 | -98 (b) | 00000010 | -99 (c) | 00000100 | -~~ | | -255 | 00000000 | -``` - -You can think of this as a Bitmap with a height of `256` and a width of the maximum string length in the field name. -In other words, it can be represented by the following type . - -```go -[maxFieldKeyLength][256]int8 -``` - -When decoding a field character, check whether the corresponding character exists by referring to the pre-built bitmap like the following. - -```go -var curBit int8 = math.MaxInt8 // 11111111 - -c := char(buf, cursor) -bit := bitmap[keyIdx][c] -curBit &= bit -if curBit == 0 { - // not found field -} -``` - -If `curBit` is not `0` until the end of the field string, then the string is -You may have hit one of the fields. -But the possibility is that if the decoded string is shorter than the field string, you will get a false hit. - -- input: `{"a":1}` -```go -type T struct { - X int `json:"abc"` -} -``` -※ Since `a` is shorter than `abc`, it can decode to the end of the field character without `curBit` being 0. - -Rest assured. In this case, it doesn't matter because you can tell if you hit by comparing the string length of `a` with the string length of `abc`. - -Finally, calculate the position of the bit where `1` is set and get the corresponding value, and you're done. - -Using this technique, field lookups are possible with only bitwise operations and access to slices. - -`go-json` uses a similar technique for fields with 9 or more and 16 or less fields. At this time, Bitmap is constructed as `[maxKeyLen][256]int16` type. - -Currently, this optimization is not performed when the maximum length of the field name is long (specifically, 64 bytes or more) in addition to the limitation of the number of fields from the viewpoint of saving memory usage. - -### Others - -I have done a lot of other optimizations. I will find time to write about them. If you have any questions about what's written here or other optimizations, please visit the `#go-json` channel on `gophers.slack.com` . - -## Reference - -Regarding the story of go-json, there are the following articles in Japanese only. - -- https://speakerdeck.com/goccy/zui-su-falsejsonraiburariwoqiu-mete -- https://engineering.mercari.com/blog/entry/1599563768-081104c850/ - -# Looking for Sponsors - -I'm looking for sponsors this library. This library is being developed as a personal project in my spare time. If you want a quick response or problem resolution when using this library in your project, please register as a [sponsor](https://github.com/sponsors/goccy). I will cooperate as much as possible. Of course, this library is developed as an MIT license, so you can use it freely for free. - -# License - -MIT diff --git a/vendor/github.com/goccy/go-json/color.go b/vendor/github.com/goccy/go-json/color.go deleted file mode 100644 index e80b22b48..000000000 --- a/vendor/github.com/goccy/go-json/color.go +++ /dev/null @@ -1,68 +0,0 @@ -package json - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -type ( - ColorFormat = encoder.ColorFormat - ColorScheme = encoder.ColorScheme -) - -const escape = "\x1b" - -type colorAttr int - -//nolint:deadcode,varcheck -const ( - fgBlackColor colorAttr = iota + 30 - fgRedColor - fgGreenColor - fgYellowColor - fgBlueColor - fgMagentaColor - fgCyanColor - fgWhiteColor -) - -//nolint:deadcode,varcheck -const ( - fgHiBlackColor colorAttr = iota + 90 - fgHiRedColor - fgHiGreenColor - fgHiYellowColor - fgHiBlueColor - fgHiMagentaColor - fgHiCyanColor - fgHiWhiteColor -) - -func createColorFormat(attr colorAttr) ColorFormat { - return ColorFormat{ - Header: wrapColor(attr), - Footer: resetColor(), - } -} - -func wrapColor(attr colorAttr) string { - return fmt.Sprintf("%s[%dm", escape, attr) -} - -func resetColor() string { - return wrapColor(colorAttr(0)) -} - -var ( - DefaultColorScheme = &ColorScheme{ - Int: createColorFormat(fgHiMagentaColor), - Uint: createColorFormat(fgHiMagentaColor), - Float: createColorFormat(fgHiMagentaColor), - Bool: createColorFormat(fgHiYellowColor), - String: createColorFormat(fgHiGreenColor), - Binary: createColorFormat(fgHiRedColor), - ObjectKey: createColorFormat(fgHiCyanColor), - Null: createColorFormat(fgBlueColor), - } -) diff --git a/vendor/github.com/goccy/go-json/decode.go b/vendor/github.com/goccy/go-json/decode.go deleted file mode 100644 index d99749d05..000000000 --- a/vendor/github.com/goccy/go-json/decode.go +++ /dev/null @@ -1,232 +0,0 @@ -package json - -import ( - "context" - "fmt" - "io" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/decoder" - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type Decoder struct { - s *decoder.Stream -} - -const ( - nul = '\000' -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -func unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - src := make([]byte, len(data)+1) // append nul byte to the end - copy(src, data) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - ctx := decoder.TakeRuntimeContext() - ctx.Buf = src - ctx.Option.Flags = 0 - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - cursor, err := dec.Decode(ctx, 0, 0, header.ptr) - if err != nil { - decoder.ReleaseRuntimeContext(ctx) - return err - } - decoder.ReleaseRuntimeContext(ctx) - return validateEndBuf(src, cursor) -} - -func unmarshalContext(ctx context.Context, data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - src := make([]byte, len(data)+1) // append nul byte to the end - copy(src, data) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - rctx := decoder.TakeRuntimeContext() - rctx.Buf = src - rctx.Option.Flags = 0 - rctx.Option.Flags |= decoder.ContextOption - rctx.Option.Context = ctx - for _, optFunc := range optFuncs { - optFunc(rctx.Option) - } - cursor, err := dec.Decode(rctx, 0, 0, header.ptr) - if err != nil { - decoder.ReleaseRuntimeContext(rctx) - return err - } - decoder.ReleaseRuntimeContext(rctx) - return validateEndBuf(src, cursor) -} - -func unmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - src := make([]byte, len(data)+1) // append nul byte to the end - copy(src, data) - - header := (*emptyInterface)(unsafe.Pointer(&v)) - - if err := validateType(header.typ, uintptr(header.ptr)); err != nil { - return err - } - dec, err := decoder.CompileToGetDecoder(header.typ) - if err != nil { - return err - } - - ctx := decoder.TakeRuntimeContext() - ctx.Buf = src - ctx.Option.Flags = 0 - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - cursor, err := dec.Decode(ctx, 0, 0, noescape(header.ptr)) - if err != nil { - decoder.ReleaseRuntimeContext(ctx) - return err - } - decoder.ReleaseRuntimeContext(ctx) - return validateEndBuf(src, cursor) -} - -func validateEndBuf(src []byte, cursor int64) error { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case nul: - return nil - } - return errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after top-level value", src[cursor]), - cursor+1, - ) - } -} - -//nolint:staticcheck -//go:nosplit -func noescape(p unsafe.Pointer) unsafe.Pointer { - x := uintptr(p) - return unsafe.Pointer(x ^ 0) -} - -func validateType(typ *runtime.Type, p uintptr) error { - if typ == nil || typ.Kind() != reflect.Ptr || p == 0 { - return &InvalidUnmarshalError{Type: runtime.RType2Type(typ)} - } - return nil -} - -// NewDecoder returns a new decoder that reads from r. -// -// The decoder introduces its own buffering and may -// read data from r beyond the JSON values requested. -func NewDecoder(r io.Reader) *Decoder { - s := decoder.NewStream(r) - return &Decoder{ - s: s, - } -} - -// Buffered returns a reader of the data remaining in the Decoder's -// buffer. The reader is valid until the next call to Decode. -func (d *Decoder) Buffered() io.Reader { - return d.s.Buffered() -} - -// Decode reads the next JSON-encoded value from its -// input and stores it in the value pointed to by v. -// -// See the documentation for Unmarshal for details about -// the conversion of JSON into a Go value. -func (d *Decoder) Decode(v interface{}) error { - return d.DecodeWithOption(v) -} - -// DecodeContext reads the next JSON-encoded value from its -// input and stores it in the value pointed to by v with context.Context. -func (d *Decoder) DecodeContext(ctx context.Context, v interface{}) error { - d.s.Option.Flags |= decoder.ContextOption - d.s.Option.Context = ctx - return d.DecodeWithOption(v) -} - -func (d *Decoder) DecodeWithOption(v interface{}, optFuncs ...DecodeOptionFunc) error { - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - ptr := uintptr(header.ptr) - typeptr := uintptr(unsafe.Pointer(typ)) - // noescape trick for header.typ ( reflect.*rtype ) - copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr)) - - if err := validateType(copiedType, ptr); err != nil { - return err - } - - dec, err := decoder.CompileToGetDecoder(typ) - if err != nil { - return err - } - if err := d.s.PrepareForDecode(); err != nil { - return err - } - s := d.s - for _, optFunc := range optFuncs { - optFunc(s.Option) - } - if err := dec.DecodeStream(s, 0, header.ptr); err != nil { - return err - } - s.Reset() - return nil -} - -func (d *Decoder) More() bool { - return d.s.More() -} - -func (d *Decoder) Token() (Token, error) { - return d.s.Token() -} - -// DisallowUnknownFields causes the Decoder to return an error when the destination -// is a struct and the input contains object keys which do not match any -// non-ignored, exported fields in the destination. -func (d *Decoder) DisallowUnknownFields() { - d.s.DisallowUnknownFields = true -} - -func (d *Decoder) InputOffset() int64 { - return d.s.TotalOffset() -} - -// UseNumber causes the Decoder to unmarshal a number into an interface{} as a -// Number instead of as a float64. -func (d *Decoder) UseNumber() { - d.s.UseNumber = true -} diff --git a/vendor/github.com/goccy/go-json/docker-compose.yml b/vendor/github.com/goccy/go-json/docker-compose.yml deleted file mode 100644 index e51066624..000000000 --- a/vendor/github.com/goccy/go-json/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '2' -services: - go-json: - image: golang:1.16 - volumes: - - '.:/go/src/go-json' - deploy: - resources: - limits: - memory: 620M - working_dir: /go/src/go-json - command: | - sh -c "go test -c . && ls go-json.test" diff --git a/vendor/github.com/goccy/go-json/encode.go b/vendor/github.com/goccy/go-json/encode.go deleted file mode 100644 index 7f198bdca..000000000 --- a/vendor/github.com/goccy/go-json/encode.go +++ /dev/null @@ -1,323 +0,0 @@ -package json - -import ( - "context" - "io" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/encoder/vm" - "github.com/goccy/go-json/internal/encoder/vm_color" - "github.com/goccy/go-json/internal/encoder/vm_color_indent" - "github.com/goccy/go-json/internal/encoder/vm_indent" -) - -// An Encoder writes JSON values to an output stream. -type Encoder struct { - w io.Writer - enabledIndent bool - enabledHTMLEscape bool - prefix string - indentStr string -} - -// NewEncoder returns a new encoder that writes to w. -func NewEncoder(w io.Writer) *Encoder { - return &Encoder{w: w, enabledHTMLEscape: true} -} - -// Encode writes the JSON encoding of v to the stream, followed by a newline character. -// -// See the documentation for Marshal for details about the conversion of Go values to JSON. -func (e *Encoder) Encode(v interface{}) error { - return e.EncodeWithOption(v) -} - -// EncodeWithOption call Encode with EncodeOption. -func (e *Encoder) EncodeWithOption(v interface{}, optFuncs ...EncodeOptionFunc) error { - ctx := encoder.TakeRuntimeContext() - ctx.Option.Flag = 0 - - err := e.encodeWithOption(ctx, v, optFuncs...) - - encoder.ReleaseRuntimeContext(ctx) - return err -} - -// EncodeContext call Encode with context.Context and EncodeOption. -func (e *Encoder) EncodeContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) error { - rctx := encoder.TakeRuntimeContext() - rctx.Option.Flag = 0 - rctx.Option.Flag |= encoder.ContextOption - rctx.Option.Context = ctx - - err := e.encodeWithOption(rctx, v, optFuncs...) - - encoder.ReleaseRuntimeContext(rctx) - return err -} - -func (e *Encoder) encodeWithOption(ctx *encoder.RuntimeContext, v interface{}, optFuncs ...EncodeOptionFunc) error { - if e.enabledHTMLEscape { - ctx.Option.Flag |= encoder.HTMLEscapeOption - } - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - var ( - buf []byte - err error - ) - if e.enabledIndent { - buf, err = encodeIndent(ctx, v, e.prefix, e.indentStr) - } else { - buf, err = encode(ctx, v) - } - if err != nil { - return err - } - if e.enabledIndent { - buf = buf[:len(buf)-2] - } else { - buf = buf[:len(buf)-1] - } - buf = append(buf, '\n') - if _, err := e.w.Write(buf); err != nil { - return err - } - return nil -} - -// SetEscapeHTML specifies whether problematic HTML characters should be escaped inside JSON quoted strings. -// The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML. -// -// In non-HTML settings where the escaping interferes with the readability of the output, SetEscapeHTML(false) disables this behavior. -func (e *Encoder) SetEscapeHTML(on bool) { - e.enabledHTMLEscape = on -} - -// SetIndent instructs the encoder to format each subsequent encoded value as if indented by the package-level function Indent(dst, src, prefix, indent). -// Calling SetIndent("", "") disables indentation. -func (e *Encoder) SetIndent(prefix, indent string) { - if prefix == "" && indent == "" { - e.enabledIndent = false - return - } - e.prefix = prefix - e.indentStr = indent - e.enabledIndent = true -} - -func marshalContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - rctx := encoder.TakeRuntimeContext() - rctx.Option.Flag = 0 - rctx.Option.Flag = encoder.HTMLEscapeOption | encoder.ContextOption - rctx.Option.Context = ctx - for _, optFunc := range optFuncs { - optFunc(rctx.Option) - } - - buf, err := encode(rctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(rctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(rctx) - return copied, nil -} - -func marshal(v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= encoder.HTMLEscapeOption - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - - buf, err := encode(ctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func marshalNoEscape(v interface{}) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= encoder.HTMLEscapeOption - - buf, err := encodeNoEscape(ctx, v) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - // this line exists to escape call of `runtime.makeslicecopy` . - // if use `make([]byte, len(buf)-1)` and `copy(copied, buf)`, - // dst buffer size and src buffer size are differrent. - // in this case, compiler uses `runtime.makeslicecopy`, but it is slow. - buf = buf[:len(buf)-1] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func marshalIndent(v interface{}, prefix, indent string, optFuncs ...EncodeOptionFunc) ([]byte, error) { - ctx := encoder.TakeRuntimeContext() - - ctx.Option.Flag = 0 - ctx.Option.Flag |= (encoder.HTMLEscapeOption | encoder.IndentOption) - for _, optFunc := range optFuncs { - optFunc(ctx.Option) - } - - buf, err := encodeIndent(ctx, v, prefix, indent) - if err != nil { - encoder.ReleaseRuntimeContext(ctx) - return nil, err - } - - buf = buf[:len(buf)-2] - copied := make([]byte, len(buf)) - copy(copied, buf) - - encoder.ReleaseRuntimeContext(ctx) - return copied, nil -} - -func encode(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendComma(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - ctx.KeepRefs = append(ctx.KeepRefs, header.ptr) - - buf, err := encodeRunCode(ctx, b, codeSet) - if err != nil { - return nil, err - } - ctx.Buf = buf - return buf, nil -} - -func encodeNoEscape(ctx *encoder.RuntimeContext, v interface{}) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendComma(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - buf, err := encodeRunCode(ctx, b, codeSet) - if err != nil { - return nil, err - } - - ctx.Buf = buf - return buf, nil -} - -func encodeIndent(ctx *encoder.RuntimeContext, v interface{}, prefix, indent string) ([]byte, error) { - b := ctx.Buf[:0] - if v == nil { - b = encoder.AppendNull(ctx, b) - b = encoder.AppendCommaIndent(ctx, b) - return b, nil - } - header := (*emptyInterface)(unsafe.Pointer(&v)) - typ := header.typ - - typeptr := uintptr(unsafe.Pointer(typ)) - codeSet, err := encoder.CompileToGetCodeSet(typeptr) - if err != nil { - return nil, err - } - - p := uintptr(header.ptr) - ctx.Init(p, codeSet.CodeLength) - buf, err := encodeRunIndentCode(ctx, b, codeSet, prefix, indent) - - ctx.KeepRefs = append(ctx.KeepRefs, header.ptr) - - if err != nil { - return nil, err - } - - ctx.Buf = buf - return buf, nil -} - -func encodeRunCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - if (ctx.Option.Flag & encoder.DebugOption) != 0 { - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color.DebugRun(ctx, b, codeSet) - } - return vm.DebugRun(ctx, b, codeSet) - } - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color.Run(ctx, b, codeSet) - } - return vm.Run(ctx, b, codeSet) -} - -func encodeRunIndentCode(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, prefix, indent string) ([]byte, error) { - ctx.Prefix = []byte(prefix) - ctx.IndentStr = []byte(indent) - if (ctx.Option.Flag & encoder.DebugOption) != 0 { - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color_indent.DebugRun(ctx, b, codeSet) - } - return vm_indent.DebugRun(ctx, b, codeSet) - } - if (ctx.Option.Flag & encoder.ColorizeOption) != 0 { - return vm_color_indent.Run(ctx, b, codeSet) - } - return vm_indent.Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/error.go b/vendor/github.com/goccy/go-json/error.go deleted file mode 100644 index 94c1339a0..000000000 --- a/vendor/github.com/goccy/go-json/error.go +++ /dev/null @@ -1,39 +0,0 @@ -package json - -import ( - "github.com/goccy/go-json/internal/errors" -) - -// Before Go 1.2, an InvalidUTF8Error was returned by Marshal when -// attempting to encode a string value with invalid UTF-8 sequences. -// As of Go 1.2, Marshal instead coerces the string to valid UTF-8 by -// replacing invalid bytes with the Unicode replacement rune U+FFFD. -// -// Deprecated: No longer used; kept for compatibility. -type InvalidUTF8Error = errors.InvalidUTF8Error - -// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. -// (The argument to Unmarshal must be a non-nil pointer.) -type InvalidUnmarshalError = errors.InvalidUnmarshalError - -// A MarshalerError represents an error from calling a MarshalJSON or MarshalText method. -type MarshalerError = errors.MarshalerError - -// A SyntaxError is a description of a JSON syntax error. -type SyntaxError = errors.SyntaxError - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// -// Deprecated: No longer used; kept for compatibility. -type UnmarshalFieldError = errors.UnmarshalFieldError - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError = errors.UnmarshalTypeError - -// An UnsupportedTypeError is returned by Marshal when attempting -// to encode an unsupported value type. -type UnsupportedTypeError = errors.UnsupportedTypeError - -type UnsupportedValueError = errors.UnsupportedValueError diff --git a/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go b/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go deleted file mode 100644 index 030cb7a97..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/anonymous_field.go +++ /dev/null @@ -1,37 +0,0 @@ -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type anonymousFieldDecoder struct { - structType *runtime.Type - offset uintptr - dec Decoder -} - -func newAnonymousFieldDecoder(structType *runtime.Type, offset uintptr, dec Decoder) *anonymousFieldDecoder { - return &anonymousFieldDecoder{ - structType: structType, - offset: offset, - dec: dec, - } -} - -func (d *anonymousFieldDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - if *(*unsafe.Pointer)(p) == nil { - *(*unsafe.Pointer)(p) = unsafe_New(d.structType) - } - p = *(*unsafe.Pointer)(p) - return d.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+d.offset)) -} - -func (d *anonymousFieldDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - if *(*unsafe.Pointer)(p) == nil { - *(*unsafe.Pointer)(p) = unsafe_New(d.structType) - } - p = *(*unsafe.Pointer)(p) - return d.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+d.offset)) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/array.go b/vendor/github.com/goccy/go-json/internal/decoder/array.go deleted file mode 100644 index 21f1fd585..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/array.go +++ /dev/null @@ -1,169 +0,0 @@ -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type arrayDecoder struct { - elemType *runtime.Type - size uintptr - valueDecoder Decoder - alen int - structName string - fieldName string - zeroValue unsafe.Pointer -} - -func newArrayDecoder(dec Decoder, elemType *runtime.Type, alen int, structName, fieldName string) *arrayDecoder { - zeroValue := *(*unsafe.Pointer)(unsafe_New(elemType)) - return &arrayDecoder{ - valueDecoder: dec, - elemType: elemType, - size: elemType.Size(), - alen: alen, - structName: structName, - fieldName: fieldName, - zeroValue: zeroValue, - } -} - -func (d *arrayDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - case '[': - idx := 0 - s.cursor++ - if s.skipWhiteSpace() == ']' { - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - s.cursor++ - return nil - } - for { - if idx < d.alen { - if err := d.valueDecoder.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)); err != nil { - return err - } - } else { - if err := s.skipValue(depth); err != nil { - return err - } - } - idx++ - switch s.skipWhiteSpace() { - case ']': - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - s.cursor++ - return nil - case ',': - s.cursor++ - continue - case nul: - if s.read() { - s.cursor++ - continue - } - goto ERROR - default: - goto ERROR - } - } - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - s.cursor++ - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("array", s.totalOffset()) -} - -func (d *arrayDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case '[': - idx := 0 - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == ']' { - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - cursor++ - return cursor, nil - } - for { - if idx < d.alen { - c, err := d.valueDecoder.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+uintptr(idx)*d.size)) - if err != nil { - return 0, err - } - cursor = c - } else { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } - idx++ - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case ']': - for idx < d.alen { - *(*unsafe.Pointer)(unsafe.Pointer(uintptr(p) + uintptr(idx)*d.size)) = d.zeroValue - idx++ - } - cursor++ - return cursor, nil - case ',': - cursor++ - continue - default: - return 0, errors.ErrInvalidCharacter(buf[cursor], "array", cursor) - } - } - default: - return 0, errors.ErrUnexpectedEndOfJSON("array", cursor) - } - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/bool.go b/vendor/github.com/goccy/go-json/internal/decoder/bool.go deleted file mode 100644 index 455042a53..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/bool.go +++ /dev/null @@ -1,78 +0,0 @@ -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type boolDecoder struct { - structName string - fieldName string -} - -func newBoolDecoder(structName, fieldName string) *boolDecoder { - return &boolDecoder{structName: structName, fieldName: fieldName} -} - -func (d *boolDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - c := s.skipWhiteSpace() - for { - switch c { - case 't': - if err := trueBytes(s); err != nil { - return err - } - **(**bool)(unsafe.Pointer(&p)) = true - return nil - case 'f': - if err := falseBytes(s); err != nil { - return err - } - **(**bool)(unsafe.Pointer(&p)) = false - return nil - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - case nul: - if s.read() { - c = s.char() - continue - } - goto ERROR - } - break - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("bool", s.totalOffset()) -} - -func (d *boolDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**bool)(unsafe.Pointer(&p)) = true - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - **(**bool)(unsafe.Pointer(&p)) = false - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - } - return 0, errors.ErrUnexpectedEndOfJSON("bool", cursor) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/bytes.go b/vendor/github.com/goccy/go-json/internal/decoder/bytes.go deleted file mode 100644 index 01a37fef4..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/bytes.go +++ /dev/null @@ -1,114 +0,0 @@ -package decoder - -import ( - "encoding/base64" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type bytesDecoder struct { - typ *runtime.Type - sliceDecoder Decoder - stringDecoder *stringDecoder - structName string - fieldName string -} - -func byteUnmarshalerSliceDecoder(typ *runtime.Type, structName string, fieldName string) Decoder { - var unmarshalDecoder Decoder - switch { - case runtime.PtrTo(typ).Implements(unmarshalJSONType): - unmarshalDecoder = newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName) - case runtime.PtrTo(typ).Implements(unmarshalTextType): - unmarshalDecoder = newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName) - } - if unmarshalDecoder == nil { - return nil - } - return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName) -} - -func newBytesDecoder(typ *runtime.Type, structName string, fieldName string) *bytesDecoder { - return &bytesDecoder{ - typ: typ, - sliceDecoder: byteUnmarshalerSliceDecoder(typ, structName, fieldName), - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - } -} - -func (d *bytesDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamBinary(s, depth, p) - if err != nil { - return err - } - if bytes == nil { - s.reset() - return nil - } - decodedLen := base64.StdEncoding.DecodedLen(len(bytes)) - buf := make([]byte, decodedLen) - n, err := base64.StdEncoding.Decode(buf, bytes) - if err != nil { - return err - } - *(*[]byte)(p) = buf[:n] - s.reset() - return nil -} - -func (d *bytesDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeBinary(ctx, cursor, depth, p) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - decodedLen := base64.StdEncoding.DecodedLen(len(bytes)) - b := make([]byte, decodedLen) - n, err := base64.StdEncoding.Decode(b, bytes) - if err != nil { - return 0, err - } - *(*[]byte)(p) = b[:n] - return cursor, nil -} - -func (d *bytesDecoder) decodeStreamBinary(s *Stream, depth int64, p unsafe.Pointer) ([]byte, error) { - c := s.skipWhiteSpace() - if c == '[' { - if d.sliceDecoder == nil { - return nil, &errors.UnmarshalTypeError{ - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - err := d.sliceDecoder.DecodeStream(s, depth, p) - return nil, err - } - return d.stringDecoder.decodeStreamByte(s) -} - -func (d *bytesDecoder) decodeBinary(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) ([]byte, int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == '[' { - if d.sliceDecoder == nil { - return nil, 0, &errors.UnmarshalTypeError{ - Type: runtime.RType2Type(d.typ), - Offset: cursor, - } - } - c, err := d.sliceDecoder.Decode(ctx, cursor, depth, p) - if err != nil { - return nil, 0, err - } - return nil, c, nil - } - return d.stringDecoder.decodeByte(buf, cursor) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile.go b/vendor/github.com/goccy/go-json/internal/decoder/compile.go deleted file mode 100644 index 08dd044e6..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile.go +++ /dev/null @@ -1,510 +0,0 @@ -package decoder - -import ( - "encoding/json" - "fmt" - "reflect" - "strings" - "sync/atomic" - "unicode" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -var ( - jsonNumberType = reflect.TypeOf(json.Number("")) - typeAddr *runtime.TypeAddr - cachedDecoderMap unsafe.Pointer // map[uintptr]decoder - cachedDecoder []Decoder -) - -func init() { - typeAddr = runtime.AnalyzeTypeAddr() - if typeAddr == nil { - typeAddr = &runtime.TypeAddr{} - } - cachedDecoder = make([]Decoder, typeAddr.AddrRange>>typeAddr.AddrShift) -} - -func loadDecoderMap() map[uintptr]Decoder { - p := atomic.LoadPointer(&cachedDecoderMap) - return *(*map[uintptr]Decoder)(unsafe.Pointer(&p)) -} - -func storeDecoder(typ uintptr, dec Decoder, m map[uintptr]Decoder) { - newDecoderMap := make(map[uintptr]Decoder, len(m)+1) - newDecoderMap[typ] = dec - - for k, v := range m { - newDecoderMap[k] = v - } - - atomic.StorePointer(&cachedDecoderMap, *(*unsafe.Pointer)(unsafe.Pointer(&newDecoderMap))) -} - -func compileToGetDecoderSlowPath(typeptr uintptr, typ *runtime.Type) (Decoder, error) { - decoderMap := loadDecoderMap() - if dec, exists := decoderMap[typeptr]; exists { - return dec, nil - } - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - storeDecoder(typeptr, dec, decoderMap) - return dec, nil -} - -func compileHead(typ *runtime.Type, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return newUnmarshalJSONDecoder(runtime.PtrTo(typ), "", ""), nil - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return newUnmarshalTextDecoder(runtime.PtrTo(typ), "", ""), nil - } - return compile(typ.Elem(), "", "", structTypeToDecoder) -} - -func compile(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName), nil - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName), nil - } - - switch typ.Kind() { - case reflect.Ptr: - return compilePtr(typ, structName, fieldName, structTypeToDecoder) - case reflect.Struct: - return compileStruct(typ, structName, fieldName, structTypeToDecoder) - case reflect.Slice: - elem := typ.Elem() - if elem.Kind() == reflect.Uint8 { - return compileBytes(elem, structName, fieldName) - } - return compileSlice(typ, structName, fieldName, structTypeToDecoder) - case reflect.Array: - return compileArray(typ, structName, fieldName, structTypeToDecoder) - case reflect.Map: - return compileMap(typ, structName, fieldName, structTypeToDecoder) - case reflect.Interface: - return compileInterface(typ, structName, fieldName) - case reflect.Uintptr: - return compileUint(typ, structName, fieldName) - case reflect.Int: - return compileInt(typ, structName, fieldName) - case reflect.Int8: - return compileInt8(typ, structName, fieldName) - case reflect.Int16: - return compileInt16(typ, structName, fieldName) - case reflect.Int32: - return compileInt32(typ, structName, fieldName) - case reflect.Int64: - return compileInt64(typ, structName, fieldName) - case reflect.Uint: - return compileUint(typ, structName, fieldName) - case reflect.Uint8: - return compileUint8(typ, structName, fieldName) - case reflect.Uint16: - return compileUint16(typ, structName, fieldName) - case reflect.Uint32: - return compileUint32(typ, structName, fieldName) - case reflect.Uint64: - return compileUint64(typ, structName, fieldName) - case reflect.String: - return compileString(typ, structName, fieldName) - case reflect.Bool: - return compileBool(structName, fieldName) - case reflect.Float32: - return compileFloat32(structName, fieldName) - case reflect.Float64: - return compileFloat64(structName, fieldName) - case reflect.Func: - return compileFunc(typ, structName, fieldName) - } - return nil, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(typ), - Offset: 0, - Struct: structName, - Field: fieldName, - } -} - -func isStringTagSupportedType(typ *runtime.Type) bool { - switch { - case implementsUnmarshalJSONType(runtime.PtrTo(typ)): - return false - case runtime.PtrTo(typ).Implements(unmarshalTextType): - return false - } - switch typ.Kind() { - case reflect.Map: - return false - case reflect.Slice: - return false - case reflect.Array: - return false - case reflect.Struct: - return false - case reflect.Interface: - return false - } - return true -} - -func compileMapKey(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - if runtime.PtrTo(typ).Implements(unmarshalTextType) { - return newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName), nil - } - dec, err := compile(typ, structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - for { - switch t := dec.(type) { - case *stringDecoder, *interfaceDecoder: - return dec, nil - case *boolDecoder, *intDecoder, *uintDecoder, *numberDecoder: - return newWrappedStringDecoder(typ, dec, structName, fieldName), nil - case *ptrDecoder: - dec = t.dec - default: - goto ERROR - } - } -ERROR: - return nil, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(typ), - Offset: 0, - Struct: structName, - Field: fieldName, - } -} - -func compilePtr(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - dec, err := compile(typ.Elem(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newPtrDecoder(dec, typ.Elem(), structName, fieldName), nil -} - -func compileInt(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int)(p) = int(v) - }), nil -} - -func compileInt8(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int8)(p) = int8(v) - }), nil -} - -func compileInt16(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int16)(p) = int16(v) - }), nil -} - -func compileInt32(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int32)(p) = int32(v) - }), nil -} - -func compileInt64(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newIntDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v int64) { - *(*int64)(p) = v - }), nil -} - -func compileUint(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint)(p) = uint(v) - }), nil -} - -func compileUint8(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint8)(p) = uint8(v) - }), nil -} - -func compileUint16(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint16)(p) = uint16(v) - }), nil -} - -func compileUint32(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint32)(p) = uint32(v) - }), nil -} - -func compileUint64(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newUintDecoder(typ, structName, fieldName, func(p unsafe.Pointer, v uint64) { - *(*uint64)(p) = v - }), nil -} - -func compileFloat32(structName, fieldName string) (Decoder, error) { - return newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*float32)(p) = float32(v) - }), nil -} - -func compileFloat64(structName, fieldName string) (Decoder, error) { - return newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*float64)(p) = v - }), nil -} - -func compileString(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - if typ == runtime.Type2RType(jsonNumberType) { - return newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*json.Number)(p) = v - }), nil - } - return newStringDecoder(structName, fieldName), nil -} - -func compileBool(structName, fieldName string) (Decoder, error) { - return newBoolDecoder(structName, fieldName), nil -} - -func compileBytes(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newBytesDecoder(typ, structName, fieldName), nil -} - -func compileSlice(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - elem := typ.Elem() - decoder, err := compile(elem, structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newSliceDecoder(decoder, elem, elem.Size(), structName, fieldName), nil -} - -func compileArray(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - elem := typ.Elem() - decoder, err := compile(elem, structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newArrayDecoder(decoder, elem, typ.Len(), structName, fieldName), nil -} - -func compileMap(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - keyDec, err := compileMapKey(typ.Key(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - valueDec, err := compile(typ.Elem(), structName, fieldName, structTypeToDecoder) - if err != nil { - return nil, err - } - return newMapDecoder(typ, typ.Key(), keyDec, typ.Elem(), valueDec, structName, fieldName), nil -} - -func compileInterface(typ *runtime.Type, structName, fieldName string) (Decoder, error) { - return newInterfaceDecoder(typ, structName, fieldName), nil -} - -func compileFunc(typ *runtime.Type, strutName, fieldName string) (Decoder, error) { - return newFuncDecoder(typ, strutName, fieldName), nil -} - -func removeConflictFields(fieldMap map[string]*structFieldSet, conflictedMap map[string]struct{}, dec *structDecoder, field reflect.StructField) { - for k, v := range dec.fieldMap { - if _, exists := conflictedMap[k]; exists { - // already conflicted key - continue - } - set, exists := fieldMap[k] - if !exists { - fieldSet := &structFieldSet{ - dec: v.dec, - offset: field.Offset + v.offset, - isTaggedKey: v.isTaggedKey, - key: k, - keyLen: int64(len(k)), - } - fieldMap[k] = fieldSet - lower := strings.ToLower(k) - if _, exists := fieldMap[lower]; !exists { - fieldMap[lower] = fieldSet - } - continue - } - if set.isTaggedKey { - if v.isTaggedKey { - // conflict tag key - delete(fieldMap, k) - delete(fieldMap, strings.ToLower(k)) - conflictedMap[k] = struct{}{} - conflictedMap[strings.ToLower(k)] = struct{}{} - } - } else { - if v.isTaggedKey { - fieldSet := &structFieldSet{ - dec: v.dec, - offset: field.Offset + v.offset, - isTaggedKey: v.isTaggedKey, - key: k, - keyLen: int64(len(k)), - } - fieldMap[k] = fieldSet - lower := strings.ToLower(k) - if _, exists := fieldMap[lower]; !exists { - fieldMap[lower] = fieldSet - } - } else { - // conflict tag key - delete(fieldMap, k) - delete(fieldMap, strings.ToLower(k)) - conflictedMap[k] = struct{}{} - conflictedMap[strings.ToLower(k)] = struct{}{} - } - } - } -} - -func compileStruct(typ *runtime.Type, structName, fieldName string, structTypeToDecoder map[uintptr]Decoder) (Decoder, error) { - fieldNum := typ.NumField() - conflictedMap := map[string]struct{}{} - fieldMap := map[string]*structFieldSet{} - typeptr := uintptr(unsafe.Pointer(typ)) - if dec, exists := structTypeToDecoder[typeptr]; exists { - return dec, nil - } - structDec := newStructDecoder(structName, fieldName, fieldMap) - structTypeToDecoder[typeptr] = structDec - structName = typ.Name() - for i := 0; i < fieldNum; i++ { - field := typ.Field(i) - if runtime.IsIgnoredStructField(field) { - continue - } - isUnexportedField := unicode.IsLower([]rune(field.Name)[0]) - tag := runtime.StructTagFromField(field) - dec, err := compile(runtime.Type2RType(field.Type), structName, field.Name, structTypeToDecoder) - if err != nil { - return nil, err - } - if field.Anonymous && !tag.IsTaggedKey { - if stDec, ok := dec.(*structDecoder); ok { - if runtime.Type2RType(field.Type) == typ { - // recursive definition - continue - } - removeConflictFields(fieldMap, conflictedMap, stDec, field) - } else if pdec, ok := dec.(*ptrDecoder); ok { - contentDec := pdec.contentDecoder() - if pdec.typ == typ { - // recursive definition - continue - } - var fieldSetErr error - if isUnexportedField { - fieldSetErr = fmt.Errorf( - "json: cannot set embedded pointer to unexported struct: %v", - field.Type.Elem(), - ) - } - if dec, ok := contentDec.(*structDecoder); ok { - for k, v := range dec.fieldMap { - if _, exists := conflictedMap[k]; exists { - // already conflicted key - continue - } - set, exists := fieldMap[k] - if !exists { - fieldSet := &structFieldSet{ - dec: newAnonymousFieldDecoder(pdec.typ, v.offset, v.dec), - offset: field.Offset, - isTaggedKey: v.isTaggedKey, - key: k, - keyLen: int64(len(k)), - err: fieldSetErr, - } - fieldMap[k] = fieldSet - lower := strings.ToLower(k) - if _, exists := fieldMap[lower]; !exists { - fieldMap[lower] = fieldSet - } - continue - } - if set.isTaggedKey { - if v.isTaggedKey { - // conflict tag key - delete(fieldMap, k) - delete(fieldMap, strings.ToLower(k)) - conflictedMap[k] = struct{}{} - conflictedMap[strings.ToLower(k)] = struct{}{} - } - } else { - if v.isTaggedKey { - fieldSet := &structFieldSet{ - dec: newAnonymousFieldDecoder(pdec.typ, v.offset, v.dec), - offset: field.Offset, - isTaggedKey: v.isTaggedKey, - key: k, - keyLen: int64(len(k)), - err: fieldSetErr, - } - fieldMap[k] = fieldSet - lower := strings.ToLower(k) - if _, exists := fieldMap[lower]; !exists { - fieldMap[lower] = fieldSet - } - } else { - // conflict tag key - delete(fieldMap, k) - delete(fieldMap, strings.ToLower(k)) - conflictedMap[k] = struct{}{} - conflictedMap[strings.ToLower(k)] = struct{}{} - } - } - } - } - } - } else { - if tag.IsString && isStringTagSupportedType(runtime.Type2RType(field.Type)) { - dec = newWrappedStringDecoder(runtime.Type2RType(field.Type), dec, structName, field.Name) - } - var key string - if tag.Key != "" { - key = tag.Key - } else { - key = field.Name - } - fieldSet := &structFieldSet{ - dec: dec, - offset: field.Offset, - isTaggedKey: tag.IsTaggedKey, - key: key, - keyLen: int64(len(key)), - } - fieldMap[key] = fieldSet - lower := strings.ToLower(key) - if _, exists := fieldMap[lower]; !exists { - fieldMap[lower] = fieldSet - } - } - } - delete(structTypeToDecoder, typeptr) - structDec.tryOptimize() - return structDec, nil -} - -func implementsUnmarshalJSONType(typ *runtime.Type) bool { - return typ.Implements(unmarshalJSONType) || typ.Implements(unmarshalJSONContextType) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go b/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go deleted file mode 100644 index 592f63737..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile_norace.go +++ /dev/null @@ -1,28 +0,0 @@ -// +build !race - -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) { - typeptr := uintptr(unsafe.Pointer(typ)) - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetDecoderSlowPath(typeptr, typ) - } - - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - if dec := cachedDecoder[index]; dec != nil { - return dec, nil - } - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - cachedDecoder[index] = dec - return dec, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go b/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go deleted file mode 100644 index b691bc947..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/compile_race.go +++ /dev/null @@ -1,36 +0,0 @@ -// +build race - -package decoder - -import ( - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -var decMu sync.RWMutex - -func CompileToGetDecoder(typ *runtime.Type) (Decoder, error) { - typeptr := uintptr(unsafe.Pointer(typ)) - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetDecoderSlowPath(typeptr, typ) - } - - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - decMu.RLock() - if dec := cachedDecoder[index]; dec != nil { - decMu.RUnlock() - return dec, nil - } - decMu.RUnlock() - - dec, err := compileHead(typ, map[uintptr]Decoder{}) - if err != nil { - return nil, err - } - decMu.Lock() - cachedDecoder[index] = dec - decMu.Unlock() - return dec, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/context.go b/vendor/github.com/goccy/go-json/internal/decoder/context.go deleted file mode 100644 index cb2ffdafd..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/context.go +++ /dev/null @@ -1,254 +0,0 @@ -package decoder - -import ( - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type RuntimeContext struct { - Buf []byte - Option *Option -} - -var ( - runtimeContextPool = sync.Pool{ - New: func() interface{} { - return &RuntimeContext{ - Option: &Option{}, - } - }, - } -) - -func TakeRuntimeContext() *RuntimeContext { - return runtimeContextPool.Get().(*RuntimeContext) -} - -func ReleaseRuntimeContext(ctx *RuntimeContext) { - runtimeContextPool.Put(ctx) -} - -var ( - isWhiteSpace = [256]bool{} -) - -func init() { - isWhiteSpace[' '] = true - isWhiteSpace['\n'] = true - isWhiteSpace['\t'] = true - isWhiteSpace['\r'] = true -} - -func char(ptr unsafe.Pointer, offset int64) byte { - return *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(offset))) -} - -func skipWhiteSpace(buf []byte, cursor int64) int64 { - for isWhiteSpace[buf[cursor]] { - cursor++ - } - return cursor -} - -func skipObject(buf []byte, cursor, depth int64) (int64, error) { - braceCount := 1 - for { - switch buf[cursor] { - case '{': - braceCount++ - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case '}': - depth-- - braceCount-- - if braceCount == 0 { - return cursor + 1, nil - } - case '[': - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case ']': - depth-- - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("object of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func skipArray(buf []byte, cursor, depth int64) (int64, error) { - bracketCount := 1 - for { - switch buf[cursor] { - case '[': - bracketCount++ - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case ']': - bracketCount-- - depth-- - if bracketCount == 0 { - return cursor + 1, nil - } - case '{': - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - case '}': - depth-- - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("array of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func skipValue(buf []byte, cursor, depth int64) (int64, error) { - for { - switch buf[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return skipObject(buf, cursor+1, depth+1) - case '[': - return skipArray(buf, cursor+1, depth+1) - case '"': - for { - cursor++ - switch buf[cursor] { - case '\\': - cursor++ - if buf[cursor] == nul { - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - return cursor + 1, nil - case nul: - return 0, errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - for { - cursor++ - if floatTable[buf[cursor]] { - continue - } - break - } - return cursor, nil - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - default: - return cursor, errors.ErrUnexpectedEndOfJSON("null", cursor) - } - } -} - -func validateTrue(buf []byte, cursor int64) error { - if cursor+3 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("true", cursor) - } - if buf[cursor+1] != 'r' { - return errors.ErrInvalidCharacter(buf[cursor+1], "true", cursor) - } - if buf[cursor+2] != 'u' { - return errors.ErrInvalidCharacter(buf[cursor+2], "true", cursor) - } - if buf[cursor+3] != 'e' { - return errors.ErrInvalidCharacter(buf[cursor+3], "true", cursor) - } - return nil -} - -func validateFalse(buf []byte, cursor int64) error { - if cursor+4 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("false", cursor) - } - if buf[cursor+1] != 'a' { - return errors.ErrInvalidCharacter(buf[cursor+1], "false", cursor) - } - if buf[cursor+2] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+2], "false", cursor) - } - if buf[cursor+3] != 's' { - return errors.ErrInvalidCharacter(buf[cursor+3], "false", cursor) - } - if buf[cursor+4] != 'e' { - return errors.ErrInvalidCharacter(buf[cursor+4], "false", cursor) - } - return nil -} - -func validateNull(buf []byte, cursor int64) error { - if cursor+3 >= int64(len(buf)) { - return errors.ErrUnexpectedEndOfJSON("null", cursor) - } - if buf[cursor+1] != 'u' { - return errors.ErrInvalidCharacter(buf[cursor+1], "null", cursor) - } - if buf[cursor+2] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+2], "null", cursor) - } - if buf[cursor+3] != 'l' { - return errors.ErrInvalidCharacter(buf[cursor+3], "null", cursor) - } - return nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/float.go b/vendor/github.com/goccy/go-json/internal/decoder/float.go deleted file mode 100644 index dfb7168da..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/float.go +++ /dev/null @@ -1,158 +0,0 @@ -package decoder - -import ( - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type floatDecoder struct { - op func(unsafe.Pointer, float64) - structName string - fieldName string -} - -func newFloatDecoder(structName, fieldName string, op func(unsafe.Pointer, float64)) *floatDecoder { - return &floatDecoder{op: op, structName: structName, fieldName: fieldName} -} - -var ( - floatTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - '.': true, - 'e': true, - 'E': true, - '+': true, - '-': true, - } - - validEndNumberChar = [256]bool{ - nul: true, - ' ': true, - '\t': true, - '\r': true, - '\n': true, - ',': true, - ':': true, - '}': true, - ']': true, - } -) - -func floatBytes(s *Stream) []byte { - start := s.cursor - for { - s.cursor++ - if floatTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - return s.buf[start:s.cursor] -} - -func (d *floatDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return floatBytes(s), nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("float", s.totalOffset()) -} - -func (d *floatDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for floatTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, errors.ErrUnexpectedEndOfJSON("float", cursor) - } - } -} - -func (d *floatDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - str := *(*string)(unsafe.Pointer(&bytes)) - f64, err := strconv.ParseFloat(str, 64) - if err != nil { - return errors.ErrSyntax(err.Error(), s.totalOffset()) - } - d.op(p, f64) - return nil -} - -func (d *floatDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - bytes, c, err := d.decodeByte(buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - if !validEndNumberChar[buf[cursor]] { - return 0, errors.ErrUnexpectedEndOfJSON("float", cursor) - } - s := *(*string)(unsafe.Pointer(&bytes)) - f64, err := strconv.ParseFloat(s, 64) - if err != nil { - return 0, errors.ErrSyntax(err.Error(), cursor) - } - d.op(p, f64) - return cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/func.go b/vendor/github.com/goccy/go-json/internal/decoder/func.go deleted file mode 100644 index ee3563711..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/func.go +++ /dev/null @@ -1,141 +0,0 @@ -package decoder - -import ( - "bytes" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type funcDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newFuncDecoder(typ *runtime.Type, structName, fieldName string) *funcDecoder { - fnDecoder := &funcDecoder{typ, structName, fieldName} - return fnDecoder -} - -func (d *funcDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if len(src) > 0 { - switch src[0] { - case '"': - return &errors.UnmarshalTypeError{ - Value: "string", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '[': - return &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '{': - return &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case 'n': - if err := nullBytes(s); err != nil { - return err - } - *(*unsafe.Pointer)(p) = nil - return nil - case 't': - if err := trueBytes(s); err == nil { - return &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - case 'f': - if err := falseBytes(s); err == nil { - return &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - } - } - } - return errors.ErrInvalidBeginningOfValue(s.buf[s.cursor], s.totalOffset()) -} - -func (d *funcDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if len(src) > 0 { - switch src[0] { - case '"': - return 0, &errors.UnmarshalTypeError{ - Value: "string", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '[': - return 0, &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '{': - return 0, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - case 't': - if err := validateTrue(buf, start); err == nil { - return 0, &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - } - case 'f': - if err := validateFalse(buf, start); err == nil { - return 0, &errors.UnmarshalTypeError{ - Value: "boolean", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - } - } - } - return cursor, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/int.go b/vendor/github.com/goccy/go-json/internal/decoder/int.go deleted file mode 100644 index 7edfb0411..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/int.go +++ /dev/null @@ -1,242 +0,0 @@ -package decoder - -import ( - "fmt" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type intDecoder struct { - typ *runtime.Type - kind reflect.Kind - op func(unsafe.Pointer, int64) - structName string - fieldName string -} - -func newIntDecoder(typ *runtime.Type, structName, fieldName string, op func(unsafe.Pointer, int64)) *intDecoder { - return &intDecoder{ - typ: typ, - kind: typ.Kind(), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *intDecoder) typeError(buf []byte, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: fmt.Sprintf("number %s", string(buf)), - Type: runtime.RType2Type(d.typ), - Struct: d.structName, - Field: d.fieldName, - Offset: offset, - } -} - -var ( - pow10i64 = [...]int64{ - 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, - } - pow10i64Len = len(pow10i64) -) - -func (d *intDecoder) parseInt(b []byte) (int64, error) { - isNegative := false - if b[0] == '-' { - b = b[1:] - isNegative = true - } - maxDigit := len(b) - if maxDigit > pow10i64Len { - return 0, fmt.Errorf("invalid length of number") - } - sum := int64(0) - for i := 0; i < maxDigit; i++ { - c := int64(b[i]) - 48 - digitValue := pow10i64[maxDigit-i-1] - sum += c * digitValue - } - if isNegative { - return -1 * sum, nil - } - return sum, nil -} - -var ( - numTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - } -) - -var ( - numZeroBuf = []byte{'0'} -) - -func (d *intDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - if len(num) < 2 { - goto ERROR - } - return num, nil - case '0': - s.cursor++ - return numZeroBuf, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - return num, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto ERROR - default: - return nil, d.typeError([]byte{s.char()}, s.totalOffset()) - } - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("number(integer)", s.totalOffset()) -} - -func (d *intDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '0': - cursor++ - return numZeroBuf, cursor, nil - case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for numTable[char(b, cursor)] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, d.typeError([]byte{char(b, cursor)}, cursor) - } - } -} - -func (d *intDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - i64, err := d.parseInt(bytes) - if err != nil { - return d.typeError(bytes, s.totalOffset()) - } - switch d.kind { - case reflect.Int8: - if i64 <= -1*(1<<7) || (1<<7) <= i64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Int16: - if i64 <= -1*(1<<15) || (1<<15) <= i64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Int32: - if i64 <= -1*(1<<31) || (1<<31) <= i64 { - return d.typeError(bytes, s.totalOffset()) - } - } - d.op(p, i64) - s.reset() - return nil -} - -func (d *intDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - - i64, err := d.parseInt(bytes) - if err != nil { - return 0, d.typeError(bytes, cursor) - } - switch d.kind { - case reflect.Int8: - if i64 <= -1*(1<<7) || (1<<7) <= i64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Int16: - if i64 <= -1*(1<<15) || (1<<15) <= i64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Int32: - if i64 <= -1*(1<<31) || (1<<31) <= i64 { - return 0, d.typeError(bytes, cursor) - } - } - d.op(p, i64) - return cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/interface.go b/vendor/github.com/goccy/go-json/internal/decoder/interface.go deleted file mode 100644 index 4dbb4be4a..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/interface.go +++ /dev/null @@ -1,458 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding" - "encoding/json" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type interfaceDecoder struct { - typ *runtime.Type - structName string - fieldName string - sliceDecoder *sliceDecoder - mapDecoder *mapDecoder - floatDecoder *floatDecoder - numberDecoder *numberDecoder - stringDecoder *stringDecoder -} - -func newEmptyInterfaceDecoder(structName, fieldName string) *interfaceDecoder { - ifaceDecoder := &interfaceDecoder{ - typ: emptyInterfaceType, - structName: structName, - fieldName: fieldName, - floatDecoder: newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*interface{})(p) = v - }), - numberDecoder: newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*interface{})(p) = v - }), - stringDecoder: newStringDecoder(structName, fieldName), - } - ifaceDecoder.sliceDecoder = newSliceDecoder( - ifaceDecoder, - emptyInterfaceType, - emptyInterfaceType.Size(), - structName, fieldName, - ) - ifaceDecoder.mapDecoder = newMapDecoder( - interfaceMapType, - stringType, - ifaceDecoder.stringDecoder, - interfaceMapType.Elem(), - ifaceDecoder, - structName, - fieldName, - ) - return ifaceDecoder -} - -func newInterfaceDecoder(typ *runtime.Type, structName, fieldName string) *interfaceDecoder { - emptyIfaceDecoder := newEmptyInterfaceDecoder(structName, fieldName) - stringDecoder := newStringDecoder(structName, fieldName) - return &interfaceDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - sliceDecoder: newSliceDecoder( - emptyIfaceDecoder, - emptyInterfaceType, - emptyInterfaceType.Size(), - structName, fieldName, - ), - mapDecoder: newMapDecoder( - interfaceMapType, - stringType, - stringDecoder, - interfaceMapType.Elem(), - emptyIfaceDecoder, - structName, - fieldName, - ), - floatDecoder: newFloatDecoder(structName, fieldName, func(p unsafe.Pointer, v float64) { - *(*interface{})(p) = v - }), - numberDecoder: newNumberDecoder(structName, fieldName, func(p unsafe.Pointer, v json.Number) { - *(*interface{})(p) = v - }), - stringDecoder: stringDecoder, - } -} - -func (d *interfaceDecoder) numDecoder(s *Stream) Decoder { - if s.UseNumber { - return d.numberDecoder - } - return d.floatDecoder -} - -var ( - emptyInterfaceType = runtime.Type2RType(reflect.TypeOf((*interface{})(nil)).Elem()) - interfaceMapType = runtime.Type2RType( - reflect.TypeOf((*map[string]interface{})(nil)).Elem(), - ) - stringType = runtime.Type2RType( - reflect.TypeOf(""), - ) -) - -func decodeStreamUnmarshaler(s *Stream, depth int64, unmarshaler json.Unmarshaler) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(dst); err != nil { - return err - } - return nil -} - -func decodeStreamUnmarshalerContext(s *Stream, depth int64, unmarshaler unmarshalerContext) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(s.Option.Context, dst); err != nil { - return err - } - return nil -} - -func decodeUnmarshaler(buf []byte, cursor, depth int64, unmarshaler json.Unmarshaler) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(dst); err != nil { - return 0, err - } - return end, nil -} - -func decodeUnmarshalerContext(ctx *RuntimeContext, buf []byte, cursor, depth int64, unmarshaler unmarshalerContext) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalJSON(ctx.Option.Context, dst); err != nil { - return 0, err - } - return end, nil -} - -func decodeStreamTextUnmarshaler(s *Stream, depth int64, unmarshaler encoding.TextUnmarshaler, p unsafe.Pointer) error { - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return nil - } - - dst := make([]byte, len(src)) - copy(dst, src) - - if err := unmarshaler.UnmarshalText(dst); err != nil { - return err - } - return nil -} - -func decodeTextUnmarshaler(buf []byte, cursor, depth int64, unmarshaler encoding.TextUnmarshaler, p unsafe.Pointer) (int64, error) { - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - if s, ok := unquoteBytes(src); ok { - src = s - } - if err := unmarshaler.UnmarshalText(src); err != nil { - return 0, err - } - return end, nil -} - -func (d *interfaceDecoder) decodeStreamEmptyInterface(s *Stream, depth int64, p unsafe.Pointer) error { - c := s.skipWhiteSpace() - for { - switch c { - case '{': - var v map[string]interface{} - ptr := unsafe.Pointer(&v) - if err := d.mapDecoder.DecodeStream(s, depth, ptr); err != nil { - return err - } - *(*interface{})(p) = v - return nil - case '[': - var v []interface{} - ptr := unsafe.Pointer(&v) - if err := d.sliceDecoder.DecodeStream(s, depth, ptr); err != nil { - return err - } - *(*interface{})(p) = v - return nil - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.numDecoder(s).DecodeStream(s, depth, p) - case '"': - s.cursor++ - start := s.cursor - for { - switch s.char() { - case '\\': - if _, err := decodeEscapeString(s, nil); err != nil { - return err - } - case '"': - literal := s.buf[start:s.cursor] - s.cursor++ - *(*interface{})(p) = string(literal) - return nil - case nul: - if s.read() { - continue - } - return errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - s.cursor++ - } - case 't': - if err := trueBytes(s); err != nil { - return err - } - **(**interface{})(unsafe.Pointer(&p)) = true - return nil - case 'f': - if err := falseBytes(s); err != nil { - return err - } - **(**interface{})(unsafe.Pointer(&p)) = false - return nil - case 'n': - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - case nul: - if s.read() { - c = s.char() - continue - } - } - break - } - return errors.ErrInvalidBeginningOfValue(c, s.totalOffset()) -} - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -func (d *interfaceDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - runtimeInterfaceValue := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - rv := reflect.ValueOf(runtimeInterfaceValue) - if rv.NumMethod() > 0 && rv.CanInterface() { - if u, ok := rv.Interface().(unmarshalerContext); ok { - return decodeStreamUnmarshalerContext(s, depth, u) - } - if u, ok := rv.Interface().(json.Unmarshaler); ok { - return decodeStreamUnmarshaler(s, depth, u) - } - if u, ok := rv.Interface().(encoding.TextUnmarshaler); ok { - return decodeStreamTextUnmarshaler(s, depth, u, p) - } - if s.skipWhiteSpace() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - } - return d.errUnmarshalType(rv.Type(), s.totalOffset()) - } - iface := rv.Interface() - ifaceHeader := (*emptyInterface)(unsafe.Pointer(&iface)) - typ := ifaceHeader.typ - if ifaceHeader.ptr == nil || d.typ == typ || typ == nil { - // concrete type is empty interface - return d.decodeStreamEmptyInterface(s, depth, p) - } - if typ.Kind() == reflect.Ptr && typ.Elem() == d.typ || typ.Kind() != reflect.Ptr { - return d.decodeStreamEmptyInterface(s, depth, p) - } - if s.skipWhiteSpace() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*interface{})(p) = nil - return nil - } - decoder, err := CompileToGetDecoder(typ) - if err != nil { - return err - } - return decoder.DecodeStream(s, depth, ifaceHeader.ptr) -} - -func (d *interfaceDecoder) errUnmarshalType(typ reflect.Type, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: typ.String(), - Type: typ, - Offset: offset, - Struct: d.structName, - Field: d.fieldName, - } -} - -func (d *interfaceDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - runtimeInterfaceValue := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - rv := reflect.ValueOf(runtimeInterfaceValue) - if rv.NumMethod() > 0 && rv.CanInterface() { - if u, ok := rv.Interface().(unmarshalerContext); ok { - return decodeUnmarshalerContext(ctx, buf, cursor, depth, u) - } - if u, ok := rv.Interface().(json.Unmarshaler); ok { - return decodeUnmarshaler(buf, cursor, depth, u) - } - if u, ok := rv.Interface().(encoding.TextUnmarshaler); ok { - return decodeTextUnmarshaler(buf, cursor, depth, u, p) - } - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - return 0, d.errUnmarshalType(rv.Type(), cursor) - } - - iface := rv.Interface() - ifaceHeader := (*emptyInterface)(unsafe.Pointer(&iface)) - typ := ifaceHeader.typ - if ifaceHeader.ptr == nil || d.typ == typ || typ == nil { - // concrete type is empty interface - return d.decodeEmptyInterface(ctx, cursor, depth, p) - } - if typ.Kind() == reflect.Ptr && typ.Elem() == d.typ || typ.Kind() != reflect.Ptr { - return d.decodeEmptyInterface(ctx, cursor, depth, p) - } - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - decoder, err := CompileToGetDecoder(typ) - if err != nil { - return 0, err - } - return decoder.Decode(ctx, cursor, depth, ifaceHeader.ptr) -} - -func (d *interfaceDecoder) decodeEmptyInterface(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case '{': - var v map[string]interface{} - ptr := unsafe.Pointer(&v) - cursor, err := d.mapDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case '[': - var v []interface{} - ptr := unsafe.Pointer(&v) - cursor, err := d.sliceDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.floatDecoder.Decode(ctx, cursor, depth, p) - case '"': - var v string - ptr := unsafe.Pointer(&v) - cursor, err := d.stringDecoder.Decode(ctx, cursor, depth, ptr) - if err != nil { - return 0, err - } - **(**interface{})(unsafe.Pointer(&p)) = v - return cursor, nil - case 't': - if err := validateTrue(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = true - return cursor, nil - case 'f': - if err := validateFalse(buf, cursor); err != nil { - return 0, err - } - cursor += 5 - **(**interface{})(unsafe.Pointer(&p)) = false - return cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**interface{})(unsafe.Pointer(&p)) = nil - return cursor, nil - } - return cursor, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/map.go b/vendor/github.com/goccy/go-json/internal/decoder/map.go deleted file mode 100644 index bb18ef995..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/map.go +++ /dev/null @@ -1,186 +0,0 @@ -package decoder - -import ( - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type mapDecoder struct { - mapType *runtime.Type - keyType *runtime.Type - valueType *runtime.Type - canUseAssignFaststrType bool - keyDecoder Decoder - valueDecoder Decoder - structName string - fieldName string -} - -func newMapDecoder(mapType *runtime.Type, keyType *runtime.Type, keyDec Decoder, valueType *runtime.Type, valueDec Decoder, structName, fieldName string) *mapDecoder { - return &mapDecoder{ - mapType: mapType, - keyDecoder: keyDec, - keyType: keyType, - canUseAssignFaststrType: canUseAssignFaststrType(keyType, valueType), - valueType: valueType, - valueDecoder: valueDec, - structName: structName, - fieldName: fieldName, - } -} - -const ( - mapMaxElemSize = 128 -) - -// See detail: https://github.com/goccy/go-json/pull/283 -func canUseAssignFaststrType(key *runtime.Type, value *runtime.Type) bool { - indirectElem := value.Size() > mapMaxElemSize - if indirectElem { - return false - } - return key.Kind() == reflect.String -} - -//go:linkname makemap reflect.makemap -func makemap(*runtime.Type, int) unsafe.Pointer - -//nolint:golint -//go:linkname mapassign_faststr runtime.mapassign_faststr -//go:noescape -func mapassign_faststr(t *runtime.Type, m unsafe.Pointer, s string) unsafe.Pointer - -//go:linkname mapassign reflect.mapassign -//go:noescape -func mapassign(t *runtime.Type, m unsafe.Pointer, k, v unsafe.Pointer) - -func (d *mapDecoder) mapassign(t *runtime.Type, m, k, v unsafe.Pointer) { - if d.canUseAssignFaststrType { - mapV := mapassign_faststr(t, m, *(*string)(k)) - typedmemmove(d.valueType, mapV, v) - } else { - mapassign(t, m, k, v) - } -} - -func (d *mapDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - switch s.skipWhiteSpace() { - case 'n': - if err := nullBytes(s); err != nil { - return err - } - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = nil - return nil - case '{': - default: - return errors.ErrExpected("{ character for map value", s.totalOffset()) - } - mapValue := *(*unsafe.Pointer)(p) - if mapValue == nil { - mapValue = makemap(d.mapType, 0) - } - if s.buf[s.cursor+1] == '}' { - *(*unsafe.Pointer)(p) = mapValue - s.cursor += 2 - return nil - } - for { - s.cursor++ - k := unsafe_New(d.keyType) - if err := d.keyDecoder.DecodeStream(s, depth, k); err != nil { - return err - } - s.skipWhiteSpace() - if !s.equalChar(':') { - return errors.ErrExpected("colon after object key", s.totalOffset()) - } - s.cursor++ - v := unsafe_New(d.valueType) - if err := d.valueDecoder.DecodeStream(s, depth, v); err != nil { - return err - } - d.mapassign(d.mapType, mapValue, k, v) - s.skipWhiteSpace() - if s.equalChar('}') { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - s.cursor++ - return nil - } - if !s.equalChar(',') { - return errors.ErrExpected("comma after object value", s.totalOffset()) - } - } -} - -func (d *mapDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - cursor = skipWhiteSpace(buf, cursor) - buflen := int64(len(buf)) - if buflen < 2 { - return 0, errors.ErrExpected("{} for map", cursor) - } - switch buf[cursor] { - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = nil - return cursor, nil - case '{': - default: - return 0, errors.ErrExpected("{ character for map value", cursor) - } - cursor++ - cursor = skipWhiteSpace(buf, cursor) - mapValue := *(*unsafe.Pointer)(p) - if mapValue == nil { - mapValue = makemap(d.mapType, 0) - } - if buf[cursor] == '}' { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - cursor++ - return cursor, nil - } - for { - k := unsafe_New(d.keyType) - keyCursor, err := d.keyDecoder.Decode(ctx, cursor, depth, k) - if err != nil { - return 0, err - } - cursor = skipWhiteSpace(buf, keyCursor) - if buf[cursor] != ':' { - return 0, errors.ErrExpected("colon after object key", cursor) - } - cursor++ - v := unsafe_New(d.valueType) - valueCursor, err := d.valueDecoder.Decode(ctx, cursor, depth, v) - if err != nil { - return 0, err - } - d.mapassign(d.mapType, mapValue, k, v) - cursor = skipWhiteSpace(buf, valueCursor) - if buf[cursor] == '}' { - **(**unsafe.Pointer)(unsafe.Pointer(&p)) = mapValue - cursor++ - return cursor, nil - } - if buf[cursor] != ',' { - return 0, errors.ErrExpected("comma after object value", cursor) - } - cursor++ - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/number.go b/vendor/github.com/goccy/go-json/internal/decoder/number.go deleted file mode 100644 index bf63773e3..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/number.go +++ /dev/null @@ -1,112 +0,0 @@ -package decoder - -import ( - "encoding/json" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type numberDecoder struct { - stringDecoder *stringDecoder - op func(unsafe.Pointer, json.Number) - structName string - fieldName string -} - -func newNumberDecoder(structName, fieldName string, op func(unsafe.Pointer, json.Number)) *numberDecoder { - return &numberDecoder{ - stringDecoder: newStringDecoder(structName, fieldName), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *numberDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { - return errors.ErrSyntax(err.Error(), s.totalOffset()) - } - d.op(p, json.Number(string(bytes))) - s.reset() - return nil -} - -func (d *numberDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { - return 0, errors.ErrSyntax(err.Error(), c) - } - cursor = c - s := *(*string)(unsafe.Pointer(&bytes)) - d.op(p, json.Number(s)) - return cursor, nil -} - -func (d *numberDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - start := s.cursor - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return floatBytes(s), nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case '"': - return d.stringDecoder.decodeStreamByte(s) - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - if s.cursor == start { - return nil, errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) - } - return nil, errors.ErrUnexpectedEndOfJSON("json.Number", s.totalOffset()) -} - -func (d *numberDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for floatTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - case '"': - return d.stringDecoder.decodeByte(buf, cursor) - default: - return nil, 0, errors.ErrUnexpectedEndOfJSON("json.Number", cursor) - } - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/option.go b/vendor/github.com/goccy/go-json/internal/decoder/option.go deleted file mode 100644 index e41f876b0..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/option.go +++ /dev/null @@ -1,15 +0,0 @@ -package decoder - -import "context" - -type OptionFlags uint8 - -const ( - FirstWinOption OptionFlags = 1 << iota - ContextOption -) - -type Option struct { - Flags OptionFlags - Context context.Context -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/ptr.go b/vendor/github.com/goccy/go-json/internal/decoder/ptr.go deleted file mode 100644 index 2c83b9c44..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/ptr.go +++ /dev/null @@ -1,87 +0,0 @@ -package decoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type ptrDecoder struct { - dec Decoder - typ *runtime.Type - structName string - fieldName string -} - -func newPtrDecoder(dec Decoder, typ *runtime.Type, structName, fieldName string) *ptrDecoder { - return &ptrDecoder{ - dec: dec, - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *ptrDecoder) contentDecoder() Decoder { - dec, ok := d.dec.(*ptrDecoder) - if !ok { - return d.dec - } - return dec.contentDecoder() -} - -//nolint:golint -//go:linkname unsafe_New reflect.unsafe_New -func unsafe_New(*runtime.Type) unsafe.Pointer - -func (d *ptrDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - if s.skipWhiteSpace() == nul { - s.read() - } - if s.char() == 'n' { - if err := nullBytes(s); err != nil { - return err - } - *(*unsafe.Pointer)(p) = nil - return nil - } - var newptr unsafe.Pointer - if *(*unsafe.Pointer)(p) == nil { - newptr = unsafe_New(d.typ) - *(*unsafe.Pointer)(p) = newptr - } else { - newptr = *(*unsafe.Pointer)(p) - } - if err := d.dec.DecodeStream(s, depth, newptr); err != nil { - return err - } - return nil -} - -func (d *ptrDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == 'n' { - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - if p != nil { - *(*unsafe.Pointer)(p) = nil - } - cursor += 4 - return cursor, nil - } - var newptr unsafe.Pointer - if *(*unsafe.Pointer)(p) == nil { - newptr = unsafe_New(d.typ) - *(*unsafe.Pointer)(p) = newptr - } else { - newptr = *(*unsafe.Pointer)(p) - } - c, err := d.dec.Decode(ctx, cursor, depth, newptr) - if err != nil { - return 0, err - } - cursor = c - return cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/slice.go b/vendor/github.com/goccy/go-json/internal/decoder/slice.go deleted file mode 100644 index 85b6e1119..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/slice.go +++ /dev/null @@ -1,301 +0,0 @@ -package decoder - -import ( - "reflect" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -var ( - sliceType = runtime.Type2RType( - reflect.TypeOf((*sliceHeader)(nil)).Elem(), - ) - nilSlice = unsafe.Pointer(&sliceHeader{}) -) - -type sliceDecoder struct { - elemType *runtime.Type - isElemPointerType bool - valueDecoder Decoder - size uintptr - arrayPool sync.Pool - structName string - fieldName string -} - -// If use reflect.SliceHeader, data type is uintptr. -// In this case, Go compiler cannot trace reference created by newArray(). -// So, define using unsafe.Pointer as data type -type sliceHeader struct { - data unsafe.Pointer - len int - cap int -} - -const ( - defaultSliceCapacity = 2 -) - -func newSliceDecoder(dec Decoder, elemType *runtime.Type, size uintptr, structName, fieldName string) *sliceDecoder { - return &sliceDecoder{ - valueDecoder: dec, - elemType: elemType, - isElemPointerType: elemType.Kind() == reflect.Ptr || elemType.Kind() == reflect.Map, - size: size, - arrayPool: sync.Pool{ - New: func() interface{} { - return &sliceHeader{ - data: newArray(elemType, defaultSliceCapacity), - len: 0, - cap: defaultSliceCapacity, - } - }, - }, - structName: structName, - fieldName: fieldName, - } -} - -func (d *sliceDecoder) newSlice(src *sliceHeader) *sliceHeader { - slice := d.arrayPool.Get().(*sliceHeader) - if src.len > 0 { - // copy original elem - if slice.cap < src.cap { - data := newArray(d.elemType, src.cap) - slice = &sliceHeader{data: data, len: src.len, cap: src.cap} - } else { - slice.len = src.len - } - copySlice(d.elemType, *slice, *src) - } else { - slice.len = 0 - } - return slice -} - -func (d *sliceDecoder) releaseSlice(p *sliceHeader) { - d.arrayPool.Put(p) -} - -//go:linkname copySlice reflect.typedslicecopy -func copySlice(elemType *runtime.Type, dst, src sliceHeader) int - -//go:linkname newArray reflect.unsafe_NewArray -func newArray(*runtime.Type, int) unsafe.Pointer - -//go:linkname typedmemmove reflect.typedmemmove -func typedmemmove(t *runtime.Type, dst, src unsafe.Pointer) - -func (d *sliceDecoder) errNumber(offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: "number", - Type: reflect.SliceOf(runtime.RType2Type(d.elemType)), - Struct: d.structName, - Field: d.fieldName, - Offset: offset, - } -} - -func (d *sliceDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case 'n': - if err := nullBytes(s); err != nil { - return err - } - typedmemmove(sliceType, p, nilSlice) - return nil - case '[': - s.cursor++ - if s.skipWhiteSpace() == ']' { - dst := (*sliceHeader)(p) - if dst.data == nil { - dst.data = newArray(d.elemType, 0) - } else { - dst.len = 0 - } - s.cursor++ - return nil - } - idx := 0 - slice := d.newSlice((*sliceHeader)(p)) - srcLen := slice.len - capacity := slice.cap - data := slice.data - for { - if capacity <= idx { - src := sliceHeader{data: data, len: idx, cap: capacity} - capacity *= 2 - data = newArray(d.elemType, capacity) - dst := sliceHeader{data: data, len: idx, cap: capacity} - copySlice(d.elemType, dst, src) - } - ep := unsafe.Pointer(uintptr(data) + uintptr(idx)*d.size) - - // if srcLen is greater than idx, keep the original reference - if srcLen <= idx { - if d.isElemPointerType { - **(**unsafe.Pointer)(unsafe.Pointer(&ep)) = nil // initialize elem pointer - } else { - // assign new element to the slice - typedmemmove(d.elemType, ep, unsafe_New(d.elemType)) - } - } - - if err := d.valueDecoder.DecodeStream(s, depth, ep); err != nil { - return err - } - s.skipWhiteSpace() - RETRY: - switch s.char() { - case ']': - slice.cap = capacity - slice.len = idx + 1 - slice.data = data - dst := (*sliceHeader)(p) - dst.len = idx + 1 - if dst.len > dst.cap { - dst.data = newArray(d.elemType, dst.len) - dst.cap = dst.len - } - copySlice(d.elemType, *dst, *slice) - d.releaseSlice(slice) - s.cursor++ - return nil - case ',': - idx++ - case nul: - if s.read() { - goto RETRY - } - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - goto ERROR - default: - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - goto ERROR - } - s.cursor++ - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return d.errNumber(s.totalOffset()) - case nul: - if s.read() { - continue - } - goto ERROR - default: - goto ERROR - } - } -ERROR: - return errors.ErrUnexpectedEndOfJSON("slice", s.totalOffset()) -} - -func (d *sliceDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - typedmemmove(sliceType, p, nilSlice) - return cursor, nil - case '[': - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == ']' { - dst := (*sliceHeader)(p) - if dst.data == nil { - dst.data = newArray(d.elemType, 0) - } else { - dst.len = 0 - } - cursor++ - return cursor, nil - } - idx := 0 - slice := d.newSlice((*sliceHeader)(p)) - srcLen := slice.len - capacity := slice.cap - data := slice.data - for { - if capacity <= idx { - src := sliceHeader{data: data, len: idx, cap: capacity} - capacity *= 2 - data = newArray(d.elemType, capacity) - dst := sliceHeader{data: data, len: idx, cap: capacity} - copySlice(d.elemType, dst, src) - } - ep := unsafe.Pointer(uintptr(data) + uintptr(idx)*d.size) - // if srcLen is greater than idx, keep the original reference - if srcLen <= idx { - if d.isElemPointerType { - **(**unsafe.Pointer)(unsafe.Pointer(&ep)) = nil // initialize elem pointer - } else { - // assign new element to the slice - typedmemmove(d.elemType, ep, unsafe_New(d.elemType)) - } - } - c, err := d.valueDecoder.Decode(ctx, cursor, depth, ep) - if err != nil { - return 0, err - } - cursor = c - cursor = skipWhiteSpace(buf, cursor) - switch buf[cursor] { - case ']': - slice.cap = capacity - slice.len = idx + 1 - slice.data = data - dst := (*sliceHeader)(p) - dst.len = idx + 1 - if dst.len > dst.cap { - dst.data = newArray(d.elemType, dst.len) - dst.cap = dst.len - } - copySlice(d.elemType, *dst, *slice) - d.releaseSlice(slice) - cursor++ - return cursor, nil - case ',': - idx++ - default: - slice.cap = capacity - slice.data = data - d.releaseSlice(slice) - return 0, errors.ErrInvalidCharacter(buf[cursor], "slice", cursor) - } - cursor++ - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, d.errNumber(cursor) - default: - return 0, errors.ErrUnexpectedEndOfJSON("slice", cursor) - } - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/stream.go b/vendor/github.com/goccy/go-json/internal/decoder/stream.go deleted file mode 100644 index c27468348..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/stream.go +++ /dev/null @@ -1,554 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding/json" - "io" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -const ( - initBufSize = 512 -) - -type Stream struct { - buf []byte - bufSize int64 - length int64 - r io.Reader - offset int64 - cursor int64 - filledBuffer bool - allRead bool - UseNumber bool - DisallowUnknownFields bool - Option *Option -} - -func NewStream(r io.Reader) *Stream { - return &Stream{ - r: r, - bufSize: initBufSize, - buf: make([]byte, initBufSize), - Option: &Option{}, - } -} - -func (s *Stream) TotalOffset() int64 { - return s.totalOffset() -} - -func (s *Stream) Buffered() io.Reader { - buflen := int64(len(s.buf)) - for i := s.cursor; i < buflen; i++ { - if s.buf[i] == nul { - return bytes.NewReader(s.buf[s.cursor:i]) - } - } - return bytes.NewReader(s.buf[s.cursor:]) -} - -func (s *Stream) PrepareForDecode() error { - for { - switch s.char() { - case ' ', '\t', '\r', '\n': - s.cursor++ - continue - case ',', ':': - s.cursor++ - return nil - case nul: - if s.read() { - continue - } - return io.EOF - } - break - } - return nil -} - -func (s *Stream) totalOffset() int64 { - return s.offset + s.cursor -} - -func (s *Stream) char() byte { - return s.buf[s.cursor] -} - -func (s *Stream) equalChar(c byte) bool { - cur := s.buf[s.cursor] - if cur == nul { - s.read() - cur = s.buf[s.cursor] - } - return cur == c -} - -func (s *Stream) stat() ([]byte, int64, unsafe.Pointer) { - return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) bufptr() unsafe.Pointer { - return (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) statForRetry() ([]byte, int64, unsafe.Pointer) { - s.cursor-- // for retry ( because caller progress cursor position in each loop ) - return s.buf, s.cursor, (*sliceHeader)(unsafe.Pointer(&s.buf)).data -} - -func (s *Stream) Reset() { - s.reset() - s.bufSize = initBufSize -} - -func (s *Stream) More() bool { - for { - switch s.char() { - case ' ', '\n', '\r', '\t': - s.cursor++ - continue - case '}', ']': - return false - case nul: - if s.read() { - continue - } - return false - } - break - } - return true -} - -func (s *Stream) Token() (interface{}, error) { - for { - c := s.char() - switch c { - case ' ', '\n', '\r', '\t': - s.cursor++ - case '{', '[', ']', '}': - s.cursor++ - return json.Delim(c), nil - case ',', ':': - s.cursor++ - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - bytes := floatBytes(s) - s := *(*string)(unsafe.Pointer(&bytes)) - f64, err := strconv.ParseFloat(s, 64) - if err != nil { - return nil, err - } - return f64, nil - case '"': - bytes, err := stringBytes(s) - if err != nil { - return nil, err - } - return string(bytes), nil - case 't': - if err := trueBytes(s); err != nil { - return nil, err - } - return true, nil - case 'f': - if err := falseBytes(s); err != nil { - return nil, err - } - return false, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - goto END - default: - return nil, errors.ErrInvalidCharacter(s.char(), "token", s.totalOffset()) - } - } -END: - return nil, io.EOF -} - -func (s *Stream) reset() { - s.offset += s.cursor - s.buf = s.buf[s.cursor:] - s.length -= s.cursor - s.cursor = 0 -} - -func (s *Stream) readBuf() []byte { - if s.filledBuffer { - s.bufSize *= 2 - remainBuf := s.buf - s.buf = make([]byte, s.bufSize) - copy(s.buf, remainBuf) - } - remainLen := s.length - s.cursor - remainNotNulCharNum := int64(0) - for i := int64(0); i < remainLen; i++ { - if s.buf[s.cursor+i] == nul { - break - } - remainNotNulCharNum++ - } - s.length = s.cursor + remainNotNulCharNum - return s.buf[s.cursor+remainNotNulCharNum:] -} - -func (s *Stream) read() bool { - if s.allRead { - return false - } - buf := s.readBuf() - last := len(buf) - 1 - buf[last] = nul - n, err := s.r.Read(buf[:last]) - s.length += int64(n) - if n == last { - s.filledBuffer = true - } else { - s.filledBuffer = false - } - if err == io.EOF { - s.allRead = true - } else if err != nil { - return false - } - return true -} - -func (s *Stream) skipWhiteSpace() byte { - p := s.bufptr() -LOOP: - c := char(p, s.cursor) - switch c { - case ' ', '\n', '\t', '\r': - s.cursor++ - goto LOOP - case nul: - if s.read() { - p = s.bufptr() - goto LOOP - } - } - return c -} - -func (s *Stream) skipObject(depth int64) error { - braceCount := 1 - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case '{': - braceCount++ - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case '}': - braceCount-- - depth-- - if braceCount == 0 { - s.cursor = cursor + 1 - return nil - } - case '[': - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case ']': - depth-- - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("object of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func (s *Stream) skipArray(depth int64) error { - bracketCount := 1 - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case '[': - bracketCount++ - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case ']': - bracketCount-- - depth-- - if bracketCount == 0 { - s.cursor = cursor + 1 - return nil - } - case '{': - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - case '}': - depth-- - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - case '"': - goto SWITCH_OUT - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("string of object", cursor) - } - } - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("array of object", cursor) - } - SWITCH_OUT: - cursor++ - } -} - -func (s *Stream) skipValue(depth int64) error { - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of object", s.totalOffset()) - case '{': - s.cursor = cursor + 1 - return s.skipObject(depth + 1) - case '[': - s.cursor = cursor + 1 - return s.skipArray(depth + 1) - case '"': - for { - cursor++ - switch char(p, cursor) { - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of string", s.totalOffset()) - } - case '"': - s.cursor = cursor + 1 - return nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.statForRetry() - continue - } - return errors.ErrUnexpectedEndOfJSON("value of string", s.totalOffset()) - } - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - for { - cursor++ - c := char(p, cursor) - if floatTable[c] { - continue - } else if c == nul { - if s.read() { - s.cursor-- // for retry current character - _, cursor, p = s.stat() - continue - } - } - s.cursor = cursor - return nil - } - case 't': - s.cursor = cursor - if err := trueBytes(s); err != nil { - return err - } - return nil - case 'f': - s.cursor = cursor - if err := falseBytes(s); err != nil { - return err - } - return nil - case 'n': - s.cursor = cursor - if err := nullBytes(s); err != nil { - return err - } - return nil - } - cursor++ - } -} - -func nullBytes(s *Stream) error { - // current cursor's character is 'n' - s.cursor++ - if s.char() != 'u' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadNull(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadNull(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "null", s.totalOffset()) -} - -func trueBytes(s *Stream) error { - // current cursor's character is 't' - s.cursor++ - if s.char() != 'r' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'u' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'e' { - if err := retryReadTrue(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadTrue(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "bool(true)", s.totalOffset()) -} - -func falseBytes(s *Stream) error { - // current cursor's character is 'f' - s.cursor++ - if s.char() != 'a' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'l' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 's' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - if s.char() != 'e' { - if err := retryReadFalse(s); err != nil { - return err - } - } - s.cursor++ - return nil -} - -func retryReadFalse(s *Stream) error { - if s.char() == nul && s.read() { - return nil - } - return errors.ErrInvalidCharacter(s.char(), "bool(false)", s.totalOffset()) -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/string.go b/vendor/github.com/goccy/go-json/internal/decoder/string.go deleted file mode 100644 index 65b100488..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/string.go +++ /dev/null @@ -1,371 +0,0 @@ -package decoder - -import ( - "reflect" - "unicode" - "unicode/utf16" - "unicode/utf8" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type stringDecoder struct { - structName string - fieldName string -} - -func newStringDecoder(structName, fieldName string) *stringDecoder { - return &stringDecoder{ - structName: structName, - fieldName: fieldName, - } -} - -func (d *stringDecoder) errUnmarshalType(typeName string, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: typeName, - Type: reflect.TypeOf(""), - Offset: offset, - Struct: d.structName, - Field: d.fieldName, - } -} - -func (d *stringDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - **(**string)(unsafe.Pointer(&p)) = *(*string)(unsafe.Pointer(&bytes)) - s.reset() - return nil -} - -func (d *stringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - **(**string)(unsafe.Pointer(&p)) = *(*string)(unsafe.Pointer(&bytes)) - return cursor, nil -} - -var ( - hexToInt = [256]int{ - '0': 0, - '1': 1, - '2': 2, - '3': 3, - '4': 4, - '5': 5, - '6': 6, - '7': 7, - '8': 8, - '9': 9, - 'A': 10, - 'B': 11, - 'C': 12, - 'D': 13, - 'E': 14, - 'F': 15, - 'a': 10, - 'b': 11, - 'c': 12, - 'd': 13, - 'e': 14, - 'f': 15, - } -) - -func unicodeToRune(code []byte) rune { - var r rune - for i := 0; i < len(code); i++ { - r = r*16 + rune(hexToInt[code[i]]) - } - return r -} - -func decodeUnicodeRune(s *Stream, p unsafe.Pointer) (rune, int64, unsafe.Pointer, error) { - const defaultOffset = 5 - const surrogateOffset = 11 - - if s.cursor+defaultOffset >= s.length { - if !s.read() { - return rune(0), 0, nil, errors.ErrInvalidCharacter(s.char(), "escaped string", s.totalOffset()) - } - p = s.bufptr() - } - - r := unicodeToRune(s.buf[s.cursor+1 : s.cursor+defaultOffset]) - if utf16.IsSurrogate(r) { - if s.cursor+surrogateOffset >= s.length { - s.read() - p = s.bufptr() - } - if s.cursor+surrogateOffset >= s.length || s.buf[s.cursor+defaultOffset] != '\\' || s.buf[s.cursor+defaultOffset+1] != 'u' { - return unicode.ReplacementChar, defaultOffset, p, nil - } - r2 := unicodeToRune(s.buf[s.cursor+defaultOffset+2 : s.cursor+surrogateOffset]) - if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - return r, surrogateOffset, p, nil - } - } - return r, defaultOffset, p, nil -} - -func decodeUnicode(s *Stream, p unsafe.Pointer) (unsafe.Pointer, error) { - const backSlashAndULen = 2 // length of \u - - r, offset, pp, err := decodeUnicodeRune(s, p) - if err != nil { - return nil, err - } - unicode := []byte(string(r)) - unicodeLen := int64(len(unicode)) - s.buf = append(append(s.buf[:s.cursor-1], unicode...), s.buf[s.cursor+offset:]...) - unicodeOrgLen := offset - 1 - s.length = s.length - (backSlashAndULen + (unicodeOrgLen - unicodeLen)) - s.cursor = s.cursor - backSlashAndULen + unicodeLen - return pp, nil -} - -func decodeEscapeString(s *Stream, p unsafe.Pointer) (unsafe.Pointer, error) { - s.cursor++ -RETRY: - switch s.buf[s.cursor] { - case '"': - s.buf[s.cursor] = '"' - case '\\': - s.buf[s.cursor] = '\\' - case '/': - s.buf[s.cursor] = '/' - case 'b': - s.buf[s.cursor] = '\b' - case 'f': - s.buf[s.cursor] = '\f' - case 'n': - s.buf[s.cursor] = '\n' - case 'r': - s.buf[s.cursor] = '\r' - case 't': - s.buf[s.cursor] = '\t' - case 'u': - return decodeUnicode(s, p) - case nul: - if !s.read() { - return nil, errors.ErrInvalidCharacter(s.char(), "escaped string", s.totalOffset()) - } - goto RETRY - default: - return nil, errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - s.buf = append(s.buf[:s.cursor-1], s.buf[s.cursor:]...) - s.length-- - s.cursor-- - p = s.bufptr() - return p, nil -} - -var ( - runeErrBytes = []byte(string(utf8.RuneError)) - runeErrBytesLen = int64(len(runeErrBytes)) -) - -func stringBytes(s *Stream) ([]byte, error) { - _, cursor, p := s.stat() - cursor++ // skip double quote char - start := cursor - for { - switch char(p, cursor) { - case '\\': - s.cursor = cursor - pp, err := decodeEscapeString(s, p) - if err != nil { - return nil, err - } - p = pp - cursor = s.cursor - case '"': - literal := s.buf[start:cursor] - cursor++ - s.cursor = cursor - return literal, nil - case - // 0x00 is nul, 0x5c is '\\', 0x22 is '"' . - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, // 0x00-0x0F - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // 0x10-0x1F - 0x20, 0x21 /*0x22,*/, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, // 0x20-0x2F - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, // 0x30-0x3F - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, // 0x40-0x4F - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B /*0x5C,*/, 0x5D, 0x5E, 0x5F, // 0x50-0x5F - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, // 0x60-0x6F - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F: // 0x70-0x7F - // character is ASCII. skip to next char - case - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, // 0x80-0x8F - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, // 0x90-0x9F - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, // 0xA0-0xAF - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, // 0xB0-0xBF - 0xC0, 0xC1, // 0xC0-0xC1 - 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF: // 0xF5-0xFE - // character is invalid - s.buf = append(append(append([]byte{}, s.buf[:cursor]...), runeErrBytes...), s.buf[cursor+1:]...) - _, _, p = s.stat() - cursor += runeErrBytesLen - s.length += runeErrBytesLen - continue - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - goto ERROR - case 0xEF: - // RuneError is {0xEF, 0xBF, 0xBD} - if s.buf[cursor+1] == 0xBF && s.buf[cursor+2] == 0xBD { - // found RuneError: skip - cursor += 2 - break - } - fallthrough - default: - // multi bytes character - if !utf8.FullRune(s.buf[cursor : len(s.buf)-1]) { - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - goto ERROR - } - r, size := utf8.DecodeRune(s.buf[cursor:]) - if r == utf8.RuneError { - s.buf = append(append(append([]byte{}, s.buf[:cursor]...), runeErrBytes...), s.buf[cursor+1:]...) - cursor += runeErrBytesLen - s.length += runeErrBytesLen - _, _, p = s.stat() - } else { - cursor += int64(size) - } - continue - } - cursor++ - } -ERROR: - return nil, errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) -} - -func (d *stringDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '[': - return nil, d.errUnmarshalType("array", s.totalOffset()) - case '{': - return nil, d.errUnmarshalType("object", s.totalOffset()) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return nil, d.errUnmarshalType("number", s.totalOffset()) - case '"': - return stringBytes(s) - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - } - break - } - return nil, errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) -} - -func (d *stringDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - case '[': - return nil, 0, d.errUnmarshalType("array", cursor) - case '{': - return nil, 0, d.errUnmarshalType("object", cursor) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return nil, 0, d.errUnmarshalType("number", cursor) - case '"': - cursor++ - start := cursor - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case '\\': - cursor++ - switch char(b, cursor) { - case '"': - buf[cursor] = '"' - buf = append(buf[:cursor-1], buf[cursor:]...) - case '\\': - buf[cursor] = '\\' - buf = append(buf[:cursor-1], buf[cursor:]...) - case '/': - buf[cursor] = '/' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 'b': - buf[cursor] = '\b' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 'f': - buf[cursor] = '\f' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 'n': - buf[cursor] = '\n' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 'r': - buf[cursor] = '\r' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 't': - buf[cursor] = '\t' - buf = append(buf[:cursor-1], buf[cursor:]...) - case 'u': - buflen := int64(len(buf)) - if cursor+5 >= buflen { - return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor) - } - code := unicodeToRune(buf[cursor+1 : cursor+5]) - unicode := []byte(string(code)) - buf = append(append(buf[:cursor-1], unicode...), buf[cursor+5:]...) - default: - return nil, 0, errors.ErrUnexpectedEndOfJSON("escaped string", cursor) - } - continue - case '"': - literal := buf[start:cursor] - cursor++ - return literal, cursor, nil - case nul: - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - cursor++ - } - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, errors.ErrInvalidBeginningOfValue(buf[cursor], cursor) - } - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/struct.go b/vendor/github.com/goccy/go-json/internal/decoder/struct.go deleted file mode 100644 index 2c6468045..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/struct.go +++ /dev/null @@ -1,819 +0,0 @@ -package decoder - -import ( - "fmt" - "math" - "math/bits" - "sort" - "strings" - "unicode" - "unicode/utf16" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -type structFieldSet struct { - dec Decoder - offset uintptr - isTaggedKey bool - fieldIdx int - key string - keyLen int64 - err error -} - -type structDecoder struct { - fieldMap map[string]*structFieldSet - fieldUniqueNameNum int - stringDecoder *stringDecoder - structName string - fieldName string - isTriedOptimize bool - keyBitmapUint8 [][256]uint8 - keyBitmapUint16 [][256]uint16 - sortedFieldSets []*structFieldSet - keyDecoder func(*structDecoder, []byte, int64) (int64, *structFieldSet, error) - keyStreamDecoder func(*structDecoder, *Stream) (*structFieldSet, string, error) -} - -var ( - largeToSmallTable [256]byte -) - -func init() { - for i := 0; i < 256; i++ { - c := i - if 'A' <= c && c <= 'Z' { - c += 'a' - 'A' - } - largeToSmallTable[i] = byte(c) - } -} - -func newStructDecoder(structName, fieldName string, fieldMap map[string]*structFieldSet) *structDecoder { - return &structDecoder{ - fieldMap: fieldMap, - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - keyDecoder: decodeKey, - keyStreamDecoder: decodeKeyStream, - } -} - -const ( - allowOptimizeMaxKeyLen = 64 - allowOptimizeMaxFieldLen = 16 -) - -func (d *structDecoder) tryOptimize() { - fieldUniqueNameMap := map[string]int{} - fieldIdx := -1 - for k, v := range d.fieldMap { - lower := strings.ToLower(k) - idx, exists := fieldUniqueNameMap[lower] - if exists { - v.fieldIdx = idx - } else { - fieldIdx++ - v.fieldIdx = fieldIdx - } - fieldUniqueNameMap[lower] = fieldIdx - } - d.fieldUniqueNameNum = len(fieldUniqueNameMap) - - if d.isTriedOptimize { - return - } - fieldMap := map[string]*structFieldSet{} - conflicted := map[string]struct{}{} - for k, v := range d.fieldMap { - key := strings.ToLower(k) - if key != k { - // already exists same key (e.g. Hello and HELLO has same lower case key - if _, exists := conflicted[key]; exists { - d.isTriedOptimize = true - return - } - conflicted[key] = struct{}{} - } - if field, exists := fieldMap[key]; exists { - if field != v { - d.isTriedOptimize = true - return - } - } - fieldMap[key] = v - } - - if len(fieldMap) > allowOptimizeMaxFieldLen { - d.isTriedOptimize = true - return - } - - var maxKeyLen int - sortedKeys := []string{} - for key := range fieldMap { - keyLen := len(key) - if keyLen > allowOptimizeMaxKeyLen { - d.isTriedOptimize = true - return - } - if maxKeyLen < keyLen { - maxKeyLen = keyLen - } - sortedKeys = append(sortedKeys, key) - } - sort.Strings(sortedKeys) - - // By allocating one extra capacity than `maxKeyLen`, - // it is possible to avoid the process of comparing the index of the key with the length of the bitmap each time. - bitmapLen := maxKeyLen + 1 - if len(sortedKeys) <= 8 { - keyBitmap := make([][256]uint8, bitmapLen) - for i, key := range sortedKeys { - for j := 0; j < len(key); j++ { - c := key[j] - keyBitmap[j][c] |= (1 << uint(i)) - } - d.sortedFieldSets = append(d.sortedFieldSets, fieldMap[key]) - } - d.keyBitmapUint8 = keyBitmap - d.keyDecoder = decodeKeyByBitmapUint8 - d.keyStreamDecoder = decodeKeyByBitmapUint8Stream - } else { - keyBitmap := make([][256]uint16, bitmapLen) - for i, key := range sortedKeys { - for j := 0; j < len(key); j++ { - c := key[j] - keyBitmap[j][c] |= (1 << uint(i)) - } - d.sortedFieldSets = append(d.sortedFieldSets, fieldMap[key]) - } - d.keyBitmapUint16 = keyBitmap - d.keyDecoder = decodeKeyByBitmapUint16 - d.keyStreamDecoder = decodeKeyByBitmapUint16Stream - } -} - -// decode from '\uXXXX' -func decodeKeyCharByUnicodeRune(buf []byte, cursor int64) ([]byte, int64) { - const defaultOffset = 4 - const surrogateOffset = 6 - - r := unicodeToRune(buf[cursor : cursor+defaultOffset]) - if utf16.IsSurrogate(r) { - cursor += defaultOffset - if cursor+surrogateOffset >= int64(len(buf)) || buf[cursor] != '\\' || buf[cursor+1] != 'u' { - return []byte(string(unicode.ReplacementChar)), cursor + defaultOffset - 1 - } - cursor += 2 - r2 := unicodeToRune(buf[cursor : cursor+defaultOffset]) - if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - return []byte(string(r)), cursor + defaultOffset - 1 - } - } - return []byte(string(r)), cursor + defaultOffset - 1 -} - -func decodeKeyCharByEscapedChar(buf []byte, cursor int64) ([]byte, int64) { - c := buf[cursor] - cursor++ - switch c { - case '"': - return []byte{'"'}, cursor - case '\\': - return []byte{'\\'}, cursor - case '/': - return []byte{'/'}, cursor - case 'b': - return []byte{'\b'}, cursor - case 'f': - return []byte{'\f'}, cursor - case 'n': - return []byte{'\n'}, cursor - case 'r': - return []byte{'\r'}, cursor - case 't': - return []byte{'\t'}, cursor - case 'u': - return decodeKeyCharByUnicodeRune(buf, cursor) - } - return nil, cursor -} - -func decodeKeyByBitmapUint8(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - var ( - curBit uint8 = math.MaxUint8 - ) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case '"': - cursor++ - c := char(b, cursor) - switch c { - case '"': - cursor++ - return cursor, nil, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - keyIdx := 0 - bitmap := d.keyBitmapUint8 - start := cursor - for { - c := char(b, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros8(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - if keyLen < field.keyLen { - // early match - return cursor, nil, nil - } - return cursor, field, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - case '\\': - cursor++ - chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor) - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor = nextCursor - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor++ - } - default: - return cursor, nil, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - } -} - -func decodeKeyByBitmapUint16(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - var ( - curBit uint16 = math.MaxUint16 - ) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - for { - switch char(b, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case '"': - cursor++ - c := char(b, cursor) - switch c { - case '"': - cursor++ - return cursor, nil, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - keyIdx := 0 - bitmap := d.keyBitmapUint16 - start := cursor - for { - c := char(b, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros16(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - if keyLen < field.keyLen { - // early match - return cursor, nil, nil - } - return cursor, field, nil - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - case '\\': - cursor++ - chars, nextCursor := decodeKeyCharByEscapedChar(buf, cursor) - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor = nextCursor - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - return decodeKeyNotFound(b, cursor) - } - keyIdx++ - } - cursor++ - } - default: - return cursor, nil, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - } -} - -func decodeKeyNotFound(b unsafe.Pointer, cursor int64) (int64, *structFieldSet, error) { - for { - cursor++ - switch char(b, cursor) { - case '"': - cursor++ - return cursor, nil, nil - case '\\': - cursor++ - if char(b, cursor) == nul { - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - case nul: - return 0, nil, errors.ErrUnexpectedEndOfJSON("string", cursor) - } - } -} - -func decodeKey(d *structDecoder, buf []byte, cursor int64) (int64, *structFieldSet, error) { - key, c, err := d.stringDecoder.decodeByte(buf, cursor) - if err != nil { - return 0, nil, err - } - cursor = c - k := *(*string)(unsafe.Pointer(&key)) - field, exists := d.fieldMap[k] - if !exists { - return cursor, nil, nil - } - return cursor, field, nil -} - -func decodeKeyByBitmapUint8Stream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - var ( - curBit uint8 = math.MaxUint8 - ) - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - case '"': - cursor++ - FIRST_CHAR: - start := cursor - switch char(p, cursor) { - case '"': - cursor++ - s.cursor = cursor - return nil, "", nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - goto FIRST_CHAR - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - keyIdx := 0 - bitmap := d.keyBitmapUint8 - for { - c := char(p, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros8(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - s.cursor = cursor - if keyLen < field.keyLen { - // early match - return nil, field.key, nil - } - return field, field.key, nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - case '\\': - s.cursor = cursor + 1 // skip '\' char - chars, err := decodeKeyCharByEscapeCharStream(s) - if err != nil { - return nil, "", err - } - cursor = s.cursor - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - cursor++ - } - default: - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - } - } -} - -func decodeKeyByBitmapUint16Stream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - var ( - curBit uint16 = math.MaxUint16 - ) - _, cursor, p := s.stat() - for { - switch char(p, cursor) { - case ' ', '\n', '\t', '\r': - cursor++ - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - case '"': - cursor++ - FIRST_CHAR: - start := cursor - switch char(p, cursor) { - case '"': - cursor++ - s.cursor = cursor - return nil, "", nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - goto FIRST_CHAR - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - keyIdx := 0 - bitmap := d.keyBitmapUint16 - for { - c := char(p, cursor) - switch c { - case '"': - fieldSetIndex := bits.TrailingZeros16(curBit) - field := d.sortedFieldSets[fieldSetIndex] - keyLen := cursor - start - cursor++ - s.cursor = cursor - if keyLen < field.keyLen { - // early match - return nil, field.key, nil - } - return field, field.key, nil - case nul: - s.cursor = cursor - if s.read() { - _, cursor, p = s.stat() - continue - } - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - case '\\': - s.cursor = cursor + 1 // skip '\' char - chars, err := decodeKeyCharByEscapeCharStream(s) - if err != nil { - return nil, "", err - } - cursor = s.cursor - for _, c := range chars { - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - default: - curBit &= bitmap[keyIdx][largeToSmallTable[c]] - if curBit == 0 { - s.cursor = cursor - return decodeKeyNotFoundStream(s, start) - } - keyIdx++ - } - cursor++ - } - default: - return nil, "", errors.ErrInvalidBeginningOfValue(char(p, cursor), s.totalOffset()) - } - } -} - -// decode from '\uXXXX' -func decodeKeyCharByUnicodeRuneStream(s *Stream) ([]byte, error) { - const defaultOffset = 4 - const surrogateOffset = 6 - - if s.cursor+defaultOffset >= s.length { - if !s.read() { - return nil, errors.ErrInvalidCharacter(s.char(), "escaped unicode char", s.totalOffset()) - } - } - - r := unicodeToRune(s.buf[s.cursor : s.cursor+defaultOffset]) - if utf16.IsSurrogate(r) { - s.cursor += defaultOffset - if s.cursor+surrogateOffset >= s.length { - s.read() - } - if s.cursor+surrogateOffset >= s.length || s.buf[s.cursor] != '\\' || s.buf[s.cursor+1] != 'u' { - s.cursor += defaultOffset - 1 - return []byte(string(unicode.ReplacementChar)), nil - } - r2 := unicodeToRune(s.buf[s.cursor+defaultOffset+2 : s.cursor+surrogateOffset]) - if r := utf16.DecodeRune(r, r2); r != unicode.ReplacementChar { - s.cursor += defaultOffset - 1 - return []byte(string(r)), nil - } - } - s.cursor += defaultOffset - 1 - return []byte(string(r)), nil -} - -func decodeKeyCharByEscapeCharStream(s *Stream) ([]byte, error) { - c := s.buf[s.cursor] - s.cursor++ -RETRY: - switch c { - case '"': - return []byte{'"'}, nil - case '\\': - return []byte{'\\'}, nil - case '/': - return []byte{'/'}, nil - case 'b': - return []byte{'\b'}, nil - case 'f': - return []byte{'\f'}, nil - case 'n': - return []byte{'\n'}, nil - case 'r': - return []byte{'\r'}, nil - case 't': - return []byte{'\t'}, nil - case 'u': - return decodeKeyCharByUnicodeRuneStream(s) - case nul: - if !s.read() { - return nil, errors.ErrInvalidCharacter(s.char(), "escaped char", s.totalOffset()) - } - goto RETRY - default: - return nil, errors.ErrUnexpectedEndOfJSON("struct field", s.totalOffset()) - } -} - -func decodeKeyNotFoundStream(s *Stream, start int64) (*structFieldSet, string, error) { - buf, cursor, p := s.stat() - for { - cursor++ - switch char(p, cursor) { - case '"': - b := buf[start:cursor] - key := *(*string)(unsafe.Pointer(&b)) - cursor++ - s.cursor = cursor - return nil, key, nil - case '\\': - cursor++ - if char(p, cursor) == nul { - s.cursor = cursor - if !s.read() { - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - buf, cursor, p = s.statForRetry() - } - case nul: - s.cursor = cursor - if !s.read() { - return nil, "", errors.ErrUnexpectedEndOfJSON("string", s.totalOffset()) - } - buf, cursor, p = s.statForRetry() - } - } -} - -func decodeKeyStream(d *structDecoder, s *Stream) (*structFieldSet, string, error) { - key, err := d.stringDecoder.decodeStreamByte(s) - if err != nil { - return nil, "", err - } - k := *(*string)(unsafe.Pointer(&key)) - return d.fieldMap[k], k, nil -} - -func (d *structDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - depth++ - if depth > maxDecodeNestingDepth { - return errors.ErrExceededMaxDepth(s.char(), s.cursor) - } - - c := s.skipWhiteSpace() - switch c { - case 'n': - if err := nullBytes(s); err != nil { - return err - } - return nil - default: - if s.char() != '{' { - return errors.ErrInvalidBeginningOfValue(s.char(), s.totalOffset()) - } - } - s.cursor++ - if s.skipWhiteSpace() == '}' { - s.cursor++ - return nil - } - var ( - seenFields map[int]struct{} - seenFieldNum int - ) - firstWin := (s.Option.Flags & FirstWinOption) != 0 - if firstWin { - seenFields = make(map[int]struct{}, d.fieldUniqueNameNum) - } - for { - s.reset() - field, key, err := d.keyStreamDecoder(d, s) - if err != nil { - return err - } - if s.skipWhiteSpace() != ':' { - return errors.ErrExpected("colon after object key", s.totalOffset()) - } - s.cursor++ - if field != nil { - if field.err != nil { - return field.err - } - if firstWin { - if _, exists := seenFields[field.fieldIdx]; exists { - if err := s.skipValue(depth); err != nil { - return err - } - } else { - if err := field.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+field.offset)); err != nil { - return err - } - seenFieldNum++ - if d.fieldUniqueNameNum <= seenFieldNum { - return s.skipObject(depth) - } - seenFields[field.fieldIdx] = struct{}{} - } - } else { - if err := field.dec.DecodeStream(s, depth, unsafe.Pointer(uintptr(p)+field.offset)); err != nil { - return err - } - } - } else if s.DisallowUnknownFields { - return fmt.Errorf("json: unknown field %q", key) - } else { - if err := s.skipValue(depth); err != nil { - return err - } - } - c := s.skipWhiteSpace() - if c == '}' { - s.cursor++ - return nil - } - if c != ',' { - return errors.ErrExpected("comma after object element", s.totalOffset()) - } - s.cursor++ - } -} - -func (d *structDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - depth++ - if depth > maxDecodeNestingDepth { - return 0, errors.ErrExceededMaxDepth(buf[cursor], cursor) - } - buflen := int64(len(buf)) - cursor = skipWhiteSpace(buf, cursor) - b := (*sliceHeader)(unsafe.Pointer(&buf)).data - switch char(b, cursor) { - case 'n': - if err := validateNull(buf, cursor); err != nil { - return 0, err - } - cursor += 4 - return cursor, nil - case '{': - default: - return 0, errors.ErrInvalidBeginningOfValue(char(b, cursor), cursor) - } - cursor++ - cursor = skipWhiteSpace(buf, cursor) - if buf[cursor] == '}' { - cursor++ - return cursor, nil - } - var ( - seenFields map[int]struct{} - seenFieldNum int - ) - firstWin := (ctx.Option.Flags & FirstWinOption) != 0 - if firstWin { - seenFields = make(map[int]struct{}, d.fieldUniqueNameNum) - } - for { - c, field, err := d.keyDecoder(d, buf, cursor) - if err != nil { - return 0, err - } - cursor = skipWhiteSpace(buf, c) - if char(b, cursor) != ':' { - return 0, errors.ErrExpected("colon after object key", cursor) - } - cursor++ - if cursor >= buflen { - return 0, errors.ErrExpected("object value after colon", cursor) - } - if field != nil { - if field.err != nil { - return 0, field.err - } - if firstWin { - if _, exists := seenFields[field.fieldIdx]; exists { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } else { - c, err := field.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+field.offset)) - if err != nil { - return 0, err - } - cursor = c - seenFieldNum++ - if d.fieldUniqueNameNum <= seenFieldNum { - return skipObject(buf, cursor, depth) - } - seenFields[field.fieldIdx] = struct{}{} - } - } else { - c, err := field.dec.Decode(ctx, cursor, depth, unsafe.Pointer(uintptr(p)+field.offset)) - if err != nil { - return 0, err - } - cursor = c - } - } else { - c, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - cursor = c - } - cursor = skipWhiteSpace(buf, cursor) - if char(b, cursor) == '}' { - cursor++ - return cursor, nil - } - if char(b, cursor) != ',' { - return 0, errors.ErrExpected("comma after object element", cursor) - } - cursor++ - } -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/type.go b/vendor/github.com/goccy/go-json/internal/decoder/type.go deleted file mode 100644 index 70e9907c8..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/type.go +++ /dev/null @@ -1,29 +0,0 @@ -package decoder - -import ( - "context" - "encoding" - "encoding/json" - "reflect" - "unsafe" -) - -type Decoder interface { - Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error) - DecodeStream(*Stream, int64, unsafe.Pointer) error -} - -const ( - nul = '\000' - maxDecodeNestingDepth = 10000 -) - -type unmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} - -var ( - unmarshalJSONType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem() - unmarshalJSONContextType = reflect.TypeOf((*unmarshalerContext)(nil)).Elem() - unmarshalTextType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() -) diff --git a/vendor/github.com/goccy/go-json/internal/decoder/uint.go b/vendor/github.com/goccy/go-json/internal/decoder/uint.go deleted file mode 100644 index a62c51492..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/uint.go +++ /dev/null @@ -1,190 +0,0 @@ -package decoder - -import ( - "fmt" - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type uintDecoder struct { - typ *runtime.Type - kind reflect.Kind - op func(unsafe.Pointer, uint64) - structName string - fieldName string -} - -func newUintDecoder(typ *runtime.Type, structName, fieldName string, op func(unsafe.Pointer, uint64)) *uintDecoder { - return &uintDecoder{ - typ: typ, - kind: typ.Kind(), - op: op, - structName: structName, - fieldName: fieldName, - } -} - -func (d *uintDecoder) typeError(buf []byte, offset int64) *errors.UnmarshalTypeError { - return &errors.UnmarshalTypeError{ - Value: fmt.Sprintf("number %s", string(buf)), - Type: runtime.RType2Type(d.typ), - Offset: offset, - } -} - -var ( - pow10u64 = [...]uint64{ - 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - } - pow10u64Len = len(pow10u64) -) - -func (d *uintDecoder) parseUint(b []byte) (uint64, error) { - maxDigit := len(b) - if maxDigit > pow10u64Len { - return 0, fmt.Errorf("invalid length of number") - } - sum := uint64(0) - for i := 0; i < maxDigit; i++ { - c := uint64(b[i]) - 48 - digitValue := pow10u64[maxDigit-i-1] - sum += c * digitValue - } - return sum, nil -} - -func (d *uintDecoder) decodeStreamByte(s *Stream) ([]byte, error) { - for { - switch s.char() { - case ' ', '\n', '\t', '\r': - s.cursor++ - continue - case '0': - s.cursor++ - return numZeroBuf, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := s.cursor - for { - s.cursor++ - if numTable[s.char()] { - continue - } else if s.char() == nul { - if s.read() { - s.cursor-- // for retry current character - continue - } - } - break - } - num := s.buf[start:s.cursor] - return num, nil - case 'n': - if err := nullBytes(s); err != nil { - return nil, err - } - return nil, nil - case nul: - if s.read() { - continue - } - default: - return nil, d.typeError([]byte{s.char()}, s.totalOffset()) - } - break - } - return nil, errors.ErrUnexpectedEndOfJSON("number(unsigned integer)", s.totalOffset()) -} - -func (d *uintDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { - for { - switch buf[cursor] { - case ' ', '\n', '\t', '\r': - cursor++ - continue - case '0': - cursor++ - return numZeroBuf, cursor, nil - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - start := cursor - cursor++ - for numTable[buf[cursor]] { - cursor++ - } - num := buf[start:cursor] - return num, cursor, nil - case 'n': - if err := validateNull(buf, cursor); err != nil { - return nil, 0, err - } - cursor += 4 - return nil, cursor, nil - default: - return nil, 0, d.typeError([]byte{buf[cursor]}, cursor) - } - } -} - -func (d *uintDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - return nil - } - u64, err := d.parseUint(bytes) - if err != nil { - return d.typeError(bytes, s.totalOffset()) - } - switch d.kind { - case reflect.Uint8: - if (1 << 8) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Uint16: - if (1 << 16) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - case reflect.Uint32: - if (1 << 32) <= u64 { - return d.typeError(bytes, s.totalOffset()) - } - } - d.op(p, u64) - return nil -} - -func (d *uintDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - return c, nil - } - cursor = c - u64, err := d.parseUint(bytes) - if err != nil { - return 0, d.typeError(bytes, cursor) - } - switch d.kind { - case reflect.Uint8: - if (1 << 8) <= u64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Uint16: - if (1 << 16) <= u64 { - return 0, d.typeError(bytes, cursor) - } - case reflect.Uint32: - if (1 << 32) <= u64 { - return 0, d.typeError(bytes, cursor) - } - } - d.op(p, u64) - return cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go deleted file mode 100644 index d90f39cc5..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_json.go +++ /dev/null @@ -1,91 +0,0 @@ -package decoder - -import ( - "encoding/json" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type unmarshalJSONDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newUnmarshalJSONDecoder(typ *runtime.Type, structName, fieldName string) *unmarshalJSONDecoder { - return &unmarshalJSONDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *unmarshalJSONDecoder) annotateError(cursor int64, err error) { - switch e := err.(type) { - case *errors.UnmarshalTypeError: - e.Struct = d.structName - e.Field = d.fieldName - case *errors.SyntaxError: - e.Offset = cursor - } -} - -func (d *unmarshalJSONDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - dst := make([]byte, len(src)) - copy(dst, src) - - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - if (s.Option.Flags & ContextOption) != 0 { - if err := v.(unmarshalerContext).UnmarshalJSON(s.Option.Context, dst); err != nil { - d.annotateError(s.cursor, err) - return err - } - } else { - if err := v.(json.Unmarshaler).UnmarshalJSON(dst); err != nil { - d.annotateError(s.cursor, err) - return err - } - } - return nil -} - -func (d *unmarshalJSONDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - dst := make([]byte, len(src)) - copy(dst, src) - - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - if (ctx.Option.Flags & ContextOption) != 0 { - if err := v.(unmarshalerContext).UnmarshalJSON(ctx.Option.Context, dst); err != nil { - d.annotateError(cursor, err) - return 0, err - } - } else { - if err := v.(json.Unmarshaler).UnmarshalJSON(dst); err != nil { - d.annotateError(cursor, err) - return 0, err - } - } - return end, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go b/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go deleted file mode 100644 index 1ef287782..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/unmarshal_text.go +++ /dev/null @@ -1,280 +0,0 @@ -package decoder - -import ( - "bytes" - "encoding" - "unicode" - "unicode/utf16" - "unicode/utf8" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type unmarshalTextDecoder struct { - typ *runtime.Type - structName string - fieldName string -} - -func newUnmarshalTextDecoder(typ *runtime.Type, structName, fieldName string) *unmarshalTextDecoder { - return &unmarshalTextDecoder{ - typ: typ, - structName: structName, - fieldName: fieldName, - } -} - -func (d *unmarshalTextDecoder) annotateError(cursor int64, err error) { - switch e := err.(type) { - case *errors.UnmarshalTypeError: - e.Struct = d.structName - e.Field = d.fieldName - case *errors.SyntaxError: - e.Offset = cursor - } -} - -var ( - nullbytes = []byte(`null`) -) - -func (d *unmarshalTextDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - s.skipWhiteSpace() - start := s.cursor - if err := s.skipValue(depth); err != nil { - return err - } - src := s.buf[start:s.cursor] - if len(src) > 0 { - switch src[0] { - case '[': - return &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '{': - return &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: s.totalOffset(), - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return nil - } - } - } - dst := make([]byte, len(src)) - copy(dst, src) - - if b, ok := unquoteBytes(dst); ok { - dst = b - } - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: p, - })) - if err := v.(encoding.TextUnmarshaler).UnmarshalText(dst); err != nil { - d.annotateError(s.cursor, err) - return err - } - return nil -} - -func (d *unmarshalTextDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - buf := ctx.Buf - cursor = skipWhiteSpace(buf, cursor) - start := cursor - end, err := skipValue(buf, cursor, depth) - if err != nil { - return 0, err - } - src := buf[start:end] - if len(src) > 0 { - switch src[0] { - case '[': - return 0, &errors.UnmarshalTypeError{ - Value: "array", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '{': - return 0, &errors.UnmarshalTypeError{ - Value: "object", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return 0, &errors.UnmarshalTypeError{ - Value: "number", - Type: runtime.RType2Type(d.typ), - Offset: start, - } - case 'n': - if bytes.Equal(src, nullbytes) { - *(*unsafe.Pointer)(p) = nil - return end, nil - } - } - } - - if s, ok := unquoteBytes(src); ok { - src = s - } - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: d.typ, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) - if err := v.(encoding.TextUnmarshaler).UnmarshalText(src); err != nil { - d.annotateError(cursor, err) - return 0, err - } - return end, nil -} - -func unquoteBytes(s []byte) (t []byte, ok bool) { - length := len(s) - if length < 2 || s[0] != '"' || s[length-1] != '"' { - return - } - s = s[1 : length-1] - length -= 2 - - // Check for unusual characters. If there are none, - // then no unquoting is needed, so return a slice of the - // original bytes. - r := 0 - for r < length { - c := s[r] - if c == '\\' || c == '"' || c < ' ' { - break - } - if c < utf8.RuneSelf { - r++ - continue - } - rr, size := utf8.DecodeRune(s[r:]) - if rr == utf8.RuneError && size == 1 { - break - } - r += size - } - if r == length { - return s, true - } - - b := make([]byte, length+2*utf8.UTFMax) - w := copy(b, s[0:r]) - for r < length { - // Out of room? Can only happen if s is full of - // malformed UTF-8 and we're replacing each - // byte with RuneError. - if w >= len(b)-2*utf8.UTFMax { - nb := make([]byte, (len(b)+utf8.UTFMax)*2) - copy(nb, b[0:w]) - b = nb - } - switch c := s[r]; { - case c == '\\': - r++ - if r >= length { - return - } - switch s[r] { - default: - return - case '"', '\\', '/', '\'': - b[w] = s[r] - r++ - w++ - case 'b': - b[w] = '\b' - r++ - w++ - case 'f': - b[w] = '\f' - r++ - w++ - case 'n': - b[w] = '\n' - r++ - w++ - case 'r': - b[w] = '\r' - r++ - w++ - case 't': - b[w] = '\t' - r++ - w++ - case 'u': - r-- - rr := getu4(s[r:]) - if rr < 0 { - return - } - r += 6 - if utf16.IsSurrogate(rr) { - rr1 := getu4(s[r:]) - if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { - // A valid pair; consume. - r += 6 - w += utf8.EncodeRune(b[w:], dec) - break - } - // Invalid surrogate; fall back to replacement rune. - rr = unicode.ReplacementChar - } - w += utf8.EncodeRune(b[w:], rr) - } - - // Quote, control characters are invalid. - case c == '"', c < ' ': - return - - // ASCII - case c < utf8.RuneSelf: - b[w] = c - r++ - w++ - - // Coerce to well-formed UTF-8. - default: - rr, size := utf8.DecodeRune(s[r:]) - r += size - w += utf8.EncodeRune(b[w:], rr) - } - } - return b[0:w], true -} - -func getu4(s []byte) rune { - if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { - return -1 - } - var r rune - for _, c := range s[2:6] { - switch { - case '0' <= c && c <= '9': - c = c - '0' - case 'a' <= c && c <= 'f': - c = c - 'a' + 10 - case 'A' <= c && c <= 'F': - c = c - 'A' + 10 - default: - return -1 - } - r = r*16 + rune(c) - } - return r -} diff --git a/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go b/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go deleted file mode 100644 index 66227ae02..000000000 --- a/vendor/github.com/goccy/go-json/internal/decoder/wrapped_string.go +++ /dev/null @@ -1,68 +0,0 @@ -package decoder - -import ( - "reflect" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type wrappedStringDecoder struct { - typ *runtime.Type - dec Decoder - stringDecoder *stringDecoder - structName string - fieldName string - isPtrType bool -} - -func newWrappedStringDecoder(typ *runtime.Type, dec Decoder, structName, fieldName string) *wrappedStringDecoder { - return &wrappedStringDecoder{ - typ: typ, - dec: dec, - stringDecoder: newStringDecoder(structName, fieldName), - structName: structName, - fieldName: fieldName, - isPtrType: typ.Kind() == reflect.Ptr, - } -} - -func (d *wrappedStringDecoder) DecodeStream(s *Stream, depth int64, p unsafe.Pointer) error { - bytes, err := d.stringDecoder.decodeStreamByte(s) - if err != nil { - return err - } - if bytes == nil { - if d.isPtrType { - *(*unsafe.Pointer)(p) = nil - } - return nil - } - b := make([]byte, len(bytes)+1) - copy(b, bytes) - if _, err := d.dec.Decode(&RuntimeContext{Buf: b}, 0, depth, p); err != nil { - return err - } - return nil -} - -func (d *wrappedStringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { - bytes, c, err := d.stringDecoder.decodeByte(ctx.Buf, cursor) - if err != nil { - return 0, err - } - if bytes == nil { - if d.isPtrType { - *(*unsafe.Pointer)(p) = nil - } - return c, nil - } - bytes = append(bytes, nul) - oldBuf := ctx.Buf - ctx.Buf = bytes - if _, err := d.dec.Decode(ctx, 0, depth, p); err != nil { - return 0, err - } - ctx.Buf = oldBuf - return c, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compact.go b/vendor/github.com/goccy/go-json/internal/encoder/compact.go deleted file mode 100644 index 0eb9545d8..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compact.go +++ /dev/null @@ -1,286 +0,0 @@ -package encoder - -import ( - "bytes" - "fmt" - "strconv" - "unsafe" - - "github.com/goccy/go-json/internal/errors" -) - -var ( - isWhiteSpace = [256]bool{ - ' ': true, - '\n': true, - '\t': true, - '\r': true, - } - isHTMLEscapeChar = [256]bool{ - '<': true, - '>': true, - '&': true, - } - nul = byte('\000') -) - -func Compact(buf *bytes.Buffer, src []byte, escape bool) error { - if len(src) == 0 { - return errors.ErrUnexpectedEndOfJSON("", 0) - } - buf.Grow(len(src)) - dst := buf.Bytes() - - ctx := TakeRuntimeContext() - ctxBuf := ctx.Buf[:0] - ctxBuf = append(append(ctxBuf, src...), nul) - ctx.Buf = ctxBuf - - if err := compactAndWrite(buf, dst, ctxBuf, escape); err != nil { - ReleaseRuntimeContext(ctx) - return err - } - ReleaseRuntimeContext(ctx) - return nil -} - -func compactAndWrite(buf *bytes.Buffer, dst []byte, src []byte, escape bool) error { - dst, err := compact(dst, src, escape) - if err != nil { - return err - } - if _, err := buf.Write(dst); err != nil { - return err - } - return nil -} - -func compact(dst, src []byte, escape bool) ([]byte, error) { - buf, cursor, err := compactValue(dst, src, 0, escape) - if err != nil { - return nil, err - } - if err := validateEndBuf(src, cursor); err != nil { - return nil, err - } - return buf, nil -} - -func validateEndBuf(src []byte, cursor int64) error { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case nul: - return nil - } - return errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after top-level value", src[cursor]), - cursor+1, - ) - } -} - -func skipWhiteSpace(buf []byte, cursor int64) int64 { -LOOP: - if isWhiteSpace[buf[cursor]] { - cursor++ - goto LOOP - } - return cursor -} - -func compactValue(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return compactObject(dst, src, cursor, escape) - case '}': - return nil, 0, errors.ErrSyntax("unexpected character '}'", cursor) - case '[': - return compactArray(dst, src, cursor, escape) - case ']': - return nil, 0, errors.ErrSyntax("unexpected character ']'", cursor) - case '"': - return compactString(dst, src, cursor, escape) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return compactNumber(dst, src, cursor) - case 't': - return compactTrue(dst, src, cursor) - case 'f': - return compactFalse(dst, src, cursor) - case 'n': - return compactNull(dst, src, cursor) - default: - return nil, 0, errors.ErrSyntax(fmt.Sprintf("unexpected character '%c'", src[cursor]), cursor) - } - } -} - -func compactObject(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] == '{' { - dst = append(dst, '{') - } else { - return nil, 0, errors.ErrExpected("expected { character for object value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == '}' { - dst = append(dst, '}') - return dst, cursor + 1, nil - } - var err error - for { - cursor = skipWhiteSpace(src, cursor) - dst, cursor, err = compactString(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - if src[cursor] != ':' { - return nil, 0, errors.ErrExpected("colon after object key", cursor) - } - dst = append(dst, ':') - dst, cursor, err = compactValue(dst, src, cursor+1, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case '}': - dst = append(dst, '}') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrExpected("comma after object value", cursor) - } - cursor++ - } -} - -func compactArray(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] == '[' { - dst = append(dst, '[') - } else { - return nil, 0, errors.ErrExpected("expected [ character for array value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == ']' { - dst = append(dst, ']') - return dst, cursor + 1, nil - } - var err error - for { - dst, cursor, err = compactValue(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case ']': - dst = append(dst, ']') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrExpected("comma after array value", cursor) - } - cursor++ - } -} - -func compactString(dst, src []byte, cursor int64, escape bool) ([]byte, int64, error) { - if src[cursor] != '"' { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "string", cursor) - } - start := cursor - for { - cursor++ - c := src[cursor] - if escape { - if isHTMLEscapeChar[c] { - dst = append(dst, src[start:cursor]...) - dst = append(dst, `\u00`...) - dst = append(dst, hex[c>>4], hex[c&0xF]) - start = cursor + 1 - } else if c == 0xE2 && cursor+2 < int64(len(src)) && src[cursor+1] == 0x80 && src[cursor+2]&^1 == 0xA8 { - dst = append(dst, src[start:cursor]...) - dst = append(dst, `\u202`...) - dst = append(dst, hex[src[cursor+2]&0xF]) - cursor += 2 - start = cursor + 3 - } - } - switch c { - case '\\': - cursor++ - if src[cursor] == nul { - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", int64(len(src))) - } - case '"': - cursor++ - return append(dst, src[start:cursor]...), cursor, nil - case nul: - return nil, 0, errors.ErrUnexpectedEndOfJSON("string", int64(len(src))) - } - } -} - -func compactNumber(dst, src []byte, cursor int64) ([]byte, int64, error) { - start := cursor - for { - cursor++ - if floatTable[src[cursor]] { - continue - } - break - } - num := src[start:cursor] - if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&num)), 64); err != nil { - return nil, 0, err - } - dst = append(dst, num...) - return dst, cursor, nil -} - -func compactTrue(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+3 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("true", cursor) - } - if !bytes.Equal(src[cursor:cursor+4], []byte(`true`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "true", cursor) - } - dst = append(dst, "true"...) - cursor += 4 - return dst, cursor, nil -} - -func compactFalse(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+4 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("false", cursor) - } - if !bytes.Equal(src[cursor:cursor+5], []byte(`false`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "false", cursor) - } - dst = append(dst, "false"...) - cursor += 5 - return dst, cursor, nil -} - -func compactNull(dst, src []byte, cursor int64) ([]byte, int64, error) { - if cursor+3 >= int64(len(src)) { - return nil, 0, errors.ErrUnexpectedEndOfJSON("null", cursor) - } - if !bytes.Equal(src[cursor:cursor+4], []byte(`null`)) { - return nil, 0, errors.ErrInvalidCharacter(src[cursor], "null", cursor) - } - dst = append(dst, "null"...) - cursor += 4 - return dst, cursor, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler.go deleted file mode 100644 index c627ed307..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler.go +++ /dev/null @@ -1,1570 +0,0 @@ -package encoder - -import ( - "context" - "encoding" - "encoding/json" - "fmt" - "reflect" - "strings" - "sync/atomic" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -type marshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -var ( - marshalJSONType = reflect.TypeOf((*json.Marshaler)(nil)).Elem() - marshalJSONContextType = reflect.TypeOf((*marshalerContext)(nil)).Elem() - marshalTextType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() - jsonNumberType = reflect.TypeOf(json.Number("")) - cachedOpcodeSets []*OpcodeSet - cachedOpcodeMap unsafe.Pointer // map[uintptr]*OpcodeSet - typeAddr *runtime.TypeAddr -) - -func init() { - typeAddr = runtime.AnalyzeTypeAddr() - if typeAddr == nil { - typeAddr = &runtime.TypeAddr{} - } - cachedOpcodeSets = make([]*OpcodeSet, typeAddr.AddrRange>>typeAddr.AddrShift) -} - -func loadOpcodeMap() map[uintptr]*OpcodeSet { - p := atomic.LoadPointer(&cachedOpcodeMap) - return *(*map[uintptr]*OpcodeSet)(unsafe.Pointer(&p)) -} - -func storeOpcodeSet(typ uintptr, set *OpcodeSet, m map[uintptr]*OpcodeSet) { - newOpcodeMap := make(map[uintptr]*OpcodeSet, len(m)+1) - newOpcodeMap[typ] = set - - for k, v := range m { - newOpcodeMap[k] = v - } - - atomic.StorePointer(&cachedOpcodeMap, *(*unsafe.Pointer)(unsafe.Pointer(&newOpcodeMap))) -} - -func compileToGetCodeSetSlowPath(typeptr uintptr) (*OpcodeSet, error) { - opcodeMap := loadOpcodeMap() - if codeSet, exists := opcodeMap[typeptr]; exists { - return codeSet, nil - } - - // noescape trick for header.typ ( reflect.*rtype ) - copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr)) - - noescapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - }) - if err != nil { - return nil, err - } - escapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - escapeKey: true, - }) - if err != nil { - return nil, err - } - noescapeKeyCode = copyOpcode(noescapeKeyCode) - escapeKeyCode = copyOpcode(escapeKeyCode) - setTotalLengthToInterfaceOp(noescapeKeyCode) - setTotalLengthToInterfaceOp(escapeKeyCode) - interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode) - interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode) - codeLength := noescapeKeyCode.TotalLength() - codeSet := &OpcodeSet{ - Type: copiedType, - NoescapeKeyCode: noescapeKeyCode, - EscapeKeyCode: escapeKeyCode, - InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode, - InterfaceEscapeKeyCode: interfaceEscapeKeyCode, - CodeLength: codeLength, - EndCode: ToEndCode(interfaceNoescapeKeyCode), - } - storeOpcodeSet(typeptr, codeSet, opcodeMap) - return codeSet, nil -} - -func compileHead(ctx *compileContext) (*Opcode, error) { - typ := ctx.typ - switch { - case implementsMarshalJSON(typ): - return compileMarshalJSON(ctx) - case implementsMarshalText(typ): - return compileMarshalText(ctx) - } - - isPtr := false - orgType := typ - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - isPtr = true - } - switch { - case implementsMarshalJSON(typ): - return compileMarshalJSON(ctx) - case implementsMarshalText(typ): - return compileMarshalText(ctx) - } - switch typ.Kind() { - case reflect.Slice: - ctx := ctx.withType(typ) - elem := typ.Elem() - if elem.Kind() == reflect.Uint8 { - p := runtime.PtrTo(elem) - if !implementsMarshalJSONType(p) && !p.Implements(marshalTextType) { - if isPtr { - return compileBytesPtr(ctx) - } - return compileBytes(ctx) - } - } - code, err := compileSlice(ctx) - if err != nil { - return nil, err - } - optimizeStructEnd(code) - linkRecursiveCode(code) - return code, nil - case reflect.Map: - if isPtr { - return compilePtr(ctx.withType(runtime.PtrTo(typ))) - } - code, err := compileMap(ctx.withType(typ)) - if err != nil { - return nil, err - } - optimizeStructEnd(code) - linkRecursiveCode(code) - return code, nil - case reflect.Struct: - code, err := compileStruct(ctx.withType(typ), isPtr) - if err != nil { - return nil, err - } - optimizeStructEnd(code) - linkRecursiveCode(code) - return code, nil - case reflect.Int: - ctx := ctx.withType(typ) - if isPtr { - return compileIntPtr(ctx) - } - return compileInt(ctx) - case reflect.Int8: - ctx := ctx.withType(typ) - if isPtr { - return compileInt8Ptr(ctx) - } - return compileInt8(ctx) - case reflect.Int16: - ctx := ctx.withType(typ) - if isPtr { - return compileInt16Ptr(ctx) - } - return compileInt16(ctx) - case reflect.Int32: - ctx := ctx.withType(typ) - if isPtr { - return compileInt32Ptr(ctx) - } - return compileInt32(ctx) - case reflect.Int64: - ctx := ctx.withType(typ) - if isPtr { - return compileInt64Ptr(ctx) - } - return compileInt64(ctx) - case reflect.Uint, reflect.Uintptr: - ctx := ctx.withType(typ) - if isPtr { - return compileUintPtr(ctx) - } - return compileUint(ctx) - case reflect.Uint8: - ctx := ctx.withType(typ) - if isPtr { - return compileUint8Ptr(ctx) - } - return compileUint8(ctx) - case reflect.Uint16: - ctx := ctx.withType(typ) - if isPtr { - return compileUint16Ptr(ctx) - } - return compileUint16(ctx) - case reflect.Uint32: - ctx := ctx.withType(typ) - if isPtr { - return compileUint32Ptr(ctx) - } - return compileUint32(ctx) - case reflect.Uint64: - ctx := ctx.withType(typ) - if isPtr { - return compileUint64Ptr(ctx) - } - return compileUint64(ctx) - case reflect.Float32: - ctx := ctx.withType(typ) - if isPtr { - return compileFloat32Ptr(ctx) - } - return compileFloat32(ctx) - case reflect.Float64: - ctx := ctx.withType(typ) - if isPtr { - return compileFloat64Ptr(ctx) - } - return compileFloat64(ctx) - case reflect.String: - ctx := ctx.withType(typ) - if isPtr { - return compileStringPtr(ctx) - } - return compileString(ctx) - case reflect.Bool: - ctx := ctx.withType(typ) - if isPtr { - return compileBoolPtr(ctx) - } - return compileBool(ctx) - case reflect.Interface: - ctx := ctx.withType(typ) - if isPtr { - return compileInterfacePtr(ctx) - } - return compileInterface(ctx) - default: - if isPtr && typ.Implements(marshalTextType) { - typ = orgType - } - code, err := compile(ctx.withType(typ), isPtr) - if err != nil { - return nil, err - } - optimizeStructEnd(code) - linkRecursiveCode(code) - return code, nil - } -} - -func linkRecursiveCode(c *Opcode) { - for code := c; code.Op != OpEnd && code.Op != OpRecursiveEnd; { - switch code.Op { - case OpRecursive, OpRecursivePtr: - if code.Jmp.Linked { - code = code.Next - continue - } - code.Jmp.Code = copyOpcode(code.Jmp.Code) - - c := code.Jmp.Code - c.End.Next = newEndOp(&compileContext{}) - c.Op = c.Op.PtrHeadToHead() - - beforeLastCode := c.End - lastCode := beforeLastCode.Next - - lastCode.Idx = beforeLastCode.Idx + uintptrSize - lastCode.ElemIdx = lastCode.Idx + uintptrSize - lastCode.Length = lastCode.Idx + 2*uintptrSize - - // extend length to alloc slot for elemIdx + length - totalLength := uintptr(code.TotalLength() + 3) - nextTotalLength := uintptr(c.TotalLength() + 3) - - c.End.Next.Op = OpRecursiveEnd - - code.Jmp.CurLen = totalLength - code.Jmp.NextLen = nextTotalLength - code.Jmp.Linked = true - - linkRecursiveCode(code.Jmp.Code) - - code = code.Next - continue - } - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - default: - code = code.Next - } - } -} - -func optimizeStructEnd(c *Opcode) { - for code := c; code.Op != OpEnd; { - if code.Op == OpRecursive || code.Op == OpRecursivePtr { - // ignore if exists recursive operation - return - } - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - default: - code = code.Next - } - } - - for code := c; code.Op != OpEnd; { - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - case CodeStructEnd: - switch code.Op { - case OpStructEnd: - prev := code.PrevField - prevOp := prev.Op.String() - if strings.Contains(prevOp, "Head") || - strings.Contains(prevOp, "Slice") || - strings.Contains(prevOp, "Array") || - strings.Contains(prevOp, "Map") || - strings.Contains(prevOp, "MarshalJSON") || - strings.Contains(prevOp, "MarshalText") { - // not exists field - code = code.Next - break - } - if prev.Op != prev.Op.FieldToEnd() { - prev.Op = prev.Op.FieldToEnd() - prev.Next = code.Next - } - code = code.Next - default: - code = code.Next - } - default: - code = code.Next - } - } -} - -func implementsMarshalJSON(typ *runtime.Type) bool { - if !implementsMarshalJSONType(typ) { - return false - } - if typ.Kind() != reflect.Ptr { - return true - } - // type kind is reflect.Ptr - if !implementsMarshalJSONType(typ.Elem()) { - return true - } - // needs to dereference - return false -} - -func implementsMarshalText(typ *runtime.Type) bool { - if !typ.Implements(marshalTextType) { - return false - } - if typ.Kind() != reflect.Ptr { - return true - } - // type kind is reflect.Ptr - if !typ.Elem().Implements(marshalTextType) { - return true - } - // needs to dereference - return false -} - -func compile(ctx *compileContext, isPtr bool) (*Opcode, error) { - typ := ctx.typ - switch { - case implementsMarshalJSON(typ): - return compileMarshalJSON(ctx) - case implementsMarshalText(typ): - return compileMarshalText(ctx) - } - switch typ.Kind() { - case reflect.Ptr: - return compilePtr(ctx) - case reflect.Slice: - elem := typ.Elem() - if elem.Kind() == reflect.Uint8 { - p := runtime.PtrTo(elem) - if !implementsMarshalJSONType(p) && !p.Implements(marshalTextType) { - return compileBytes(ctx) - } - } - return compileSlice(ctx) - case reflect.Array: - return compileArray(ctx) - case reflect.Map: - return compileMap(ctx) - case reflect.Struct: - return compileStruct(ctx, isPtr) - case reflect.Interface: - return compileInterface(ctx) - case reflect.Int: - return compileInt(ctx) - case reflect.Int8: - return compileInt8(ctx) - case reflect.Int16: - return compileInt16(ctx) - case reflect.Int32: - return compileInt32(ctx) - case reflect.Int64: - return compileInt64(ctx) - case reflect.Uint: - return compileUint(ctx) - case reflect.Uint8: - return compileUint8(ctx) - case reflect.Uint16: - return compileUint16(ctx) - case reflect.Uint32: - return compileUint32(ctx) - case reflect.Uint64: - return compileUint64(ctx) - case reflect.Uintptr: - return compileUint(ctx) - case reflect.Float32: - return compileFloat32(ctx) - case reflect.Float64: - return compileFloat64(ctx) - case reflect.String: - return compileString(ctx) - case reflect.Bool: - return compileBool(ctx) - } - return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)} -} - -func convertPtrOp(code *Opcode) OpType { - ptrHeadOp := code.Op.HeadToPtrHead() - if code.Op != ptrHeadOp { - if code.PtrNum > 0 { - // ptr field and ptr head - code.PtrNum-- - } - return ptrHeadOp - } - switch code.Op { - case OpInt: - return OpIntPtr - case OpUint: - return OpUintPtr - case OpFloat32: - return OpFloat32Ptr - case OpFloat64: - return OpFloat64Ptr - case OpString: - return OpStringPtr - case OpBool: - return OpBoolPtr - case OpBytes: - return OpBytesPtr - case OpNumber: - return OpNumberPtr - case OpArray: - return OpArrayPtr - case OpSlice: - return OpSlicePtr - case OpMap: - return OpMapPtr - case OpMarshalJSON: - return OpMarshalJSONPtr - case OpMarshalText: - return OpMarshalTextPtr - case OpInterface: - return OpInterfacePtr - case OpRecursive: - return OpRecursivePtr - } - return code.Op -} - -func compileKey(ctx *compileContext) (*Opcode, error) { - typ := ctx.typ - switch { - case implementsMarshalJSON(typ): - return compileMarshalJSON(ctx) - case implementsMarshalText(typ): - return compileMarshalText(ctx) - } - switch typ.Kind() { - case reflect.Ptr: - return compilePtr(ctx) - case reflect.String: - return compileString(ctx) - case reflect.Int: - return compileIntString(ctx) - case reflect.Int8: - return compileInt8String(ctx) - case reflect.Int16: - return compileInt16String(ctx) - case reflect.Int32: - return compileInt32String(ctx) - case reflect.Int64: - return compileInt64String(ctx) - case reflect.Uint: - return compileUintString(ctx) - case reflect.Uint8: - return compileUint8String(ctx) - case reflect.Uint16: - return compileUint16String(ctx) - case reflect.Uint32: - return compileUint32String(ctx) - case reflect.Uint64: - return compileUint64String(ctx) - case reflect.Uintptr: - return compileUintString(ctx) - } - return nil, &errors.UnsupportedTypeError{Type: runtime.RType2Type(typ)} -} - -func compilePtr(ctx *compileContext) (*Opcode, error) { - code, err := compile(ctx.withType(ctx.typ.Elem()), true) - if err != nil { - return nil, err - } - code.Op = convertPtrOp(code) - code.PtrNum++ - return code, nil -} - -func compileMarshalJSON(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpMarshalJSON) - typ := ctx.typ - if isPtrMarshalJSONType(typ) { - code.Flags |= AddrForMarshalerFlags - } - if typ.Implements(marshalJSONContextType) || runtime.PtrTo(typ).Implements(marshalJSONContextType) { - code.Flags |= MarshalerContextFlags - } - if isNilableType(typ) { - code.Flags |= IsNilableTypeFlags - } else { - code.Flags &= ^IsNilableTypeFlags - } - ctx.incIndex() - return code, nil -} - -func compileMarshalText(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpMarshalText) - typ := ctx.typ - if !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType) { - code.Flags |= AddrForMarshalerFlags - } - if isNilableType(typ) { - code.Flags |= IsNilableTypeFlags - } else { - code.Flags &= ^IsNilableTypeFlags - } - ctx.incIndex() - return code, nil -} - -const intSize = 32 << (^uint(0) >> 63) - -func compileInt(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpInt) - code.NumBitSize = intSize - ctx.incIndex() - return code, nil -} - -func compileIntPtr(ctx *compileContext) (*Opcode, error) { - code, err := compileInt(ctx) - if err != nil { - return nil, err - } - code.Op = OpIntPtr - return code, nil -} - -func compileInt8(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpInt) - code.NumBitSize = 8 - ctx.incIndex() - return code, nil -} - -func compileInt8Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileInt8(ctx) - if err != nil { - return nil, err - } - code.Op = OpIntPtr - return code, nil -} - -func compileInt16(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpInt) - code.NumBitSize = 16 - ctx.incIndex() - return code, nil -} - -func compileInt16Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileInt16(ctx) - if err != nil { - return nil, err - } - code.Op = OpIntPtr - return code, nil -} - -func compileInt32(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpInt) - code.NumBitSize = 32 - ctx.incIndex() - return code, nil -} - -func compileInt32Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileInt32(ctx) - if err != nil { - return nil, err - } - code.Op = OpIntPtr - return code, nil -} - -func compileInt64(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpInt) - code.NumBitSize = 64 - ctx.incIndex() - return code, nil -} - -func compileInt64Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileInt64(ctx) - if err != nil { - return nil, err - } - code.Op = OpIntPtr - return code, nil -} - -func compileUint(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUint) - code.NumBitSize = intSize - ctx.incIndex() - return code, nil -} - -func compileUintPtr(ctx *compileContext) (*Opcode, error) { - code, err := compileUint(ctx) - if err != nil { - return nil, err - } - code.Op = OpUintPtr - return code, nil -} - -func compileUint8(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUint) - code.NumBitSize = 8 - ctx.incIndex() - return code, nil -} - -func compileUint8Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileUint8(ctx) - if err != nil { - return nil, err - } - code.Op = OpUintPtr - return code, nil -} - -func compileUint16(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUint) - code.NumBitSize = 16 - ctx.incIndex() - return code, nil -} - -func compileUint16Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileUint16(ctx) - if err != nil { - return nil, err - } - code.Op = OpUintPtr - return code, nil -} - -func compileUint32(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUint) - code.NumBitSize = 32 - ctx.incIndex() - return code, nil -} - -func compileUint32Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileUint32(ctx) - if err != nil { - return nil, err - } - code.Op = OpUintPtr - return code, nil -} - -func compileUint64(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUint) - code.NumBitSize = 64 - ctx.incIndex() - return code, nil -} - -func compileUint64Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileUint64(ctx) - if err != nil { - return nil, err - } - code.Op = OpUintPtr - return code, nil -} - -func compileIntString(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpIntString) - code.NumBitSize = intSize - ctx.incIndex() - return code, nil -} - -func compileInt8String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpIntString) - code.NumBitSize = 8 - ctx.incIndex() - return code, nil -} - -func compileInt16String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpIntString) - code.NumBitSize = 16 - ctx.incIndex() - return code, nil -} - -func compileInt32String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpIntString) - code.NumBitSize = 32 - ctx.incIndex() - return code, nil -} - -func compileInt64String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpIntString) - code.NumBitSize = 64 - ctx.incIndex() - return code, nil -} - -func compileUintString(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUintString) - code.NumBitSize = intSize - ctx.incIndex() - return code, nil -} - -func compileUint8String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUintString) - code.NumBitSize = 8 - ctx.incIndex() - return code, nil -} - -func compileUint16String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUintString) - code.NumBitSize = 16 - ctx.incIndex() - return code, nil -} - -func compileUint32String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUintString) - code.NumBitSize = 32 - ctx.incIndex() - return code, nil -} - -func compileUint64String(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpUintString) - code.NumBitSize = 64 - ctx.incIndex() - return code, nil -} - -func compileFloat32(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpFloat32) - ctx.incIndex() - return code, nil -} - -func compileFloat32Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileFloat32(ctx) - if err != nil { - return nil, err - } - code.Op = OpFloat32Ptr - return code, nil -} - -func compileFloat64(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpFloat64) - ctx.incIndex() - return code, nil -} - -func compileFloat64Ptr(ctx *compileContext) (*Opcode, error) { - code, err := compileFloat64(ctx) - if err != nil { - return nil, err - } - code.Op = OpFloat64Ptr - return code, nil -} - -func compileString(ctx *compileContext) (*Opcode, error) { - var op OpType - if ctx.typ == runtime.Type2RType(jsonNumberType) { - op = OpNumber - } else { - op = OpString - } - code := newOpCode(ctx, op) - ctx.incIndex() - return code, nil -} - -func compileStringPtr(ctx *compileContext) (*Opcode, error) { - code, err := compileString(ctx) - if err != nil { - return nil, err - } - if code.Op == OpNumber { - code.Op = OpNumberPtr - } else { - code.Op = OpStringPtr - } - return code, nil -} - -func compileBool(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpBool) - ctx.incIndex() - return code, nil -} - -func compileBoolPtr(ctx *compileContext) (*Opcode, error) { - code, err := compileBool(ctx) - if err != nil { - return nil, err - } - code.Op = OpBoolPtr - return code, nil -} - -func compileBytes(ctx *compileContext) (*Opcode, error) { - code := newOpCode(ctx, OpBytes) - ctx.incIndex() - return code, nil -} - -func compileBytesPtr(ctx *compileContext) (*Opcode, error) { - code, err := compileBytes(ctx) - if err != nil { - return nil, err - } - code.Op = OpBytesPtr - return code, nil -} - -func compileInterface(ctx *compileContext) (*Opcode, error) { - code := newInterfaceCode(ctx) - ctx.incIndex() - return code, nil -} - -func compileInterfacePtr(ctx *compileContext) (*Opcode, error) { - code, err := compileInterface(ctx) - if err != nil { - return nil, err - } - code.Op = OpInterfacePtr - return code, nil -} - -func compileSlice(ctx *compileContext) (*Opcode, error) { - elem := ctx.typ.Elem() - size := elem.Size() - - header := newSliceHeaderCode(ctx) - ctx.incIndex() - - code, err := compileListElem(ctx.withType(elem).incIndent()) - if err != nil { - return nil, err - } - code.Flags |= IndirectFlags - - // header => opcode => elem => end - // ^ | - // |________| - - elemCode := newSliceElemCode(ctx, header, size) - ctx.incIndex() - - end := newOpCode(ctx, OpSliceEnd) - ctx.incIndex() - - header.End = end - header.Next = code - code.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(elemCode)) - elemCode.Next = code - elemCode.End = end - return (*Opcode)(unsafe.Pointer(header)), nil -} - -func compileListElem(ctx *compileContext) (*Opcode, error) { - typ := ctx.typ - switch { - case isPtrMarshalJSONType(typ): - return compileMarshalJSON(ctx) - case !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType): - return compileMarshalText(ctx) - case typ.Kind() == reflect.Map: - return compilePtr(ctx.withType(runtime.PtrTo(typ))) - default: - code, err := compile(ctx, false) - if err != nil { - return nil, err - } - if code.Op == OpMapPtr { - code.PtrNum++ - } - return code, nil - } -} - -func compileArray(ctx *compileContext) (*Opcode, error) { - typ := ctx.typ - elem := typ.Elem() - alen := typ.Len() - size := elem.Size() - - header := newArrayHeaderCode(ctx, alen) - ctx.incIndex() - - code, err := compileListElem(ctx.withType(elem).incIndent()) - if err != nil { - return nil, err - } - code.Flags |= IndirectFlags - // header => opcode => elem => end - // ^ | - // |________| - - elemCode := newArrayElemCode(ctx, header, alen, size) - ctx.incIndex() - - end := newOpCode(ctx, OpArrayEnd) - ctx.incIndex() - - header.End = end - header.Next = code - code.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(elemCode)) - elemCode.Next = code - elemCode.End = end - return (*Opcode)(unsafe.Pointer(header)), nil -} - -func compileMap(ctx *compileContext) (*Opcode, error) { - // header => code => value => code => key => code => value => code => end - // ^ | - // |_______________________| - ctx = ctx.incIndent() - header := newMapHeaderCode(ctx) - ctx.incIndex() - - typ := ctx.typ - keyType := ctx.typ.Key() - keyCode, err := compileKey(ctx.withType(keyType)) - if err != nil { - return nil, err - } - - value := newMapValueCode(ctx, header) - ctx.incIndex() - - valueCode, err := compileMapValue(ctx.withType(typ.Elem())) - if err != nil { - return nil, err - } - valueCode.Flags |= IndirectFlags - - key := newMapKeyCode(ctx, header) - ctx.incIndex() - - ctx = ctx.decIndent() - - end := newMapEndCode(ctx, header) - ctx.incIndex() - - header.Next = keyCode - keyCode.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(value)) - value.Next = valueCode - valueCode.BeforeLastCode().Next = (*Opcode)(unsafe.Pointer(key)) - key.Next = keyCode - - header.End = end - key.End = end - value.End = end - - return (*Opcode)(unsafe.Pointer(header)), nil -} - -func compileMapValue(ctx *compileContext) (*Opcode, error) { - switch ctx.typ.Kind() { - case reflect.Map: - return compilePtr(ctx.withType(runtime.PtrTo(ctx.typ))) - default: - code, err := compile(ctx, false) - if err != nil { - return nil, err - } - if code.Op == OpMapPtr { - code.PtrNum++ - } - return code, nil - } -} - -func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType { - headType := code.ToHeaderType(tag.IsString) - if tag.IsOmitEmpty { - headType = headType.HeadToOmitEmptyHead() - } - return headType -} - -func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType { - fieldType := code.ToFieldType(tag.IsString) - if tag.IsOmitEmpty { - fieldType = fieldType.FieldToOmitEmptyField() - } - return fieldType -} - -func recursiveCode(ctx *compileContext, jmp *CompiledCode) *Opcode { - code := newRecursiveCode(ctx, jmp) - ctx.incIndex() - return code -} - -func compiledCode(ctx *compileContext) *Opcode { - typ := ctx.typ - typeptr := uintptr(unsafe.Pointer(typ)) - if cc, exists := ctx.structTypeToCompiledCode[typeptr]; exists { - return recursiveCode(ctx, cc) - } - return nil -} - -func structHeader(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode { - op := optimizeStructHeader(valueCode, tag) - fieldCode.Op = op - fieldCode.NumBitSize = valueCode.NumBitSize - fieldCode.PtrNum = valueCode.PtrNum - if op.IsMultipleOpHead() { - return valueCode.BeforeLastCode() - } - ctx.decOpcodeIndex() - return fieldCode -} - -func structField(ctx *compileContext, fieldCode *Opcode, valueCode *Opcode, tag *runtime.StructTag) *Opcode { - op := optimizeStructField(valueCode, tag) - fieldCode.Op = op - fieldCode.NumBitSize = valueCode.NumBitSize - fieldCode.PtrNum = valueCode.PtrNum - if op.IsMultipleOpField() { - return valueCode.BeforeLastCode() - } - ctx.decIndex() - return fieldCode -} - -func isNotExistsField(head *Opcode) bool { - if head == nil { - return false - } - if head.Op != OpStructHead { - return false - } - if (head.Flags & AnonymousHeadFlags) == 0 { - return false - } - if head.Next == nil { - return false - } - if head.NextField == nil { - return false - } - if head.NextField.Op != OpStructAnonymousEnd { - return false - } - if head.Next.Op == OpStructAnonymousEnd { - return true - } - if head.Next.Op.CodeType() != CodeStructField { - return false - } - return isNotExistsField(head.Next) -} - -func optimizeAnonymousFields(head *Opcode) { - code := head - var prev *Opcode - removedFields := map[*Opcode]struct{}{} - for { - if code.Op == OpStructEnd { - break - } - if code.Op == OpStructField { - codeType := code.Next.Op.CodeType() - if codeType == CodeStructField { - if isNotExistsField(code.Next) { - code.Next = code.NextField - diff := code.Next.DisplayIdx - code.DisplayIdx - for i := uint32(0); i < diff; i++ { - code.Next.decOpcodeIndex() - } - linkPrevToNextField(code, removedFields) - code = prev - } - } - } - prev = code - code = code.NextField - } -} - -type structFieldPair struct { - prevField *Opcode - curField *Opcode - isTaggedKey bool - linked bool -} - -func anonymousStructFieldPairMap(tags runtime.StructTags, named string, valueCode *Opcode) map[string][]structFieldPair { - anonymousFields := map[string][]structFieldPair{} - f := valueCode - var prevAnonymousField *Opcode - removedFields := map[*Opcode]struct{}{} - for { - existsKey := tags.ExistsKey(f.DisplayKey) - isHeadOp := strings.Contains(f.Op.String(), "Head") - if existsKey && f.Next != nil && strings.Contains(f.Next.Op.String(), "Recursive") { - // through - } else if isHeadOp && (f.Flags&AnonymousHeadFlags) == 0 { - if existsKey { - // TODO: need to remove this head - f.Op = OpStructHead - f.Flags |= AnonymousKeyFlags - f.Flags |= AnonymousHeadFlags - } else if named == "" { - f.Flags |= AnonymousHeadFlags - } - } else if named == "" && f.Op == OpStructEnd { - f.Op = OpStructAnonymousEnd - } else if existsKey { - diff := f.NextField.DisplayIdx - f.DisplayIdx - for i := uint32(0); i < diff; i++ { - f.NextField.decOpcodeIndex() - } - linkPrevToNextField(f, removedFields) - } - - if f.DisplayKey == "" { - if f.NextField == nil { - break - } - prevAnonymousField = f - f = f.NextField - continue - } - - key := fmt.Sprintf("%s.%s", named, f.DisplayKey) - anonymousFields[key] = append(anonymousFields[key], structFieldPair{ - prevField: prevAnonymousField, - curField: f, - isTaggedKey: (f.Flags & IsTaggedKeyFlags) != 0, - }) - if f.Next != nil && f.NextField != f.Next && f.Next.Op.CodeType() == CodeStructField { - for k, v := range anonymousFieldPairRecursively(named, f.Next) { - anonymousFields[k] = append(anonymousFields[k], v...) - } - } - if f.NextField == nil { - break - } - prevAnonymousField = f - f = f.NextField - } - return anonymousFields -} - -func anonymousFieldPairRecursively(named string, valueCode *Opcode) map[string][]structFieldPair { - anonymousFields := map[string][]structFieldPair{} - f := valueCode - var prevAnonymousField *Opcode - for { - if f.DisplayKey != "" && (f.Flags&AnonymousHeadFlags) != 0 { - key := fmt.Sprintf("%s.%s", named, f.DisplayKey) - anonymousFields[key] = append(anonymousFields[key], structFieldPair{ - prevField: prevAnonymousField, - curField: f, - isTaggedKey: (f.Flags & IsTaggedKeyFlags) != 0, - }) - if f.Next != nil && f.NextField != f.Next && f.Next.Op.CodeType() == CodeStructField { - for k, v := range anonymousFieldPairRecursively(named, f.Next) { - anonymousFields[k] = append(anonymousFields[k], v...) - } - } - } - if f.NextField == nil { - break - } - prevAnonymousField = f - f = f.NextField - } - return anonymousFields -} - -func optimizeConflictAnonymousFields(anonymousFields map[string][]structFieldPair) { - removedFields := map[*Opcode]struct{}{} - for _, fieldPairs := range anonymousFields { - if len(fieldPairs) == 1 { - continue - } - // conflict anonymous fields - taggedPairs := []structFieldPair{} - for _, fieldPair := range fieldPairs { - if fieldPair.isTaggedKey { - taggedPairs = append(taggedPairs, fieldPair) - } else { - if !fieldPair.linked { - if fieldPair.prevField == nil { - // head operation - fieldPair.curField.Op = OpStructHead - fieldPair.curField.Flags |= AnonymousHeadFlags - fieldPair.curField.Flags |= AnonymousKeyFlags - } else { - diff := fieldPair.curField.NextField.DisplayIdx - fieldPair.curField.DisplayIdx - for i := uint32(0); i < diff; i++ { - fieldPair.curField.NextField.decOpcodeIndex() - } - removedFields[fieldPair.curField] = struct{}{} - linkPrevToNextField(fieldPair.curField, removedFields) - } - fieldPair.linked = true - } - } - } - if len(taggedPairs) > 1 { - for _, fieldPair := range taggedPairs { - if !fieldPair.linked { - if fieldPair.prevField == nil { - // head operation - fieldPair.curField.Op = OpStructHead - fieldPair.curField.Flags |= AnonymousHeadFlags - fieldPair.curField.Flags |= AnonymousKeyFlags - } else { - diff := fieldPair.curField.NextField.DisplayIdx - fieldPair.curField.DisplayIdx - removedFields[fieldPair.curField] = struct{}{} - for i := uint32(0); i < diff; i++ { - fieldPair.curField.NextField.decOpcodeIndex() - } - linkPrevToNextField(fieldPair.curField, removedFields) - } - fieldPair.linked = true - } - } - } else { - for _, fieldPair := range taggedPairs { - fieldPair.curField.Flags &= ^IsTaggedKeyFlags - } - } - } -} - -func isNilableType(typ *runtime.Type) bool { - switch typ.Kind() { - case reflect.Ptr: - return true - case reflect.Map: - return true - case reflect.Func: - return true - default: - return false - } -} - -func compileStruct(ctx *compileContext, isPtr bool) (*Opcode, error) { - if code := compiledCode(ctx); code != nil { - return code, nil - } - typ := ctx.typ - typeptr := uintptr(unsafe.Pointer(typ)) - compiled := &CompiledCode{} - ctx.structTypeToCompiledCode[typeptr] = compiled - // header => code => structField => code => end - // ^ | - // |__________| - fieldNum := typ.NumField() - indirect := runtime.IfaceIndir(typ) - fieldIdx := 0 - disableIndirectConversion := false - var ( - head *Opcode - code *Opcode - prevField *Opcode - ) - ctx = ctx.incIndent() - tags := runtime.StructTags{} - anonymousFields := map[string][]structFieldPair{} - for i := 0; i < fieldNum; i++ { - field := typ.Field(i) - if runtime.IsIgnoredStructField(field) { - continue - } - tags = append(tags, runtime.StructTagFromField(field)) - } - for i, tag := range tags { - field := tag.Field - fieldType := runtime.Type2RType(field.Type) - fieldOpcodeIndex := ctx.opcodeIndex - fieldPtrIndex := ctx.ptrIndex - ctx.incIndex() - - nilcheck := true - addrForMarshaler := false - isIndirectSpecialCase := isPtr && i == 0 && fieldNum == 1 - isNilableType := isNilableType(fieldType) - - var valueCode *Opcode - switch { - case isIndirectSpecialCase && !isNilableType && isPtrMarshalJSONType(fieldType): - // *struct{ field T } => struct { field *T } - // func (*T) MarshalJSON() ([]byte, error) - // move pointer position from head to first field - code, err := compileMarshalJSON(ctx.withType(fieldType)) - if err != nil { - return nil, err - } - addrForMarshaler = true - valueCode = code - nilcheck = false - indirect = false - disableIndirectConversion = true - case isIndirectSpecialCase && !isNilableType && isPtrMarshalTextType(fieldType): - // *struct{ field T } => struct { field *T } - // func (*T) MarshalText() ([]byte, error) - // move pointer position from head to first field - code, err := compileMarshalText(ctx.withType(fieldType)) - if err != nil { - return nil, err - } - addrForMarshaler = true - valueCode = code - nilcheck = false - indirect = false - disableIndirectConversion = true - case isPtr && isPtrMarshalJSONType(fieldType): - // *struct{ field T } - // func (*T) MarshalJSON() ([]byte, error) - code, err := compileMarshalJSON(ctx.withType(fieldType)) - if err != nil { - return nil, err - } - addrForMarshaler = true - nilcheck = false - valueCode = code - case isPtr && isPtrMarshalTextType(fieldType): - // *struct{ field T } - // func (*T) MarshalText() ([]byte, error) - code, err := compileMarshalText(ctx.withType(fieldType)) - if err != nil { - return nil, err - } - addrForMarshaler = true - nilcheck = false - valueCode = code - default: - code, err := compile(ctx.withType(fieldType), isPtr) - if err != nil { - return nil, err - } - valueCode = code - } - - if field.Anonymous && !tag.IsTaggedKey { - tagKey := "" - if tag.IsTaggedKey { - tagKey = tag.Key - } - for k, v := range anonymousStructFieldPairMap(tags, tagKey, valueCode) { - anonymousFields[k] = append(anonymousFields[k], v...) - } - - valueCode.decIndent() - - // fix issue144 - if !(isPtr && strings.Contains(valueCode.Op.String(), "Marshal")) { - if indirect { - valueCode.Flags |= IndirectFlags - } else { - valueCode.Flags &= ^IndirectFlags - } - } - } else { - if indirect { - // if parent is indirect type, set child indirect property to true - valueCode.Flags |= IndirectFlags - } else { - // if parent is not indirect type, set child indirect property to false. - // but if parent's indirect is false and isPtr is true, then indirect must be true. - // Do this only if indirectConversion is enabled at the end of compileStruct. - if i == 0 { - valueCode.Flags &= ^IndirectFlags - } - } - } - var flags OpFlags - if indirect { - flags |= IndirectFlags - } - if field.Anonymous { - flags |= AnonymousKeyFlags - } - if tag.IsTaggedKey { - flags |= IsTaggedKeyFlags - } - if nilcheck { - flags |= NilCheckFlags - } - if addrForMarshaler { - flags |= AddrForMarshalerFlags - } - if strings.Contains(valueCode.Op.String(), "Ptr") || valueCode.Op == OpInterface { - flags |= IsNextOpPtrTypeFlags - } - if isNilableType { - flags |= IsNilableTypeFlags - } - var key string - if ctx.escapeKey { - rctx := &RuntimeContext{Option: &Option{Flag: HTMLEscapeOption}} - key = fmt.Sprintf(`%s:`, string(AppendString(rctx, []byte{}, tag.Key))) - } else { - key = fmt.Sprintf(`"%s":`, tag.Key) - } - fieldCode := &Opcode{ - Idx: opcodeOffset(fieldPtrIndex), - Next: valueCode, - Flags: flags, - Key: key, - Offset: uint32(field.Offset), - Type: valueCode.Type, - DisplayIdx: fieldOpcodeIndex, - Indent: ctx.indent, - DisplayKey: tag.Key, - } - if fieldIdx == 0 { - code = structHeader(ctx, fieldCode, valueCode, tag) - head = fieldCode - prevField = fieldCode - } else { - fieldCode.Idx = head.Idx - code.Next = fieldCode - code = structField(ctx, fieldCode, valueCode, tag) - prevField.NextField = fieldCode - fieldCode.PrevField = prevField - prevField = fieldCode - } - fieldIdx++ - } - - structEndCode := &Opcode{ - Op: OpStructEnd, - Type: nil, - Indent: ctx.indent, - } - - ctx = ctx.decIndent() - - // no struct field - if head == nil { - head = &Opcode{ - Op: OpStructHead, - Idx: opcodeOffset(ctx.ptrIndex), - NextField: structEndCode, - Type: typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } - structEndCode.PrevField = head - ctx.incIndex() - code = head - } - - structEndCode.DisplayIdx = ctx.opcodeIndex - structEndCode.Idx = opcodeOffset(ctx.ptrIndex) - ctx.incIndex() - structEndCode.Next = newEndOp(ctx) - - if prevField != nil && prevField.NextField == nil { - prevField.NextField = structEndCode - structEndCode.PrevField = prevField - } - - head.End = structEndCode - code.Next = structEndCode - optimizeConflictAnonymousFields(anonymousFields) - optimizeAnonymousFields(head) - ret := (*Opcode)(unsafe.Pointer(head)) - compiled.Code = ret - - delete(ctx.structTypeToCompiledCode, typeptr) - - if !disableIndirectConversion && (head.Flags&IndirectFlags == 0) && isPtr { - headCode := head - for strings.Contains(headCode.Op.String(), "Head") { - headCode.Flags |= IndirectFlags - headCode = headCode.Next - } - } - - return ret, nil -} - -func implementsMarshalJSONType(typ *runtime.Type) bool { - return typ.Implements(marshalJSONType) || typ.Implements(marshalJSONContextType) -} - -func isPtrMarshalJSONType(typ *runtime.Type) bool { - return !implementsMarshalJSONType(typ) && implementsMarshalJSONType(runtime.PtrTo(typ)) -} - -func isPtrMarshalTextType(typ *runtime.Type) bool { - return !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go deleted file mode 100644 index 9d337f12b..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_norace.go +++ /dev/null @@ -1,56 +0,0 @@ -// +build !race - -package encoder - -import ( - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) { - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetCodeSetSlowPath(typeptr) - } - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - if codeSet := cachedOpcodeSets[index]; codeSet != nil { - return codeSet, nil - } - - // noescape trick for header.typ ( reflect.*rtype ) - copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr)) - - noescapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - }) - if err != nil { - return nil, err - } - escapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - escapeKey: true, - }) - if err != nil { - return nil, err - } - noescapeKeyCode = copyOpcode(noescapeKeyCode) - escapeKeyCode = copyOpcode(escapeKeyCode) - setTotalLengthToInterfaceOp(noescapeKeyCode) - setTotalLengthToInterfaceOp(escapeKeyCode) - interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode) - interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode) - codeLength := noescapeKeyCode.TotalLength() - codeSet := &OpcodeSet{ - Type: copiedType, - NoescapeKeyCode: noescapeKeyCode, - EscapeKeyCode: escapeKeyCode, - InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode, - InterfaceEscapeKeyCode: interfaceEscapeKeyCode, - CodeLength: codeLength, - EndCode: ToEndCode(interfaceNoescapeKeyCode), - } - cachedOpcodeSets[index] = codeSet - return codeSet, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go b/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go deleted file mode 100644 index 3a239e9d9..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/compiler_race.go +++ /dev/null @@ -1,65 +0,0 @@ -// +build race - -package encoder - -import ( - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -var setsMu sync.RWMutex - -func CompileToGetCodeSet(typeptr uintptr) (*OpcodeSet, error) { - if typeptr > typeAddr.MaxTypeAddr { - return compileToGetCodeSetSlowPath(typeptr) - } - index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift - setsMu.RLock() - if codeSet := cachedOpcodeSets[index]; codeSet != nil { - setsMu.RUnlock() - return codeSet, nil - } - setsMu.RUnlock() - - // noescape trick for header.typ ( reflect.*rtype ) - copiedType := *(**runtime.Type)(unsafe.Pointer(&typeptr)) - - noescapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - }) - if err != nil { - return nil, err - } - escapeKeyCode, err := compileHead(&compileContext{ - typ: copiedType, - structTypeToCompiledCode: map[uintptr]*CompiledCode{}, - escapeKey: true, - }) - if err != nil { - return nil, err - } - - noescapeKeyCode = copyOpcode(noescapeKeyCode) - escapeKeyCode = copyOpcode(escapeKeyCode) - setTotalLengthToInterfaceOp(noescapeKeyCode) - setTotalLengthToInterfaceOp(escapeKeyCode) - interfaceNoescapeKeyCode := copyToInterfaceOpcode(noescapeKeyCode) - interfaceEscapeKeyCode := copyToInterfaceOpcode(escapeKeyCode) - codeLength := noescapeKeyCode.TotalLength() - codeSet := &OpcodeSet{ - Type: copiedType, - NoescapeKeyCode: noescapeKeyCode, - EscapeKeyCode: escapeKeyCode, - InterfaceNoescapeKeyCode: interfaceNoescapeKeyCode, - InterfaceEscapeKeyCode: interfaceEscapeKeyCode, - CodeLength: codeLength, - EndCode: ToEndCode(interfaceNoescapeKeyCode), - } - setsMu.Lock() - cachedOpcodeSets[index] = codeSet - setsMu.Unlock() - return codeSet, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/context.go b/vendor/github.com/goccy/go-json/internal/encoder/context.go deleted file mode 100644 index 61b890806..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/context.go +++ /dev/null @@ -1,141 +0,0 @@ -package encoder - -import ( - "context" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -type compileContext struct { - typ *runtime.Type - opcodeIndex uint32 - ptrIndex int - indent uint32 - escapeKey bool - structTypeToCompiledCode map[uintptr]*CompiledCode - - parent *compileContext -} - -func (c *compileContext) context() *compileContext { - return &compileContext{ - typ: c.typ, - opcodeIndex: c.opcodeIndex, - ptrIndex: c.ptrIndex, - indent: c.indent, - escapeKey: c.escapeKey, - structTypeToCompiledCode: c.structTypeToCompiledCode, - parent: c, - } -} - -func (c *compileContext) withType(typ *runtime.Type) *compileContext { - ctx := c.context() - ctx.typ = typ - return ctx -} - -func (c *compileContext) incIndent() *compileContext { - ctx := c.context() - ctx.indent++ - return ctx -} - -func (c *compileContext) decIndent() *compileContext { - ctx := c.context() - ctx.indent-- - return ctx -} - -func (c *compileContext) incIndex() { - c.incOpcodeIndex() - c.incPtrIndex() -} - -func (c *compileContext) decIndex() { - c.decOpcodeIndex() - c.decPtrIndex() -} - -func (c *compileContext) incOpcodeIndex() { - c.opcodeIndex++ - if c.parent != nil { - c.parent.incOpcodeIndex() - } -} - -func (c *compileContext) decOpcodeIndex() { - c.opcodeIndex-- - if c.parent != nil { - c.parent.decOpcodeIndex() - } -} - -func (c *compileContext) incPtrIndex() { - c.ptrIndex++ - if c.parent != nil { - c.parent.incPtrIndex() - } -} - -func (c *compileContext) decPtrIndex() { - c.ptrIndex-- - if c.parent != nil { - c.parent.decPtrIndex() - } -} - -const ( - bufSize = 1024 -) - -var ( - runtimeContextPool = sync.Pool{ - New: func() interface{} { - return &RuntimeContext{ - Buf: make([]byte, 0, bufSize), - Ptrs: make([]uintptr, 128), - KeepRefs: make([]unsafe.Pointer, 0, 8), - Option: &Option{}, - } - }, - } -) - -type RuntimeContext struct { - Context context.Context - Buf []byte - MarshalBuf []byte - Ptrs []uintptr - KeepRefs []unsafe.Pointer - SeenPtr []uintptr - BaseIndent uint32 - Prefix []byte - IndentStr []byte - Option *Option -} - -func (c *RuntimeContext) Init(p uintptr, codelen int) { - if len(c.Ptrs) < codelen { - c.Ptrs = make([]uintptr, codelen) - } - c.Ptrs[0] = p - c.KeepRefs = c.KeepRefs[:0] - c.SeenPtr = c.SeenPtr[:0] - c.BaseIndent = 0 -} - -func (c *RuntimeContext) Ptr() uintptr { - header := (*runtime.SliceHeader)(unsafe.Pointer(&c.Ptrs)) - return uintptr(header.Data) -} - -func TakeRuntimeContext() *RuntimeContext { - return runtimeContextPool.Get().(*RuntimeContext) -} - -func ReleaseRuntimeContext(ctx *RuntimeContext) { - runtimeContextPool.Put(ctx) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/encoder.go b/vendor/github.com/goccy/go-json/internal/encoder/encoder.go deleted file mode 100644 index b7fa99a96..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/encoder.go +++ /dev/null @@ -1,551 +0,0 @@ -package encoder - -import ( - "bytes" - "encoding" - "encoding/base64" - "encoding/json" - "fmt" - "math" - "reflect" - "strconv" - "strings" - "sync" - "unsafe" - - "github.com/goccy/go-json/internal/errors" - "github.com/goccy/go-json/internal/runtime" -) - -func (t OpType) IsMultipleOpHead() bool { - switch t { - case OpStructHead: - return true - case OpStructHeadSlice: - return true - case OpStructHeadArray: - return true - case OpStructHeadMap: - return true - case OpStructHeadStruct: - return true - case OpStructHeadOmitEmpty: - return true - case OpStructHeadOmitEmptySlice: - return true - case OpStructHeadOmitEmptyArray: - return true - case OpStructHeadOmitEmptyMap: - return true - case OpStructHeadOmitEmptyStruct: - return true - case OpStructHeadSlicePtr: - return true - case OpStructHeadOmitEmptySlicePtr: - return true - case OpStructHeadArrayPtr: - return true - case OpStructHeadOmitEmptyArrayPtr: - return true - case OpStructHeadMapPtr: - return true - case OpStructHeadOmitEmptyMapPtr: - return true - } - return false -} - -func (t OpType) IsMultipleOpField() bool { - switch t { - case OpStructField: - return true - case OpStructFieldSlice: - return true - case OpStructFieldArray: - return true - case OpStructFieldMap: - return true - case OpStructFieldStruct: - return true - case OpStructFieldOmitEmpty: - return true - case OpStructFieldOmitEmptySlice: - return true - case OpStructFieldOmitEmptyArray: - return true - case OpStructFieldOmitEmptyMap: - return true - case OpStructFieldOmitEmptyStruct: - return true - case OpStructFieldSlicePtr: - return true - case OpStructFieldOmitEmptySlicePtr: - return true - case OpStructFieldArrayPtr: - return true - case OpStructFieldOmitEmptyArrayPtr: - return true - case OpStructFieldMapPtr: - return true - case OpStructFieldOmitEmptyMapPtr: - return true - } - return false -} - -type OpcodeSet struct { - Type *runtime.Type - NoescapeKeyCode *Opcode - EscapeKeyCode *Opcode - InterfaceNoescapeKeyCode *Opcode - InterfaceEscapeKeyCode *Opcode - CodeLength int - EndCode *Opcode -} - -type CompiledCode struct { - Code *Opcode - Linked bool // whether recursive code already have linked - CurLen uintptr - NextLen uintptr -} - -const StartDetectingCyclesAfter = 1000 - -func Load(base uintptr, idx uintptr) uintptr { - addr := base + idx - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func Store(base uintptr, idx uintptr, p uintptr) { - addr := base + idx - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func LoadNPtr(base uintptr, idx uintptr, ptrNum int) uintptr { - addr := base + idx - p := **(**uintptr)(unsafe.Pointer(&addr)) - if p == 0 { - return 0 - } - return PtrToPtr(p) - /* - for i := 0; i < ptrNum; i++ { - if p == 0 { - return p - } - p = PtrToPtr(p) - } - return p - */ -} - -func PtrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } -func PtrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } -func PtrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } -func PtrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } -func PtrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func PtrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func PtrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func PtrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func PtrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func PtrToNPtr(p uintptr, ptrNum int) uintptr { - for i := 0; i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = PtrToPtr(p) - } - return p -} - -func PtrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func PtrToInterface(code *Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func ErrUnsupportedValue(code *Opcode, ptr uintptr) *errors.UnsupportedValueError { - v := *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)), - })) - return &errors.UnsupportedValueError{ - Value: reflect.ValueOf(v), - Str: fmt.Sprintf("encountered a cycle via %s", code.Type), - } -} - -func ErrUnsupportedFloat(v float64) *errors.UnsupportedValueError { - return &errors.UnsupportedValueError{ - Value: reflect.ValueOf(v), - Str: strconv.FormatFloat(v, 'g', -1, 64), - } -} - -func ErrMarshalerWithCode(code *Opcode, err error) *errors.MarshalerError { - return &errors.MarshalerError{ - Type: runtime.RType2Type(code.Type), - Err: err, - } -} - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type MapItem struct { - Key []byte - Value []byte -} - -type Mapslice struct { - Items []MapItem -} - -func (m *Mapslice) Len() int { - return len(m.Items) -} - -func (m *Mapslice) Less(i, j int) bool { - return bytes.Compare(m.Items[i].Key, m.Items[j].Key) < 0 -} - -func (m *Mapslice) Swap(i, j int) { - m.Items[i], m.Items[j] = m.Items[j], m.Items[i] -} - -type MapContext struct { - Pos []int - Slice *Mapslice - Buf []byte -} - -var mapContextPool = sync.Pool{ - New: func() interface{} { - return &MapContext{} - }, -} - -func NewMapContext(mapLen int) *MapContext { - ctx := mapContextPool.Get().(*MapContext) - if ctx.Slice == nil { - ctx.Slice = &Mapslice{ - Items: make([]MapItem, 0, mapLen), - } - } - if cap(ctx.Pos) < (mapLen*2 + 1) { - ctx.Pos = make([]int, 0, mapLen*2+1) - ctx.Slice.Items = make([]MapItem, 0, mapLen) - } else { - ctx.Pos = ctx.Pos[:0] - ctx.Slice.Items = ctx.Slice.Items[:0] - } - ctx.Buf = ctx.Buf[:0] - return ctx -} - -func ReleaseMapContext(c *MapContext) { - mapContextPool.Put(c) -} - -//go:linkname MapIterInit reflect.mapiterinit -//go:noescape -func MapIterInit(mapType *runtime.Type, m unsafe.Pointer) unsafe.Pointer - -//go:linkname MapIterKey reflect.mapiterkey -//go:noescape -func MapIterKey(it unsafe.Pointer) unsafe.Pointer - -//go:linkname MapIterNext reflect.mapiternext -//go:noescape -func MapIterNext(it unsafe.Pointer) - -//go:linkname MapLen reflect.maplen -//go:noescape -func MapLen(m unsafe.Pointer) int - -func AppendByteSlice(_ *RuntimeContext, b []byte, src []byte) []byte { - if src == nil { - return append(b, `null`...) - } - encodedLen := base64.StdEncoding.EncodedLen(len(src)) - b = append(b, '"') - pos := len(b) - remainLen := cap(b[pos:]) - var buf []byte - if remainLen > encodedLen { - buf = b[pos : pos+encodedLen] - } else { - buf = make([]byte, encodedLen) - } - base64.StdEncoding.Encode(buf, src) - return append(append(b, buf...), '"') -} - -func AppendFloat32(_ *RuntimeContext, b []byte, v float32) []byte { - f64 := float64(v) - abs := math.Abs(f64) - fmt := byte('f') - // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. - if abs != 0 { - f32 := float32(abs) - if f32 < 1e-6 || f32 >= 1e21 { - fmt = 'e' - } - } - return strconv.AppendFloat(b, f64, fmt, -1, 32) -} - -func AppendFloat64(_ *RuntimeContext, b []byte, v float64) []byte { - abs := math.Abs(v) - fmt := byte('f') - // Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right. - if abs != 0 { - if abs < 1e-6 || abs >= 1e21 { - fmt = 'e' - } - } - return strconv.AppendFloat(b, v, fmt, -1, 64) -} - -func AppendBool(_ *RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -var ( - floatTable = [256]bool{ - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - '.': true, - 'e': true, - 'E': true, - '+': true, - '-': true, - } -) - -func AppendNumber(_ *RuntimeContext, b []byte, n json.Number) ([]byte, error) { - if len(n) == 0 { - return append(b, '0'), nil - } - for i := 0; i < len(n); i++ { - if !floatTable[n[i]] { - return nil, fmt.Errorf("json: invalid number literal %q", n) - } - } - b = append(b, n...) - return b, nil -} - -func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - var bb []byte - if (code.Flags & MarshalerContextFlags) != 0 { - marshaler, ok := v.(marshalerContext) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON(ctx.Option.Context) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } else { - marshaler, ok := v.(json.Marshaler) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } - marshalBuf := ctx.MarshalBuf[:0] - marshalBuf = append(append(marshalBuf, bb...), nul) - compactedBuf, err := compact(b, marshalBuf, (ctx.Option.Flag&HTMLEscapeOption) != 0) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - ctx.MarshalBuf = marshalBuf - return compactedBuf, nil -} - -func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - var bb []byte - if (code.Flags & MarshalerContextFlags) != 0 { - marshaler, ok := v.(marshalerContext) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON(ctx.Option.Context) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } else { - marshaler, ok := v.(json.Marshaler) - if !ok { - return AppendNull(ctx, b), nil - } - b, err := marshaler.MarshalJSON() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - bb = b - } - marshalBuf := ctx.MarshalBuf[:0] - marshalBuf = append(append(marshalBuf, bb...), nul) - indentedBuf, err := doIndent( - b, - marshalBuf, - string(ctx.Prefix)+strings.Repeat(string(ctx.IndentStr), int(ctx.BaseIndent+code.Indent)), - string(ctx.IndentStr), - (ctx.Option.Flag&HTMLEscapeOption) != 0, - ) - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - ctx.MarshalBuf = marshalBuf - return indentedBuf, nil -} - -func AppendMarshalText(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return AppendNull(ctx, b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return AppendString(ctx, b, *(*string)(unsafe.Pointer(&bytes))), nil -} - -func AppendMarshalTextIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error) { - rv := reflect.ValueOf(v) // convert by dynamic interface type - if (code.Flags & AddrForMarshalerFlags) != 0 { - if rv.CanAddr() { - rv = rv.Addr() - } else { - newV := reflect.New(rv.Type()) - newV.Elem().Set(rv) - rv = newV - } - } - v = rv.Interface() - marshaler, ok := v.(encoding.TextMarshaler) - if !ok { - return AppendNull(ctx, b), nil - } - bytes, err := marshaler.MarshalText() - if err != nil { - return nil, &errors.MarshalerError{Type: reflect.TypeOf(v), Err: err} - } - return AppendString(ctx, b, *(*string)(unsafe.Pointer(&bytes))), nil -} - -func AppendNull(_ *RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -func AppendComma(_ *RuntimeContext, b []byte) []byte { - return append(b, ',') -} - -func AppendCommaIndent(_ *RuntimeContext, b []byte) []byte { - return append(b, ',', '\n') -} - -func AppendStructEnd(_ *RuntimeContext, b []byte) []byte { - return append(b, '}', ',') -} - -func AppendStructEndIndent(ctx *RuntimeContext, code *Opcode, b []byte) []byte { - b = append(b, '\n') - b = append(b, ctx.Prefix...) - indentNum := ctx.BaseIndent + code.Indent - 1 - for i := uint32(0); i < indentNum; i++ { - b = append(b, ctx.IndentStr...) - } - return append(b, '}', ',', '\n') -} - -func AppendIndent(ctx *RuntimeContext, b []byte, indent uint32) []byte { - b = append(b, ctx.Prefix...) - indentNum := ctx.BaseIndent + indent - for i := uint32(0); i < indentNum; i++ { - b = append(b, ctx.IndentStr...) - } - return b -} - -func IsNilForMarshaler(v interface{}) bool { - rv := reflect.ValueOf(v) - switch rv.Kind() { - case reflect.Bool: - return !rv.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return rv.Uint() == 0 - case reflect.Float32, reflect.Float64: - return math.Float64bits(rv.Float()) == 0 - case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Func: - return rv.IsNil() - case reflect.Slice: - return rv.IsNil() || rv.Len() == 0 - } - return false -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/indent.go b/vendor/github.com/goccy/go-json/internal/encoder/indent.go deleted file mode 100644 index dfe04b5e3..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/indent.go +++ /dev/null @@ -1,211 +0,0 @@ -package encoder - -import ( - "bytes" - "fmt" - - "github.com/goccy/go-json/internal/errors" -) - -func takeIndentSrcRuntimeContext(src []byte) (*RuntimeContext, []byte) { - ctx := TakeRuntimeContext() - buf := ctx.Buf[:0] - buf = append(append(buf, src...), nul) - ctx.Buf = buf - return ctx, buf -} - -func Indent(buf *bytes.Buffer, src []byte, prefix, indentStr string) error { - if len(src) == 0 { - return errors.ErrUnexpectedEndOfJSON("", 0) - } - - srcCtx, srcBuf := takeIndentSrcRuntimeContext(src) - dstCtx := TakeRuntimeContext() - dst := dstCtx.Buf[:0] - - dst, err := indentAndWrite(buf, dst, srcBuf, prefix, indentStr) - if err != nil { - ReleaseRuntimeContext(srcCtx) - ReleaseRuntimeContext(dstCtx) - return err - } - dstCtx.Buf = dst - ReleaseRuntimeContext(srcCtx) - ReleaseRuntimeContext(dstCtx) - return nil -} - -func indentAndWrite(buf *bytes.Buffer, dst []byte, src []byte, prefix, indentStr string) ([]byte, error) { - dst, err := doIndent(dst, src, prefix, indentStr, false) - if err != nil { - return nil, err - } - if _, err := buf.Write(dst); err != nil { - return nil, err - } - return dst, nil -} - -func doIndent(dst, src []byte, prefix, indentStr string, escape bool) ([]byte, error) { - buf, cursor, err := indentValue(dst, src, 0, 0, []byte(prefix), []byte(indentStr), escape) - if err != nil { - return nil, err - } - if err := validateEndBuf(src, cursor); err != nil { - return nil, err - } - return buf, nil -} - -func indentValue( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - for { - switch src[cursor] { - case ' ', '\t', '\n', '\r': - cursor++ - continue - case '{': - return indentObject(dst, src, indentNum, cursor, prefix, indentBytes, escape) - case '}': - return nil, 0, errors.ErrSyntax("unexpected character '}'", cursor) - case '[': - return indentArray(dst, src, indentNum, cursor, prefix, indentBytes, escape) - case ']': - return nil, 0, errors.ErrSyntax("unexpected character ']'", cursor) - case '"': - return compactString(dst, src, cursor, escape) - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - return compactNumber(dst, src, cursor) - case 't': - return compactTrue(dst, src, cursor) - case 'f': - return compactFalse(dst, src, cursor) - case 'n': - return compactNull(dst, src, cursor) - default: - return nil, 0, errors.ErrSyntax(fmt.Sprintf("unexpected character '%c'", src[cursor]), cursor) - } - } -} - -func indentObject( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - if src[cursor] == '{' { - dst = append(dst, '{') - } else { - return nil, 0, errors.ErrExpected("expected { character for object value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == '}' { - dst = append(dst, '}') - return dst, cursor + 1, nil - } - indentNum++ - var err error - for { - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum; i++ { - dst = append(dst, indentBytes...) - } - cursor = skipWhiteSpace(src, cursor) - dst, cursor, err = compactString(dst, src, cursor, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - if src[cursor] != ':' { - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after object key", src[cursor]), - cursor+1, - ) - } - dst = append(dst, ':', ' ') - dst, cursor, err = indentValue(dst, src, indentNum, cursor+1, prefix, indentBytes, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case '}': - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum-1; i++ { - dst = append(dst, indentBytes...) - } - dst = append(dst, '}') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after object key:value pair", src[cursor]), - cursor+1, - ) - } - cursor++ - } -} - -func indentArray( - dst []byte, - src []byte, - indentNum int, - cursor int64, - prefix []byte, - indentBytes []byte, - escape bool) ([]byte, int64, error) { - if src[cursor] == '[' { - dst = append(dst, '[') - } else { - return nil, 0, errors.ErrExpected("expected [ character for array value", cursor) - } - cursor = skipWhiteSpace(src, cursor+1) - if src[cursor] == ']' { - dst = append(dst, ']') - return dst, cursor + 1, nil - } - indentNum++ - var err error - for { - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum; i++ { - dst = append(dst, indentBytes...) - } - dst, cursor, err = indentValue(dst, src, indentNum, cursor, prefix, indentBytes, escape) - if err != nil { - return nil, 0, err - } - cursor = skipWhiteSpace(src, cursor) - switch src[cursor] { - case ']': - dst = append(append(dst, '\n'), prefix...) - for i := 0; i < indentNum-1; i++ { - dst = append(dst, indentBytes...) - } - dst = append(dst, ']') - cursor++ - return dst, cursor, nil - case ',': - dst = append(dst, ',') - default: - return nil, 0, errors.ErrSyntax( - fmt.Sprintf("invalid character '%c' after array value", src[cursor]), - cursor+1, - ) - } - cursor++ - } -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/int.go b/vendor/github.com/goccy/go-json/internal/encoder/int.go deleted file mode 100644 index 3a3482d5b..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/int.go +++ /dev/null @@ -1,130 +0,0 @@ -package encoder - -import ( - "unsafe" -) - -var endianness int - -func init() { - var b [2]byte - *(*uint16)(unsafe.Pointer(&b)) = uint16(0xABCD) - - switch b[0] { - case 0xCD: - endianness = 0 // LE - case 0xAB: - endianness = 1 // BE - default: - panic("could not determine endianness") - } -} - -// "00010203...96979899" cast to []uint16 -var intLELookup = [100]uint16{ - 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930, - 0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, 0x3831, 0x3931, - 0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732, 0x3832, 0x3932, - 0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733, 0x3833, 0x3933, - 0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734, 0x3834, 0x3934, - 0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935, - 0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936, - 0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937, - 0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938, - 0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, 0x3939, -} - -var intBELookup = [100]uint16{ - 0x3030, 0x3031, 0x3032, 0x3033, 0x3034, 0x3035, 0x3036, 0x3037, 0x3038, 0x3039, - 0x3130, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, 0x3139, - 0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3236, 0x3237, 0x3238, 0x3239, - 0x3330, 0x3331, 0x3332, 0x3333, 0x3334, 0x3335, 0x3336, 0x3337, 0x3338, 0x3339, - 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, 0x3439, - 0x3530, 0x3531, 0x3532, 0x3533, 0x3534, 0x3535, 0x3536, 0x3537, 0x3538, 0x3539, - 0x3630, 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, - 0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, - 0x3830, 0x3831, 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839, - 0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, 0x3937, 0x3938, 0x3939, -} - -var intLookup = [2]*[100]uint16{&intLELookup, &intBELookup} - -func numMask(numBitSize uint8) uint64 { - return 1<>(code.NumBitSize-1))&1 == 1 - if !negative { - if n < 10 { - return append(out, byte(n+'0')) - } else if n < 100 { - u := intLELookup[n] - return append(out, byte(u), byte(u>>8)) - } - } else { - n = -n & mask - } - - lookup := intLookup[endianness] - - var b [22]byte - u := (*[11]uint16)(unsafe.Pointer(&b)) - i := 11 - - for n >= 100 { - j := n % 100 - n /= 100 - i-- - u[i] = lookup[j] - } - - i-- - u[i] = lookup[n] - - i *= 2 // convert to byte index - if n < 10 { - i++ // remove leading zero - } - if negative { - i-- - b[i] = '-' - } - - return append(out, b[i:]...) -} - -func AppendUint(_ *RuntimeContext, out []byte, u64 uint64, code *Opcode) []byte { - mask := numMask(code.NumBitSize) - n := u64 & mask - if n < 10 { - return append(out, byte(n+'0')) - } else if n < 100 { - u := intLELookup[n] - return append(out, byte(u), byte(u>>8)) - } - - lookup := intLookup[endianness] - - var b [22]byte - u := (*[11]uint16)(unsafe.Pointer(&b)) - i := 11 - - for n >= 100 { - j := n % 100 - n /= 100 - i-- - u[i] = lookup[j] - } - - i-- - u[i] = lookup[n] - - i *= 2 // convert to byte index - if n < 10 { - i++ // remove leading zero - } - return append(out, b[i:]...) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/map112.go b/vendor/github.com/goccy/go-json/internal/encoder/map112.go deleted file mode 100644 index 31858d000..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/map112.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !go1.13 - -package encoder - -import "unsafe" - -//go:linkname MapIterValue reflect.mapitervalue -func MapIterValue(it unsafe.Pointer) unsafe.Pointer diff --git a/vendor/github.com/goccy/go-json/internal/encoder/map113.go b/vendor/github.com/goccy/go-json/internal/encoder/map113.go deleted file mode 100644 index f49c27bed..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/map113.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build go1.13 - -package encoder - -import "unsafe" - -//go:linkname MapIterValue reflect.mapiterelem -func MapIterValue(it unsafe.Pointer) unsafe.Pointer diff --git a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go b/vendor/github.com/goccy/go-json/internal/encoder/opcode.go deleted file mode 100644 index 7c50eefae..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/opcode.go +++ /dev/null @@ -1,772 +0,0 @@ -package encoder - -import ( - "fmt" - "strings" - "unsafe" - - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -type OpFlags uint16 - -const ( - AnonymousHeadFlags OpFlags = 1 << 0 - AnonymousKeyFlags OpFlags = 1 << 1 - IndirectFlags OpFlags = 1 << 2 - IsTaggedKeyFlags OpFlags = 1 << 3 - NilCheckFlags OpFlags = 1 << 4 - AddrForMarshalerFlags OpFlags = 1 << 5 - IsNextOpPtrTypeFlags OpFlags = 1 << 6 - IsNilableTypeFlags OpFlags = 1 << 7 - MarshalerContextFlags OpFlags = 1 << 8 - NonEmptyInterfaceFlags OpFlags = 1 << 9 -) - -type Opcode struct { - Op OpType // operation type - Idx uint32 // offset to access ptr - Next *Opcode // next opcode - End *Opcode // array/slice/struct/map end - NextField *Opcode // next struct field - Key string // struct field key - Offset uint32 // offset size from struct header - PtrNum uint8 // pointer number: e.g. double pointer is 2. - NumBitSize uint8 - Flags OpFlags - - Type *runtime.Type // go type - PrevField *Opcode // prev struct field - Jmp *CompiledCode // for recursive call - ElemIdx uint32 // offset to access array/slice/map elem - Length uint32 // offset to access slice/map length or array length - MapIter uint32 // offset to access map iterator - MapPos uint32 // offset to access position list for sorted map - Indent uint32 // indent number - Size uint32 // array/slice elem size - DisplayIdx uint32 // opcode index - DisplayKey string // key text to display -} - -func (c *Opcode) MaxIdx() uint32 { - max := uint32(0) - for _, value := range []uint32{ - c.Idx, - c.ElemIdx, - c.Length, - c.MapIter, - c.MapPos, - c.Size, - } { - if max < value { - max = value - } - } - return max -} - -func (c *Opcode) ToHeaderType(isString bool) OpType { - switch c.Op { - case OpInt: - if isString { - return OpStructHeadIntString - } - return OpStructHeadInt - case OpIntPtr: - if isString { - return OpStructHeadIntPtrString - } - return OpStructHeadIntPtr - case OpUint: - if isString { - return OpStructHeadUintString - } - return OpStructHeadUint - case OpUintPtr: - if isString { - return OpStructHeadUintPtrString - } - return OpStructHeadUintPtr - case OpFloat32: - if isString { - return OpStructHeadFloat32String - } - return OpStructHeadFloat32 - case OpFloat32Ptr: - if isString { - return OpStructHeadFloat32PtrString - } - return OpStructHeadFloat32Ptr - case OpFloat64: - if isString { - return OpStructHeadFloat64String - } - return OpStructHeadFloat64 - case OpFloat64Ptr: - if isString { - return OpStructHeadFloat64PtrString - } - return OpStructHeadFloat64Ptr - case OpString: - if isString { - return OpStructHeadStringString - } - return OpStructHeadString - case OpStringPtr: - if isString { - return OpStructHeadStringPtrString - } - return OpStructHeadStringPtr - case OpNumber: - if isString { - return OpStructHeadNumberString - } - return OpStructHeadNumber - case OpNumberPtr: - if isString { - return OpStructHeadNumberPtrString - } - return OpStructHeadNumberPtr - case OpBool: - if isString { - return OpStructHeadBoolString - } - return OpStructHeadBool - case OpBoolPtr: - if isString { - return OpStructHeadBoolPtrString - } - return OpStructHeadBoolPtr - case OpBytes: - return OpStructHeadBytes - case OpBytesPtr: - return OpStructHeadBytesPtr - case OpMap: - return OpStructHeadMap - case OpMapPtr: - c.Op = OpMap - return OpStructHeadMapPtr - case OpArray: - return OpStructHeadArray - case OpArrayPtr: - c.Op = OpArray - return OpStructHeadArrayPtr - case OpSlice: - return OpStructHeadSlice - case OpSlicePtr: - c.Op = OpSlice - return OpStructHeadSlicePtr - case OpMarshalJSON: - return OpStructHeadMarshalJSON - case OpMarshalJSONPtr: - return OpStructHeadMarshalJSONPtr - case OpMarshalText: - return OpStructHeadMarshalText - case OpMarshalTextPtr: - return OpStructHeadMarshalTextPtr - } - return OpStructHead -} - -func (c *Opcode) ToFieldType(isString bool) OpType { - switch c.Op { - case OpInt: - if isString { - return OpStructFieldIntString - } - return OpStructFieldInt - case OpIntPtr: - if isString { - return OpStructFieldIntPtrString - } - return OpStructFieldIntPtr - case OpUint: - if isString { - return OpStructFieldUintString - } - return OpStructFieldUint - case OpUintPtr: - if isString { - return OpStructFieldUintPtrString - } - return OpStructFieldUintPtr - case OpFloat32: - if isString { - return OpStructFieldFloat32String - } - return OpStructFieldFloat32 - case OpFloat32Ptr: - if isString { - return OpStructFieldFloat32PtrString - } - return OpStructFieldFloat32Ptr - case OpFloat64: - if isString { - return OpStructFieldFloat64String - } - return OpStructFieldFloat64 - case OpFloat64Ptr: - if isString { - return OpStructFieldFloat64PtrString - } - return OpStructFieldFloat64Ptr - case OpString: - if isString { - return OpStructFieldStringString - } - return OpStructFieldString - case OpStringPtr: - if isString { - return OpStructFieldStringPtrString - } - return OpStructFieldStringPtr - case OpNumber: - if isString { - return OpStructFieldNumberString - } - return OpStructFieldNumber - case OpNumberPtr: - if isString { - return OpStructFieldNumberPtrString - } - return OpStructFieldNumberPtr - case OpBool: - if isString { - return OpStructFieldBoolString - } - return OpStructFieldBool - case OpBoolPtr: - if isString { - return OpStructFieldBoolPtrString - } - return OpStructFieldBoolPtr - case OpBytes: - return OpStructFieldBytes - case OpBytesPtr: - return OpStructFieldBytesPtr - case OpMap: - return OpStructFieldMap - case OpMapPtr: - c.Op = OpMap - return OpStructFieldMapPtr - case OpArray: - return OpStructFieldArray - case OpArrayPtr: - c.Op = OpArray - return OpStructFieldArrayPtr - case OpSlice: - return OpStructFieldSlice - case OpSlicePtr: - c.Op = OpSlice - return OpStructFieldSlicePtr - case OpMarshalJSON: - return OpStructFieldMarshalJSON - case OpMarshalJSONPtr: - return OpStructFieldMarshalJSONPtr - case OpMarshalText: - return OpStructFieldMarshalText - case OpMarshalTextPtr: - return OpStructFieldMarshalTextPtr - } - return OpStructField -} - -func newOpCode(ctx *compileContext, op OpType) *Opcode { - return newOpCodeWithNext(ctx, op, newEndOp(ctx)) -} - -func opcodeOffset(idx int) uint32 { - return uint32(idx) * uintptrSize -} - -func copyOpcode(code *Opcode) *Opcode { - codeMap := map[uintptr]*Opcode{} - return code.copy(codeMap) -} - -func setTotalLengthToInterfaceOp(code *Opcode) { - c := code - for c.Op != OpEnd && c.Op != OpInterfaceEnd { - if c.Op == OpInterface { - c.Length = uint32(code.TotalLength()) - } - switch c.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - c = c.End - default: - c = c.Next - } - } -} - -func ToEndCode(code *Opcode) *Opcode { - c := code - for c.Op != OpEnd && c.Op != OpInterfaceEnd { - switch c.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - c = c.End - default: - c = c.Next - } - } - return c -} - -func copyToInterfaceOpcode(code *Opcode) *Opcode { - copied := copyOpcode(code) - c := copied - c = ToEndCode(c) - c.Idx += uintptrSize - c.ElemIdx = c.Idx + uintptrSize - c.Length = c.Idx + 2*uintptrSize - c.Op = OpInterfaceEnd - return copied -} - -func newOpCodeWithNext(ctx *compileContext, op OpType, next *Opcode) *Opcode { - return &Opcode{ - Op: op, - Idx: opcodeOffset(ctx.ptrIndex), - Next: next, - Type: ctx.typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - } -} - -func newEndOp(ctx *compileContext) *Opcode { - return newOpCodeWithNext(ctx, OpEnd, nil) -} - -func (c *Opcode) copy(codeMap map[uintptr]*Opcode) *Opcode { - if c == nil { - return nil - } - addr := uintptr(unsafe.Pointer(c)) - if code, exists := codeMap[addr]; exists { - return code - } - copied := &Opcode{ - Op: c.Op, - Key: c.Key, - PtrNum: c.PtrNum, - NumBitSize: c.NumBitSize, - Flags: c.Flags, - Idx: c.Idx, - Offset: c.Offset, - Type: c.Type, - DisplayIdx: c.DisplayIdx, - DisplayKey: c.DisplayKey, - ElemIdx: c.ElemIdx, - Length: c.Length, - MapIter: c.MapIter, - MapPos: c.MapPos, - Size: c.Size, - Indent: c.Indent, - } - codeMap[addr] = copied - copied.End = c.End.copy(codeMap) - copied.PrevField = c.PrevField.copy(codeMap) - copied.NextField = c.NextField.copy(codeMap) - copied.Next = c.Next.copy(codeMap) - copied.Jmp = c.Jmp - return copied -} - -func (c *Opcode) BeforeLastCode() *Opcode { - code := c - for { - var nextCode *Opcode - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - nextCode = code.End - default: - nextCode = code.Next - } - if nextCode.Op == OpEnd { - return code - } - code = nextCode - } -} - -func (c *Opcode) TotalLength() int { - var idx int - code := c - for code.Op != OpEnd && code.Op != OpInterfaceEnd { - maxIdx := int(code.MaxIdx() / uintptrSize) - if idx < maxIdx { - idx = maxIdx - } - if code.Op == OpRecursiveEnd { - break - } - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - default: - code = code.Next - } - } - maxIdx := int(code.MaxIdx() / uintptrSize) - if idx < maxIdx { - idx = maxIdx - } - return idx + 1 -} - -func (c *Opcode) decOpcodeIndex() { - for code := c; code.Op != OpEnd; { - code.DisplayIdx-- - if code.Idx > 0 { - code.Idx -= uintptrSize - } - if code.ElemIdx > 0 { - code.ElemIdx -= uintptrSize - } - if code.MapIter > 0 { - code.MapIter -= uintptrSize - } - if code.Length > 0 && code.Op.CodeType() != CodeArrayHead && code.Op.CodeType() != CodeArrayElem { - code.Length -= uintptrSize - } - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - default: - code = code.Next - } - } -} - -func (c *Opcode) decIndent() { - for code := c; code.Op != OpEnd; { - code.Indent-- - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - code = code.End - default: - code = code.Next - } - } -} - -func (c *Opcode) dumpHead(code *Opcode) string { - var length uint32 - if code.Op.CodeType() == CodeArrayHead { - length = code.Length - } else { - length = code.Length / uintptrSize - } - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - length, - ) -} - -func (c *Opcode) dumpMapHead(code *Opcode) string { - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - code.Length/uintptrSize, - code.MapIter/uintptrSize, - ) -} - -func (c *Opcode) dumpMapEnd(code *Opcode) string { - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][mapPos:%d][length:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.MapPos/uintptrSize, - code.Length/uintptrSize, - ) -} - -func (c *Opcode) dumpElem(code *Opcode) string { - var length uint32 - if code.Op.CodeType() == CodeArrayElem { - length = code.Length - } else { - length = code.Length / uintptrSize - } - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][size:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - length, - code.Size, - ) -} - -func (c *Opcode) dumpField(code *Opcode) string { - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][key:%s][offset:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.DisplayKey, - code.Offset, - ) -} - -func (c *Opcode) dumpKey(code *Opcode) string { - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][elemIdx:%d][length:%d][mapIter:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.ElemIdx/uintptrSize, - code.Length/uintptrSize, - code.MapIter/uintptrSize, - ) -} - -func (c *Opcode) dumpValue(code *Opcode) string { - return fmt.Sprintf( - `[%d]%s%s ([idx:%d][mapIter:%d])`, - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - code.MapIter/uintptrSize, - ) -} - -func (c *Opcode) Dump() string { - codes := []string{} - for code := c; code.Op != OpEnd && code.Op != OpInterfaceEnd; { - switch code.Op.CodeType() { - case CodeSliceHead: - codes = append(codes, c.dumpHead(code)) - code = code.Next - case CodeMapHead: - codes = append(codes, c.dumpMapHead(code)) - code = code.Next - case CodeArrayElem, CodeSliceElem: - codes = append(codes, c.dumpElem(code)) - code = code.End - case CodeMapKey: - codes = append(codes, c.dumpKey(code)) - code = code.End - case CodeMapValue: - codes = append(codes, c.dumpValue(code)) - code = code.Next - case CodeMapEnd: - codes = append(codes, c.dumpMapEnd(code)) - code = code.Next - case CodeStructField: - codes = append(codes, c.dumpField(code)) - code = code.Next - case CodeStructEnd: - codes = append(codes, c.dumpField(code)) - code = code.Next - default: - codes = append(codes, fmt.Sprintf( - "[%d]%s%s ([idx:%d])", - code.DisplayIdx, - strings.Repeat("-", int(code.Indent)), - code.Op, - code.Idx/uintptrSize, - )) - code = code.Next - } - } - return strings.Join(codes, "\n") -} - -func prevField(code *Opcode, removedFields map[*Opcode]struct{}) *Opcode { - if _, exists := removedFields[code]; exists { - return prevField(code.PrevField, removedFields) - } - return code -} - -func nextField(code *Opcode, removedFields map[*Opcode]struct{}) *Opcode { - if _, exists := removedFields[code]; exists { - return nextField(code.NextField, removedFields) - } - return code -} - -func linkPrevToNextField(cur *Opcode, removedFields map[*Opcode]struct{}) { - prev := prevField(cur.PrevField, removedFields) - prev.NextField = nextField(cur.NextField, removedFields) - code := prev - fcode := cur - for { - var nextCode *Opcode - switch code.Op.CodeType() { - case CodeArrayElem, CodeSliceElem, CodeMapKey: - nextCode = code.End - default: - nextCode = code.Next - } - if nextCode == fcode { - code.Next = fcode.Next - break - } else if nextCode.Op == OpEnd { - break - } - code = nextCode - } -} - -func newSliceHeaderCode(ctx *compileContext) *Opcode { - idx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - elemIdx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - length := opcodeOffset(ctx.ptrIndex) - return &Opcode{ - Op: OpSlice, - Idx: idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: elemIdx, - Length: length, - Indent: ctx.indent, - } -} - -func newSliceElemCode(ctx *compileContext, head *Opcode, size uintptr) *Opcode { - return &Opcode{ - Op: OpSliceElem, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: head.Length, - Indent: ctx.indent, - Size: uint32(size), - } -} - -func newArrayHeaderCode(ctx *compileContext, alen int) *Opcode { - idx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - elemIdx := opcodeOffset(ctx.ptrIndex) - return &Opcode{ - Op: OpArray, - Idx: idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: elemIdx, - Indent: ctx.indent, - Length: uint32(alen), - } -} - -func newArrayElemCode(ctx *compileContext, head *Opcode, length int, size uintptr) *Opcode { - return &Opcode{ - Op: OpArrayElem, - Idx: head.Idx, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: uint32(length), - Indent: ctx.indent, - Size: uint32(size), - } -} - -func newMapHeaderCode(ctx *compileContext) *Opcode { - idx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - elemIdx := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - length := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - mapIter := opcodeOffset(ctx.ptrIndex) - return &Opcode{ - Op: OpMap, - Idx: idx, - Type: ctx.typ, - DisplayIdx: ctx.opcodeIndex, - ElemIdx: elemIdx, - Length: length, - MapIter: mapIter, - Indent: ctx.indent, - } -} - -func newMapKeyCode(ctx *compileContext, head *Opcode) *Opcode { - return &Opcode{ - Op: OpMapKey, - Idx: opcodeOffset(ctx.ptrIndex), - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: head.Length, - MapIter: head.MapIter, - Indent: ctx.indent, - } -} - -func newMapValueCode(ctx *compileContext, head *Opcode) *Opcode { - return &Opcode{ - Op: OpMapValue, - Idx: opcodeOffset(ctx.ptrIndex), - DisplayIdx: ctx.opcodeIndex, - ElemIdx: head.ElemIdx, - Length: head.Length, - MapIter: head.MapIter, - Indent: ctx.indent, - } -} - -func newMapEndCode(ctx *compileContext, head *Opcode) *Opcode { - mapPos := opcodeOffset(ctx.ptrIndex) - ctx.incPtrIndex() - idx := opcodeOffset(ctx.ptrIndex) - return &Opcode{ - Op: OpMapEnd, - Idx: idx, - Next: newEndOp(ctx), - DisplayIdx: ctx.opcodeIndex, - Length: head.Length, - MapPos: mapPos, - Indent: ctx.indent, - } -} - -func newInterfaceCode(ctx *compileContext) *Opcode { - var flag OpFlags - if ctx.typ.NumMethod() > 0 { - flag |= NonEmptyInterfaceFlags - } - return &Opcode{ - Op: OpInterface, - Idx: opcodeOffset(ctx.ptrIndex), - Next: newEndOp(ctx), - Type: ctx.typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - Flags: flag, - } -} - -func newRecursiveCode(ctx *compileContext, jmp *CompiledCode) *Opcode { - return &Opcode{ - Op: OpRecursive, - Idx: opcodeOffset(ctx.ptrIndex), - Next: newEndOp(ctx), - Type: ctx.typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - Jmp: jmp, - } -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/option.go b/vendor/github.com/goccy/go-json/internal/encoder/option.go deleted file mode 100644 index f5f1f044e..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/option.go +++ /dev/null @@ -1,41 +0,0 @@ -package encoder - -import "context" - -type OptionFlag uint8 - -const ( - HTMLEscapeOption OptionFlag = 1 << iota - IndentOption - UnorderedMapOption - DebugOption - ColorizeOption - ContextOption -) - -type Option struct { - Flag OptionFlag - ColorScheme *ColorScheme - Context context.Context -} - -type EncodeFormat struct { - Header string - Footer string -} - -type EncodeFormatScheme struct { - Int EncodeFormat - Uint EncodeFormat - Float EncodeFormat - Bool EncodeFormat - String EncodeFormat - Binary EncodeFormat - ObjectKey EncodeFormat - Null EncodeFormat -} - -type ( - ColorScheme = EncodeFormatScheme - ColorFormat = EncodeFormat -) diff --git a/vendor/github.com/goccy/go-json/internal/encoder/optype.go b/vendor/github.com/goccy/go-json/internal/encoder/optype.go deleted file mode 100644 index 335fc043e..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/optype.go +++ /dev/null @@ -1,934 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package encoder - -import ( - "strings" -) - -type CodeType int - -const ( - CodeOp CodeType = 0 - CodeArrayHead CodeType = 1 - CodeArrayElem CodeType = 2 - CodeSliceHead CodeType = 3 - CodeSliceElem CodeType = 4 - CodeMapHead CodeType = 5 - CodeMapKey CodeType = 6 - CodeMapValue CodeType = 7 - CodeMapEnd CodeType = 8 - CodeRecursive CodeType = 9 - CodeStructField CodeType = 10 - CodeStructEnd CodeType = 11 -) - -var opTypeStrings = [401]string{ - "End", - "Interface", - "Ptr", - "SliceElem", - "SliceEnd", - "ArrayElem", - "ArrayEnd", - "MapKey", - "MapValue", - "MapEnd", - "Recursive", - "RecursivePtr", - "RecursiveEnd", - "InterfaceEnd", - "StructAnonymousEnd", - "Int", - "Uint", - "Float32", - "Float64", - "Bool", - "String", - "Bytes", - "Number", - "Array", - "Map", - "Slice", - "Struct", - "MarshalJSON", - "MarshalText", - "IntString", - "UintString", - "Float32String", - "Float64String", - "BoolString", - "StringString", - "NumberString", - "IntPtr", - "UintPtr", - "Float32Ptr", - "Float64Ptr", - "BoolPtr", - "StringPtr", - "BytesPtr", - "NumberPtr", - "ArrayPtr", - "MapPtr", - "SlicePtr", - "MarshalJSONPtr", - "MarshalTextPtr", - "InterfacePtr", - "IntPtrString", - "UintPtrString", - "Float32PtrString", - "Float64PtrString", - "BoolPtrString", - "StringPtrString", - "NumberPtrString", - "StructHeadInt", - "StructHeadOmitEmptyInt", - "StructPtrHeadInt", - "StructPtrHeadOmitEmptyInt", - "StructHeadUint", - "StructHeadOmitEmptyUint", - "StructPtrHeadUint", - "StructPtrHeadOmitEmptyUint", - "StructHeadFloat32", - "StructHeadOmitEmptyFloat32", - "StructPtrHeadFloat32", - "StructPtrHeadOmitEmptyFloat32", - "StructHeadFloat64", - "StructHeadOmitEmptyFloat64", - "StructPtrHeadFloat64", - "StructPtrHeadOmitEmptyFloat64", - "StructHeadBool", - "StructHeadOmitEmptyBool", - "StructPtrHeadBool", - "StructPtrHeadOmitEmptyBool", - "StructHeadString", - "StructHeadOmitEmptyString", - "StructPtrHeadString", - "StructPtrHeadOmitEmptyString", - "StructHeadBytes", - "StructHeadOmitEmptyBytes", - "StructPtrHeadBytes", - "StructPtrHeadOmitEmptyBytes", - "StructHeadNumber", - "StructHeadOmitEmptyNumber", - "StructPtrHeadNumber", - "StructPtrHeadOmitEmptyNumber", - "StructHeadArray", - "StructHeadOmitEmptyArray", - "StructPtrHeadArray", - "StructPtrHeadOmitEmptyArray", - "StructHeadMap", - "StructHeadOmitEmptyMap", - "StructPtrHeadMap", - "StructPtrHeadOmitEmptyMap", - "StructHeadSlice", - "StructHeadOmitEmptySlice", - "StructPtrHeadSlice", - "StructPtrHeadOmitEmptySlice", - "StructHeadStruct", - "StructHeadOmitEmptyStruct", - "StructPtrHeadStruct", - "StructPtrHeadOmitEmptyStruct", - "StructHeadMarshalJSON", - "StructHeadOmitEmptyMarshalJSON", - "StructPtrHeadMarshalJSON", - "StructPtrHeadOmitEmptyMarshalJSON", - "StructHeadMarshalText", - "StructHeadOmitEmptyMarshalText", - "StructPtrHeadMarshalText", - "StructPtrHeadOmitEmptyMarshalText", - "StructHeadIntString", - "StructHeadOmitEmptyIntString", - "StructPtrHeadIntString", - "StructPtrHeadOmitEmptyIntString", - "StructHeadUintString", - "StructHeadOmitEmptyUintString", - "StructPtrHeadUintString", - "StructPtrHeadOmitEmptyUintString", - "StructHeadFloat32String", - "StructHeadOmitEmptyFloat32String", - "StructPtrHeadFloat32String", - "StructPtrHeadOmitEmptyFloat32String", - "StructHeadFloat64String", - "StructHeadOmitEmptyFloat64String", - "StructPtrHeadFloat64String", - "StructPtrHeadOmitEmptyFloat64String", - "StructHeadBoolString", - "StructHeadOmitEmptyBoolString", - "StructPtrHeadBoolString", - "StructPtrHeadOmitEmptyBoolString", - "StructHeadStringString", - "StructHeadOmitEmptyStringString", - "StructPtrHeadStringString", - "StructPtrHeadOmitEmptyStringString", - "StructHeadNumberString", - "StructHeadOmitEmptyNumberString", - "StructPtrHeadNumberString", - "StructPtrHeadOmitEmptyNumberString", - "StructHeadIntPtr", - "StructHeadOmitEmptyIntPtr", - "StructPtrHeadIntPtr", - "StructPtrHeadOmitEmptyIntPtr", - "StructHeadUintPtr", - "StructHeadOmitEmptyUintPtr", - "StructPtrHeadUintPtr", - "StructPtrHeadOmitEmptyUintPtr", - "StructHeadFloat32Ptr", - "StructHeadOmitEmptyFloat32Ptr", - "StructPtrHeadFloat32Ptr", - "StructPtrHeadOmitEmptyFloat32Ptr", - "StructHeadFloat64Ptr", - "StructHeadOmitEmptyFloat64Ptr", - "StructPtrHeadFloat64Ptr", - "StructPtrHeadOmitEmptyFloat64Ptr", - "StructHeadBoolPtr", - "StructHeadOmitEmptyBoolPtr", - "StructPtrHeadBoolPtr", - "StructPtrHeadOmitEmptyBoolPtr", - "StructHeadStringPtr", - "StructHeadOmitEmptyStringPtr", - "StructPtrHeadStringPtr", - "StructPtrHeadOmitEmptyStringPtr", - "StructHeadBytesPtr", - "StructHeadOmitEmptyBytesPtr", - "StructPtrHeadBytesPtr", - "StructPtrHeadOmitEmptyBytesPtr", - "StructHeadNumberPtr", - "StructHeadOmitEmptyNumberPtr", - "StructPtrHeadNumberPtr", - "StructPtrHeadOmitEmptyNumberPtr", - "StructHeadArrayPtr", - "StructHeadOmitEmptyArrayPtr", - "StructPtrHeadArrayPtr", - "StructPtrHeadOmitEmptyArrayPtr", - "StructHeadMapPtr", - "StructHeadOmitEmptyMapPtr", - "StructPtrHeadMapPtr", - "StructPtrHeadOmitEmptyMapPtr", - "StructHeadSlicePtr", - "StructHeadOmitEmptySlicePtr", - "StructPtrHeadSlicePtr", - "StructPtrHeadOmitEmptySlicePtr", - "StructHeadMarshalJSONPtr", - "StructHeadOmitEmptyMarshalJSONPtr", - "StructPtrHeadMarshalJSONPtr", - "StructPtrHeadOmitEmptyMarshalJSONPtr", - "StructHeadMarshalTextPtr", - "StructHeadOmitEmptyMarshalTextPtr", - "StructPtrHeadMarshalTextPtr", - "StructPtrHeadOmitEmptyMarshalTextPtr", - "StructHeadInterfacePtr", - "StructHeadOmitEmptyInterfacePtr", - "StructPtrHeadInterfacePtr", - "StructPtrHeadOmitEmptyInterfacePtr", - "StructHeadIntPtrString", - "StructHeadOmitEmptyIntPtrString", - "StructPtrHeadIntPtrString", - "StructPtrHeadOmitEmptyIntPtrString", - "StructHeadUintPtrString", - "StructHeadOmitEmptyUintPtrString", - "StructPtrHeadUintPtrString", - "StructPtrHeadOmitEmptyUintPtrString", - "StructHeadFloat32PtrString", - "StructHeadOmitEmptyFloat32PtrString", - "StructPtrHeadFloat32PtrString", - "StructPtrHeadOmitEmptyFloat32PtrString", - "StructHeadFloat64PtrString", - "StructHeadOmitEmptyFloat64PtrString", - "StructPtrHeadFloat64PtrString", - "StructPtrHeadOmitEmptyFloat64PtrString", - "StructHeadBoolPtrString", - "StructHeadOmitEmptyBoolPtrString", - "StructPtrHeadBoolPtrString", - "StructPtrHeadOmitEmptyBoolPtrString", - "StructHeadStringPtrString", - "StructHeadOmitEmptyStringPtrString", - "StructPtrHeadStringPtrString", - "StructPtrHeadOmitEmptyStringPtrString", - "StructHeadNumberPtrString", - "StructHeadOmitEmptyNumberPtrString", - "StructPtrHeadNumberPtrString", - "StructPtrHeadOmitEmptyNumberPtrString", - "StructHead", - "StructHeadOmitEmpty", - "StructPtrHead", - "StructPtrHeadOmitEmpty", - "StructFieldInt", - "StructFieldOmitEmptyInt", - "StructEndInt", - "StructEndOmitEmptyInt", - "StructFieldUint", - "StructFieldOmitEmptyUint", - "StructEndUint", - "StructEndOmitEmptyUint", - "StructFieldFloat32", - "StructFieldOmitEmptyFloat32", - "StructEndFloat32", - "StructEndOmitEmptyFloat32", - "StructFieldFloat64", - "StructFieldOmitEmptyFloat64", - "StructEndFloat64", - "StructEndOmitEmptyFloat64", - "StructFieldBool", - "StructFieldOmitEmptyBool", - "StructEndBool", - "StructEndOmitEmptyBool", - "StructFieldString", - "StructFieldOmitEmptyString", - "StructEndString", - "StructEndOmitEmptyString", - "StructFieldBytes", - "StructFieldOmitEmptyBytes", - "StructEndBytes", - "StructEndOmitEmptyBytes", - "StructFieldNumber", - "StructFieldOmitEmptyNumber", - "StructEndNumber", - "StructEndOmitEmptyNumber", - "StructFieldArray", - "StructFieldOmitEmptyArray", - "StructEndArray", - "StructEndOmitEmptyArray", - "StructFieldMap", - "StructFieldOmitEmptyMap", - "StructEndMap", - "StructEndOmitEmptyMap", - "StructFieldSlice", - "StructFieldOmitEmptySlice", - "StructEndSlice", - "StructEndOmitEmptySlice", - "StructFieldStruct", - "StructFieldOmitEmptyStruct", - "StructEndStruct", - "StructEndOmitEmptyStruct", - "StructFieldMarshalJSON", - "StructFieldOmitEmptyMarshalJSON", - "StructEndMarshalJSON", - "StructEndOmitEmptyMarshalJSON", - "StructFieldMarshalText", - "StructFieldOmitEmptyMarshalText", - "StructEndMarshalText", - "StructEndOmitEmptyMarshalText", - "StructFieldIntString", - "StructFieldOmitEmptyIntString", - "StructEndIntString", - "StructEndOmitEmptyIntString", - "StructFieldUintString", - "StructFieldOmitEmptyUintString", - "StructEndUintString", - "StructEndOmitEmptyUintString", - "StructFieldFloat32String", - "StructFieldOmitEmptyFloat32String", - "StructEndFloat32String", - "StructEndOmitEmptyFloat32String", - "StructFieldFloat64String", - "StructFieldOmitEmptyFloat64String", - "StructEndFloat64String", - "StructEndOmitEmptyFloat64String", - "StructFieldBoolString", - "StructFieldOmitEmptyBoolString", - "StructEndBoolString", - "StructEndOmitEmptyBoolString", - "StructFieldStringString", - "StructFieldOmitEmptyStringString", - "StructEndStringString", - "StructEndOmitEmptyStringString", - "StructFieldNumberString", - "StructFieldOmitEmptyNumberString", - "StructEndNumberString", - "StructEndOmitEmptyNumberString", - "StructFieldIntPtr", - "StructFieldOmitEmptyIntPtr", - "StructEndIntPtr", - "StructEndOmitEmptyIntPtr", - "StructFieldUintPtr", - "StructFieldOmitEmptyUintPtr", - "StructEndUintPtr", - "StructEndOmitEmptyUintPtr", - "StructFieldFloat32Ptr", - "StructFieldOmitEmptyFloat32Ptr", - "StructEndFloat32Ptr", - "StructEndOmitEmptyFloat32Ptr", - "StructFieldFloat64Ptr", - "StructFieldOmitEmptyFloat64Ptr", - "StructEndFloat64Ptr", - "StructEndOmitEmptyFloat64Ptr", - "StructFieldBoolPtr", - "StructFieldOmitEmptyBoolPtr", - "StructEndBoolPtr", - "StructEndOmitEmptyBoolPtr", - "StructFieldStringPtr", - "StructFieldOmitEmptyStringPtr", - "StructEndStringPtr", - "StructEndOmitEmptyStringPtr", - "StructFieldBytesPtr", - "StructFieldOmitEmptyBytesPtr", - "StructEndBytesPtr", - "StructEndOmitEmptyBytesPtr", - "StructFieldNumberPtr", - "StructFieldOmitEmptyNumberPtr", - "StructEndNumberPtr", - "StructEndOmitEmptyNumberPtr", - "StructFieldArrayPtr", - "StructFieldOmitEmptyArrayPtr", - "StructEndArrayPtr", - "StructEndOmitEmptyArrayPtr", - "StructFieldMapPtr", - "StructFieldOmitEmptyMapPtr", - "StructEndMapPtr", - "StructEndOmitEmptyMapPtr", - "StructFieldSlicePtr", - "StructFieldOmitEmptySlicePtr", - "StructEndSlicePtr", - "StructEndOmitEmptySlicePtr", - "StructFieldMarshalJSONPtr", - "StructFieldOmitEmptyMarshalJSONPtr", - "StructEndMarshalJSONPtr", - "StructEndOmitEmptyMarshalJSONPtr", - "StructFieldMarshalTextPtr", - "StructFieldOmitEmptyMarshalTextPtr", - "StructEndMarshalTextPtr", - "StructEndOmitEmptyMarshalTextPtr", - "StructFieldInterfacePtr", - "StructFieldOmitEmptyInterfacePtr", - "StructEndInterfacePtr", - "StructEndOmitEmptyInterfacePtr", - "StructFieldIntPtrString", - "StructFieldOmitEmptyIntPtrString", - "StructEndIntPtrString", - "StructEndOmitEmptyIntPtrString", - "StructFieldUintPtrString", - "StructFieldOmitEmptyUintPtrString", - "StructEndUintPtrString", - "StructEndOmitEmptyUintPtrString", - "StructFieldFloat32PtrString", - "StructFieldOmitEmptyFloat32PtrString", - "StructEndFloat32PtrString", - "StructEndOmitEmptyFloat32PtrString", - "StructFieldFloat64PtrString", - "StructFieldOmitEmptyFloat64PtrString", - "StructEndFloat64PtrString", - "StructEndOmitEmptyFloat64PtrString", - "StructFieldBoolPtrString", - "StructFieldOmitEmptyBoolPtrString", - "StructEndBoolPtrString", - "StructEndOmitEmptyBoolPtrString", - "StructFieldStringPtrString", - "StructFieldOmitEmptyStringPtrString", - "StructEndStringPtrString", - "StructEndOmitEmptyStringPtrString", - "StructFieldNumberPtrString", - "StructFieldOmitEmptyNumberPtrString", - "StructEndNumberPtrString", - "StructEndOmitEmptyNumberPtrString", - "StructField", - "StructFieldOmitEmpty", - "StructEnd", - "StructEndOmitEmpty", -} - -type OpType uint16 - -const ( - OpEnd OpType = 0 - OpInterface OpType = 1 - OpPtr OpType = 2 - OpSliceElem OpType = 3 - OpSliceEnd OpType = 4 - OpArrayElem OpType = 5 - OpArrayEnd OpType = 6 - OpMapKey OpType = 7 - OpMapValue OpType = 8 - OpMapEnd OpType = 9 - OpRecursive OpType = 10 - OpRecursivePtr OpType = 11 - OpRecursiveEnd OpType = 12 - OpInterfaceEnd OpType = 13 - OpStructAnonymousEnd OpType = 14 - OpInt OpType = 15 - OpUint OpType = 16 - OpFloat32 OpType = 17 - OpFloat64 OpType = 18 - OpBool OpType = 19 - OpString OpType = 20 - OpBytes OpType = 21 - OpNumber OpType = 22 - OpArray OpType = 23 - OpMap OpType = 24 - OpSlice OpType = 25 - OpStruct OpType = 26 - OpMarshalJSON OpType = 27 - OpMarshalText OpType = 28 - OpIntString OpType = 29 - OpUintString OpType = 30 - OpFloat32String OpType = 31 - OpFloat64String OpType = 32 - OpBoolString OpType = 33 - OpStringString OpType = 34 - OpNumberString OpType = 35 - OpIntPtr OpType = 36 - OpUintPtr OpType = 37 - OpFloat32Ptr OpType = 38 - OpFloat64Ptr OpType = 39 - OpBoolPtr OpType = 40 - OpStringPtr OpType = 41 - OpBytesPtr OpType = 42 - OpNumberPtr OpType = 43 - OpArrayPtr OpType = 44 - OpMapPtr OpType = 45 - OpSlicePtr OpType = 46 - OpMarshalJSONPtr OpType = 47 - OpMarshalTextPtr OpType = 48 - OpInterfacePtr OpType = 49 - OpIntPtrString OpType = 50 - OpUintPtrString OpType = 51 - OpFloat32PtrString OpType = 52 - OpFloat64PtrString OpType = 53 - OpBoolPtrString OpType = 54 - OpStringPtrString OpType = 55 - OpNumberPtrString OpType = 56 - OpStructHeadInt OpType = 57 - OpStructHeadOmitEmptyInt OpType = 58 - OpStructPtrHeadInt OpType = 59 - OpStructPtrHeadOmitEmptyInt OpType = 60 - OpStructHeadUint OpType = 61 - OpStructHeadOmitEmptyUint OpType = 62 - OpStructPtrHeadUint OpType = 63 - OpStructPtrHeadOmitEmptyUint OpType = 64 - OpStructHeadFloat32 OpType = 65 - OpStructHeadOmitEmptyFloat32 OpType = 66 - OpStructPtrHeadFloat32 OpType = 67 - OpStructPtrHeadOmitEmptyFloat32 OpType = 68 - OpStructHeadFloat64 OpType = 69 - OpStructHeadOmitEmptyFloat64 OpType = 70 - OpStructPtrHeadFloat64 OpType = 71 - OpStructPtrHeadOmitEmptyFloat64 OpType = 72 - OpStructHeadBool OpType = 73 - OpStructHeadOmitEmptyBool OpType = 74 - OpStructPtrHeadBool OpType = 75 - OpStructPtrHeadOmitEmptyBool OpType = 76 - OpStructHeadString OpType = 77 - OpStructHeadOmitEmptyString OpType = 78 - OpStructPtrHeadString OpType = 79 - OpStructPtrHeadOmitEmptyString OpType = 80 - OpStructHeadBytes OpType = 81 - OpStructHeadOmitEmptyBytes OpType = 82 - OpStructPtrHeadBytes OpType = 83 - OpStructPtrHeadOmitEmptyBytes OpType = 84 - OpStructHeadNumber OpType = 85 - OpStructHeadOmitEmptyNumber OpType = 86 - OpStructPtrHeadNumber OpType = 87 - OpStructPtrHeadOmitEmptyNumber OpType = 88 - OpStructHeadArray OpType = 89 - OpStructHeadOmitEmptyArray OpType = 90 - OpStructPtrHeadArray OpType = 91 - OpStructPtrHeadOmitEmptyArray OpType = 92 - OpStructHeadMap OpType = 93 - OpStructHeadOmitEmptyMap OpType = 94 - OpStructPtrHeadMap OpType = 95 - OpStructPtrHeadOmitEmptyMap OpType = 96 - OpStructHeadSlice OpType = 97 - OpStructHeadOmitEmptySlice OpType = 98 - OpStructPtrHeadSlice OpType = 99 - OpStructPtrHeadOmitEmptySlice OpType = 100 - OpStructHeadStruct OpType = 101 - OpStructHeadOmitEmptyStruct OpType = 102 - OpStructPtrHeadStruct OpType = 103 - OpStructPtrHeadOmitEmptyStruct OpType = 104 - OpStructHeadMarshalJSON OpType = 105 - OpStructHeadOmitEmptyMarshalJSON OpType = 106 - OpStructPtrHeadMarshalJSON OpType = 107 - OpStructPtrHeadOmitEmptyMarshalJSON OpType = 108 - OpStructHeadMarshalText OpType = 109 - OpStructHeadOmitEmptyMarshalText OpType = 110 - OpStructPtrHeadMarshalText OpType = 111 - OpStructPtrHeadOmitEmptyMarshalText OpType = 112 - OpStructHeadIntString OpType = 113 - OpStructHeadOmitEmptyIntString OpType = 114 - OpStructPtrHeadIntString OpType = 115 - OpStructPtrHeadOmitEmptyIntString OpType = 116 - OpStructHeadUintString OpType = 117 - OpStructHeadOmitEmptyUintString OpType = 118 - OpStructPtrHeadUintString OpType = 119 - OpStructPtrHeadOmitEmptyUintString OpType = 120 - OpStructHeadFloat32String OpType = 121 - OpStructHeadOmitEmptyFloat32String OpType = 122 - OpStructPtrHeadFloat32String OpType = 123 - OpStructPtrHeadOmitEmptyFloat32String OpType = 124 - OpStructHeadFloat64String OpType = 125 - OpStructHeadOmitEmptyFloat64String OpType = 126 - OpStructPtrHeadFloat64String OpType = 127 - OpStructPtrHeadOmitEmptyFloat64String OpType = 128 - OpStructHeadBoolString OpType = 129 - OpStructHeadOmitEmptyBoolString OpType = 130 - OpStructPtrHeadBoolString OpType = 131 - OpStructPtrHeadOmitEmptyBoolString OpType = 132 - OpStructHeadStringString OpType = 133 - OpStructHeadOmitEmptyStringString OpType = 134 - OpStructPtrHeadStringString OpType = 135 - OpStructPtrHeadOmitEmptyStringString OpType = 136 - OpStructHeadNumberString OpType = 137 - OpStructHeadOmitEmptyNumberString OpType = 138 - OpStructPtrHeadNumberString OpType = 139 - OpStructPtrHeadOmitEmptyNumberString OpType = 140 - OpStructHeadIntPtr OpType = 141 - OpStructHeadOmitEmptyIntPtr OpType = 142 - OpStructPtrHeadIntPtr OpType = 143 - OpStructPtrHeadOmitEmptyIntPtr OpType = 144 - OpStructHeadUintPtr OpType = 145 - OpStructHeadOmitEmptyUintPtr OpType = 146 - OpStructPtrHeadUintPtr OpType = 147 - OpStructPtrHeadOmitEmptyUintPtr OpType = 148 - OpStructHeadFloat32Ptr OpType = 149 - OpStructHeadOmitEmptyFloat32Ptr OpType = 150 - OpStructPtrHeadFloat32Ptr OpType = 151 - OpStructPtrHeadOmitEmptyFloat32Ptr OpType = 152 - OpStructHeadFloat64Ptr OpType = 153 - OpStructHeadOmitEmptyFloat64Ptr OpType = 154 - OpStructPtrHeadFloat64Ptr OpType = 155 - OpStructPtrHeadOmitEmptyFloat64Ptr OpType = 156 - OpStructHeadBoolPtr OpType = 157 - OpStructHeadOmitEmptyBoolPtr OpType = 158 - OpStructPtrHeadBoolPtr OpType = 159 - OpStructPtrHeadOmitEmptyBoolPtr OpType = 160 - OpStructHeadStringPtr OpType = 161 - OpStructHeadOmitEmptyStringPtr OpType = 162 - OpStructPtrHeadStringPtr OpType = 163 - OpStructPtrHeadOmitEmptyStringPtr OpType = 164 - OpStructHeadBytesPtr OpType = 165 - OpStructHeadOmitEmptyBytesPtr OpType = 166 - OpStructPtrHeadBytesPtr OpType = 167 - OpStructPtrHeadOmitEmptyBytesPtr OpType = 168 - OpStructHeadNumberPtr OpType = 169 - OpStructHeadOmitEmptyNumberPtr OpType = 170 - OpStructPtrHeadNumberPtr OpType = 171 - OpStructPtrHeadOmitEmptyNumberPtr OpType = 172 - OpStructHeadArrayPtr OpType = 173 - OpStructHeadOmitEmptyArrayPtr OpType = 174 - OpStructPtrHeadArrayPtr OpType = 175 - OpStructPtrHeadOmitEmptyArrayPtr OpType = 176 - OpStructHeadMapPtr OpType = 177 - OpStructHeadOmitEmptyMapPtr OpType = 178 - OpStructPtrHeadMapPtr OpType = 179 - OpStructPtrHeadOmitEmptyMapPtr OpType = 180 - OpStructHeadSlicePtr OpType = 181 - OpStructHeadOmitEmptySlicePtr OpType = 182 - OpStructPtrHeadSlicePtr OpType = 183 - OpStructPtrHeadOmitEmptySlicePtr OpType = 184 - OpStructHeadMarshalJSONPtr OpType = 185 - OpStructHeadOmitEmptyMarshalJSONPtr OpType = 186 - OpStructPtrHeadMarshalJSONPtr OpType = 187 - OpStructPtrHeadOmitEmptyMarshalJSONPtr OpType = 188 - OpStructHeadMarshalTextPtr OpType = 189 - OpStructHeadOmitEmptyMarshalTextPtr OpType = 190 - OpStructPtrHeadMarshalTextPtr OpType = 191 - OpStructPtrHeadOmitEmptyMarshalTextPtr OpType = 192 - OpStructHeadInterfacePtr OpType = 193 - OpStructHeadOmitEmptyInterfacePtr OpType = 194 - OpStructPtrHeadInterfacePtr OpType = 195 - OpStructPtrHeadOmitEmptyInterfacePtr OpType = 196 - OpStructHeadIntPtrString OpType = 197 - OpStructHeadOmitEmptyIntPtrString OpType = 198 - OpStructPtrHeadIntPtrString OpType = 199 - OpStructPtrHeadOmitEmptyIntPtrString OpType = 200 - OpStructHeadUintPtrString OpType = 201 - OpStructHeadOmitEmptyUintPtrString OpType = 202 - OpStructPtrHeadUintPtrString OpType = 203 - OpStructPtrHeadOmitEmptyUintPtrString OpType = 204 - OpStructHeadFloat32PtrString OpType = 205 - OpStructHeadOmitEmptyFloat32PtrString OpType = 206 - OpStructPtrHeadFloat32PtrString OpType = 207 - OpStructPtrHeadOmitEmptyFloat32PtrString OpType = 208 - OpStructHeadFloat64PtrString OpType = 209 - OpStructHeadOmitEmptyFloat64PtrString OpType = 210 - OpStructPtrHeadFloat64PtrString OpType = 211 - OpStructPtrHeadOmitEmptyFloat64PtrString OpType = 212 - OpStructHeadBoolPtrString OpType = 213 - OpStructHeadOmitEmptyBoolPtrString OpType = 214 - OpStructPtrHeadBoolPtrString OpType = 215 - OpStructPtrHeadOmitEmptyBoolPtrString OpType = 216 - OpStructHeadStringPtrString OpType = 217 - OpStructHeadOmitEmptyStringPtrString OpType = 218 - OpStructPtrHeadStringPtrString OpType = 219 - OpStructPtrHeadOmitEmptyStringPtrString OpType = 220 - OpStructHeadNumberPtrString OpType = 221 - OpStructHeadOmitEmptyNumberPtrString OpType = 222 - OpStructPtrHeadNumberPtrString OpType = 223 - OpStructPtrHeadOmitEmptyNumberPtrString OpType = 224 - OpStructHead OpType = 225 - OpStructHeadOmitEmpty OpType = 226 - OpStructPtrHead OpType = 227 - OpStructPtrHeadOmitEmpty OpType = 228 - OpStructFieldInt OpType = 229 - OpStructFieldOmitEmptyInt OpType = 230 - OpStructEndInt OpType = 231 - OpStructEndOmitEmptyInt OpType = 232 - OpStructFieldUint OpType = 233 - OpStructFieldOmitEmptyUint OpType = 234 - OpStructEndUint OpType = 235 - OpStructEndOmitEmptyUint OpType = 236 - OpStructFieldFloat32 OpType = 237 - OpStructFieldOmitEmptyFloat32 OpType = 238 - OpStructEndFloat32 OpType = 239 - OpStructEndOmitEmptyFloat32 OpType = 240 - OpStructFieldFloat64 OpType = 241 - OpStructFieldOmitEmptyFloat64 OpType = 242 - OpStructEndFloat64 OpType = 243 - OpStructEndOmitEmptyFloat64 OpType = 244 - OpStructFieldBool OpType = 245 - OpStructFieldOmitEmptyBool OpType = 246 - OpStructEndBool OpType = 247 - OpStructEndOmitEmptyBool OpType = 248 - OpStructFieldString OpType = 249 - OpStructFieldOmitEmptyString OpType = 250 - OpStructEndString OpType = 251 - OpStructEndOmitEmptyString OpType = 252 - OpStructFieldBytes OpType = 253 - OpStructFieldOmitEmptyBytes OpType = 254 - OpStructEndBytes OpType = 255 - OpStructEndOmitEmptyBytes OpType = 256 - OpStructFieldNumber OpType = 257 - OpStructFieldOmitEmptyNumber OpType = 258 - OpStructEndNumber OpType = 259 - OpStructEndOmitEmptyNumber OpType = 260 - OpStructFieldArray OpType = 261 - OpStructFieldOmitEmptyArray OpType = 262 - OpStructEndArray OpType = 263 - OpStructEndOmitEmptyArray OpType = 264 - OpStructFieldMap OpType = 265 - OpStructFieldOmitEmptyMap OpType = 266 - OpStructEndMap OpType = 267 - OpStructEndOmitEmptyMap OpType = 268 - OpStructFieldSlice OpType = 269 - OpStructFieldOmitEmptySlice OpType = 270 - OpStructEndSlice OpType = 271 - OpStructEndOmitEmptySlice OpType = 272 - OpStructFieldStruct OpType = 273 - OpStructFieldOmitEmptyStruct OpType = 274 - OpStructEndStruct OpType = 275 - OpStructEndOmitEmptyStruct OpType = 276 - OpStructFieldMarshalJSON OpType = 277 - OpStructFieldOmitEmptyMarshalJSON OpType = 278 - OpStructEndMarshalJSON OpType = 279 - OpStructEndOmitEmptyMarshalJSON OpType = 280 - OpStructFieldMarshalText OpType = 281 - OpStructFieldOmitEmptyMarshalText OpType = 282 - OpStructEndMarshalText OpType = 283 - OpStructEndOmitEmptyMarshalText OpType = 284 - OpStructFieldIntString OpType = 285 - OpStructFieldOmitEmptyIntString OpType = 286 - OpStructEndIntString OpType = 287 - OpStructEndOmitEmptyIntString OpType = 288 - OpStructFieldUintString OpType = 289 - OpStructFieldOmitEmptyUintString OpType = 290 - OpStructEndUintString OpType = 291 - OpStructEndOmitEmptyUintString OpType = 292 - OpStructFieldFloat32String OpType = 293 - OpStructFieldOmitEmptyFloat32String OpType = 294 - OpStructEndFloat32String OpType = 295 - OpStructEndOmitEmptyFloat32String OpType = 296 - OpStructFieldFloat64String OpType = 297 - OpStructFieldOmitEmptyFloat64String OpType = 298 - OpStructEndFloat64String OpType = 299 - OpStructEndOmitEmptyFloat64String OpType = 300 - OpStructFieldBoolString OpType = 301 - OpStructFieldOmitEmptyBoolString OpType = 302 - OpStructEndBoolString OpType = 303 - OpStructEndOmitEmptyBoolString OpType = 304 - OpStructFieldStringString OpType = 305 - OpStructFieldOmitEmptyStringString OpType = 306 - OpStructEndStringString OpType = 307 - OpStructEndOmitEmptyStringString OpType = 308 - OpStructFieldNumberString OpType = 309 - OpStructFieldOmitEmptyNumberString OpType = 310 - OpStructEndNumberString OpType = 311 - OpStructEndOmitEmptyNumberString OpType = 312 - OpStructFieldIntPtr OpType = 313 - OpStructFieldOmitEmptyIntPtr OpType = 314 - OpStructEndIntPtr OpType = 315 - OpStructEndOmitEmptyIntPtr OpType = 316 - OpStructFieldUintPtr OpType = 317 - OpStructFieldOmitEmptyUintPtr OpType = 318 - OpStructEndUintPtr OpType = 319 - OpStructEndOmitEmptyUintPtr OpType = 320 - OpStructFieldFloat32Ptr OpType = 321 - OpStructFieldOmitEmptyFloat32Ptr OpType = 322 - OpStructEndFloat32Ptr OpType = 323 - OpStructEndOmitEmptyFloat32Ptr OpType = 324 - OpStructFieldFloat64Ptr OpType = 325 - OpStructFieldOmitEmptyFloat64Ptr OpType = 326 - OpStructEndFloat64Ptr OpType = 327 - OpStructEndOmitEmptyFloat64Ptr OpType = 328 - OpStructFieldBoolPtr OpType = 329 - OpStructFieldOmitEmptyBoolPtr OpType = 330 - OpStructEndBoolPtr OpType = 331 - OpStructEndOmitEmptyBoolPtr OpType = 332 - OpStructFieldStringPtr OpType = 333 - OpStructFieldOmitEmptyStringPtr OpType = 334 - OpStructEndStringPtr OpType = 335 - OpStructEndOmitEmptyStringPtr OpType = 336 - OpStructFieldBytesPtr OpType = 337 - OpStructFieldOmitEmptyBytesPtr OpType = 338 - OpStructEndBytesPtr OpType = 339 - OpStructEndOmitEmptyBytesPtr OpType = 340 - OpStructFieldNumberPtr OpType = 341 - OpStructFieldOmitEmptyNumberPtr OpType = 342 - OpStructEndNumberPtr OpType = 343 - OpStructEndOmitEmptyNumberPtr OpType = 344 - OpStructFieldArrayPtr OpType = 345 - OpStructFieldOmitEmptyArrayPtr OpType = 346 - OpStructEndArrayPtr OpType = 347 - OpStructEndOmitEmptyArrayPtr OpType = 348 - OpStructFieldMapPtr OpType = 349 - OpStructFieldOmitEmptyMapPtr OpType = 350 - OpStructEndMapPtr OpType = 351 - OpStructEndOmitEmptyMapPtr OpType = 352 - OpStructFieldSlicePtr OpType = 353 - OpStructFieldOmitEmptySlicePtr OpType = 354 - OpStructEndSlicePtr OpType = 355 - OpStructEndOmitEmptySlicePtr OpType = 356 - OpStructFieldMarshalJSONPtr OpType = 357 - OpStructFieldOmitEmptyMarshalJSONPtr OpType = 358 - OpStructEndMarshalJSONPtr OpType = 359 - OpStructEndOmitEmptyMarshalJSONPtr OpType = 360 - OpStructFieldMarshalTextPtr OpType = 361 - OpStructFieldOmitEmptyMarshalTextPtr OpType = 362 - OpStructEndMarshalTextPtr OpType = 363 - OpStructEndOmitEmptyMarshalTextPtr OpType = 364 - OpStructFieldInterfacePtr OpType = 365 - OpStructFieldOmitEmptyInterfacePtr OpType = 366 - OpStructEndInterfacePtr OpType = 367 - OpStructEndOmitEmptyInterfacePtr OpType = 368 - OpStructFieldIntPtrString OpType = 369 - OpStructFieldOmitEmptyIntPtrString OpType = 370 - OpStructEndIntPtrString OpType = 371 - OpStructEndOmitEmptyIntPtrString OpType = 372 - OpStructFieldUintPtrString OpType = 373 - OpStructFieldOmitEmptyUintPtrString OpType = 374 - OpStructEndUintPtrString OpType = 375 - OpStructEndOmitEmptyUintPtrString OpType = 376 - OpStructFieldFloat32PtrString OpType = 377 - OpStructFieldOmitEmptyFloat32PtrString OpType = 378 - OpStructEndFloat32PtrString OpType = 379 - OpStructEndOmitEmptyFloat32PtrString OpType = 380 - OpStructFieldFloat64PtrString OpType = 381 - OpStructFieldOmitEmptyFloat64PtrString OpType = 382 - OpStructEndFloat64PtrString OpType = 383 - OpStructEndOmitEmptyFloat64PtrString OpType = 384 - OpStructFieldBoolPtrString OpType = 385 - OpStructFieldOmitEmptyBoolPtrString OpType = 386 - OpStructEndBoolPtrString OpType = 387 - OpStructEndOmitEmptyBoolPtrString OpType = 388 - OpStructFieldStringPtrString OpType = 389 - OpStructFieldOmitEmptyStringPtrString OpType = 390 - OpStructEndStringPtrString OpType = 391 - OpStructEndOmitEmptyStringPtrString OpType = 392 - OpStructFieldNumberPtrString OpType = 393 - OpStructFieldOmitEmptyNumberPtrString OpType = 394 - OpStructEndNumberPtrString OpType = 395 - OpStructEndOmitEmptyNumberPtrString OpType = 396 - OpStructField OpType = 397 - OpStructFieldOmitEmpty OpType = 398 - OpStructEnd OpType = 399 - OpStructEndOmitEmpty OpType = 400 -) - -func (t OpType) String() string { - if int(t) >= 401 { - return "" - } - return opTypeStrings[int(t)] -} - -func (t OpType) CodeType() CodeType { - if strings.Contains(t.String(), "Struct") { - if strings.Contains(t.String(), "End") { - return CodeStructEnd - } - return CodeStructField - } - switch t { - case OpArray, OpArrayPtr: - return CodeArrayHead - case OpArrayElem: - return CodeArrayElem - case OpSlice, OpSlicePtr: - return CodeSliceHead - case OpSliceElem: - return CodeSliceElem - case OpMap, OpMapPtr: - return CodeMapHead - case OpMapKey: - return CodeMapKey - case OpMapValue: - return CodeMapValue - case OpMapEnd: - return CodeMapEnd - } - - return CodeOp -} - -func (t OpType) HeadToPtrHead() OpType { - if strings.Index(t.String(), "PtrHead") > 0 { - return t - } - - idx := strings.Index(t.String(), "Head") - if idx == -1 { - return t - } - suffix := "PtrHead" + t.String()[idx+len("Head"):] - - const toPtrOffset = 2 - if strings.Contains(OpType(int(t)+toPtrOffset).String(), suffix) { - return OpType(int(t) + toPtrOffset) - } - return t -} - -func (t OpType) HeadToOmitEmptyHead() OpType { - const toOmitEmptyOffset = 1 - if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") { - return OpType(int(t) + toOmitEmptyOffset) - } - - return t -} - -func (t OpType) PtrHeadToHead() OpType { - idx := strings.Index(t.String(), "Ptr") - if idx == -1 { - return t - } - suffix := t.String()[idx+len("Ptr"):] - - const toPtrOffset = 2 - if strings.Contains(OpType(int(t)-toPtrOffset).String(), suffix) { - return OpType(int(t) - toPtrOffset) - } - return t -} - -func (t OpType) FieldToEnd() OpType { - idx := strings.Index(t.String(), "Field") - if idx == -1 { - return t - } - suffix := t.String()[idx+len("Field"):] - if suffix == "" || suffix == "OmitEmpty" { - return t - } - const toEndOffset = 2 - if strings.Contains(OpType(int(t)+toEndOffset).String(), "End"+suffix) { - return OpType(int(t) + toEndOffset) - } - return t -} - -func (t OpType) FieldToOmitEmptyField() OpType { - const toOmitEmptyOffset = 1 - if strings.Contains(OpType(int(t)+toOmitEmptyOffset).String(), "OmitEmpty") { - return OpType(int(t) + toOmitEmptyOffset) - } - return t -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/string.go b/vendor/github.com/goccy/go-json/internal/encoder/string.go deleted file mode 100644 index a699dba19..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/string.go +++ /dev/null @@ -1,640 +0,0 @@ -package encoder - -import ( - "math/bits" - "reflect" - "unicode/utf8" - "unsafe" -) - -const ( - lsb = 0x0101010101010101 - msb = 0x8080808080808080 -) - -var needEscapeWithHTML = [256]bool{ - '"': true, - '&': true, - '<': true, - '>': true, - '\\': true, - 0x00: true, - 0x01: true, - 0x02: true, - 0x03: true, - 0x04: true, - 0x05: true, - 0x06: true, - 0x07: true, - 0x08: true, - 0x09: true, - 0x0a: true, - 0x0b: true, - 0x0c: true, - 0x0d: true, - 0x0e: true, - 0x0f: true, - 0x10: true, - 0x11: true, - 0x12: true, - 0x13: true, - 0x14: true, - 0x15: true, - 0x16: true, - 0x17: true, - 0x18: true, - 0x19: true, - 0x1a: true, - 0x1b: true, - 0x1c: true, - 0x1d: true, - 0x1e: true, - 0x1f: true, - /* 0x20 - 0x7f */ - 0x80: true, - 0x81: true, - 0x82: true, - 0x83: true, - 0x84: true, - 0x85: true, - 0x86: true, - 0x87: true, - 0x88: true, - 0x89: true, - 0x8a: true, - 0x8b: true, - 0x8c: true, - 0x8d: true, - 0x8e: true, - 0x8f: true, - 0x90: true, - 0x91: true, - 0x92: true, - 0x93: true, - 0x94: true, - 0x95: true, - 0x96: true, - 0x97: true, - 0x98: true, - 0x99: true, - 0x9a: true, - 0x9b: true, - 0x9c: true, - 0x9d: true, - 0x9e: true, - 0x9f: true, - 0xa0: true, - 0xa1: true, - 0xa2: true, - 0xa3: true, - 0xa4: true, - 0xa5: true, - 0xa6: true, - 0xa7: true, - 0xa8: true, - 0xa9: true, - 0xaa: true, - 0xab: true, - 0xac: true, - 0xad: true, - 0xae: true, - 0xaf: true, - 0xb0: true, - 0xb1: true, - 0xb2: true, - 0xb3: true, - 0xb4: true, - 0xb5: true, - 0xb6: true, - 0xb7: true, - 0xb8: true, - 0xb9: true, - 0xba: true, - 0xbb: true, - 0xbc: true, - 0xbd: true, - 0xbe: true, - 0xbf: true, - 0xc0: true, - 0xc1: true, - 0xc2: true, - 0xc3: true, - 0xc4: true, - 0xc5: true, - 0xc6: true, - 0xc7: true, - 0xc8: true, - 0xc9: true, - 0xca: true, - 0xcb: true, - 0xcc: true, - 0xcd: true, - 0xce: true, - 0xcf: true, - 0xd0: true, - 0xd1: true, - 0xd2: true, - 0xd3: true, - 0xd4: true, - 0xd5: true, - 0xd6: true, - 0xd7: true, - 0xd8: true, - 0xd9: true, - 0xda: true, - 0xdb: true, - 0xdc: true, - 0xdd: true, - 0xde: true, - 0xdf: true, - 0xe0: true, - 0xe1: true, - 0xe2: true, - 0xe3: true, - 0xe4: true, - 0xe5: true, - 0xe6: true, - 0xe7: true, - 0xe8: true, - 0xe9: true, - 0xea: true, - 0xeb: true, - 0xec: true, - 0xed: true, - 0xee: true, - 0xef: true, - 0xf0: true, - 0xf1: true, - 0xf2: true, - 0xf3: true, - 0xf4: true, - 0xf5: true, - 0xf6: true, - 0xf7: true, - 0xf8: true, - 0xf9: true, - 0xfa: true, - 0xfb: true, - 0xfc: true, - 0xfd: true, - 0xfe: true, - 0xff: true, -} - -var needEscape = [256]bool{ - '"': true, - '\\': true, - 0x00: true, - 0x01: true, - 0x02: true, - 0x03: true, - 0x04: true, - 0x05: true, - 0x06: true, - 0x07: true, - 0x08: true, - 0x09: true, - 0x0a: true, - 0x0b: true, - 0x0c: true, - 0x0d: true, - 0x0e: true, - 0x0f: true, - 0x10: true, - 0x11: true, - 0x12: true, - 0x13: true, - 0x14: true, - 0x15: true, - 0x16: true, - 0x17: true, - 0x18: true, - 0x19: true, - 0x1a: true, - 0x1b: true, - 0x1c: true, - 0x1d: true, - 0x1e: true, - 0x1f: true, - /* 0x20 - 0x7f */ - 0x80: true, - 0x81: true, - 0x82: true, - 0x83: true, - 0x84: true, - 0x85: true, - 0x86: true, - 0x87: true, - 0x88: true, - 0x89: true, - 0x8a: true, - 0x8b: true, - 0x8c: true, - 0x8d: true, - 0x8e: true, - 0x8f: true, - 0x90: true, - 0x91: true, - 0x92: true, - 0x93: true, - 0x94: true, - 0x95: true, - 0x96: true, - 0x97: true, - 0x98: true, - 0x99: true, - 0x9a: true, - 0x9b: true, - 0x9c: true, - 0x9d: true, - 0x9e: true, - 0x9f: true, - 0xa0: true, - 0xa1: true, - 0xa2: true, - 0xa3: true, - 0xa4: true, - 0xa5: true, - 0xa6: true, - 0xa7: true, - 0xa8: true, - 0xa9: true, - 0xaa: true, - 0xab: true, - 0xac: true, - 0xad: true, - 0xae: true, - 0xaf: true, - 0xb0: true, - 0xb1: true, - 0xb2: true, - 0xb3: true, - 0xb4: true, - 0xb5: true, - 0xb6: true, - 0xb7: true, - 0xb8: true, - 0xb9: true, - 0xba: true, - 0xbb: true, - 0xbc: true, - 0xbd: true, - 0xbe: true, - 0xbf: true, - 0xc0: true, - 0xc1: true, - 0xc2: true, - 0xc3: true, - 0xc4: true, - 0xc5: true, - 0xc6: true, - 0xc7: true, - 0xc8: true, - 0xc9: true, - 0xca: true, - 0xcb: true, - 0xcc: true, - 0xcd: true, - 0xce: true, - 0xcf: true, - 0xd0: true, - 0xd1: true, - 0xd2: true, - 0xd3: true, - 0xd4: true, - 0xd5: true, - 0xd6: true, - 0xd7: true, - 0xd8: true, - 0xd9: true, - 0xda: true, - 0xdb: true, - 0xdc: true, - 0xdd: true, - 0xde: true, - 0xdf: true, - 0xe0: true, - 0xe1: true, - 0xe2: true, - 0xe3: true, - 0xe4: true, - 0xe5: true, - 0xe6: true, - 0xe7: true, - 0xe8: true, - 0xe9: true, - 0xea: true, - 0xeb: true, - 0xec: true, - 0xed: true, - 0xee: true, - 0xef: true, - 0xf0: true, - 0xf1: true, - 0xf2: true, - 0xf3: true, - 0xf4: true, - 0xf5: true, - 0xf6: true, - 0xf7: true, - 0xf8: true, - 0xf9: true, - 0xfa: true, - 0xfb: true, - 0xfc: true, - 0xfd: true, - 0xfe: true, - 0xff: true, -} - -var hex = "0123456789abcdef" - -// escapeIndex finds the index of the first char in `s` that requires escaping. -// A char requires escaping if it's outside of the range of [0x20, 0x7F] or if -// it includes a double quote or backslash. -// If no chars in `s` require escaping, the return value is -1. -func escapeIndex(s string) int { - chunks := stringToUint64Slice(s) - for _, n := range chunks { - // combine masks before checking for the MSB of each byte. We include - // `n` in the mask to check whether any of the *input* byte MSBs were - // set (i.e. the byte was outside the ASCII range). - mask := n | below(n, 0x20) | contains(n, '"') | contains(n, '\\') - if (mask & msb) != 0 { - return bits.TrailingZeros64(mask&msb) / 8 - } - } - - valLen := len(s) - for i := len(chunks) * 8; i < valLen; i++ { - if needEscape[s[i]] { - return i - } - } - - return -1 -} - -// below return a mask that can be used to determine if any of the bytes -// in `n` are below `b`. If a byte's MSB is set in the mask then that byte was -// below `b`. The result is only valid if `b`, and each byte in `n`, is below -// 0x80. -func below(n uint64, b byte) uint64 { - return n - expand(b) -} - -// contains returns a mask that can be used to determine if any of the -// bytes in `n` are equal to `b`. If a byte's MSB is set in the mask then -// that byte is equal to `b`. The result is only valid if `b`, and each -// byte in `n`, is below 0x80. -func contains(n uint64, b byte) uint64 { - return (n ^ expand(b)) - lsb -} - -// expand puts the specified byte into each of the 8 bytes of a uint64. -func expand(b byte) uint64 { - return lsb * uint64(b) -} - -//nolint:govet -func stringToUint64Slice(s string) []uint64 { - return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{ - Data: ((*reflect.StringHeader)(unsafe.Pointer(&s))).Data, - Len: len(s) / 8, - Cap: len(s) / 8, - })) -} - -func AppendString(ctx *RuntimeContext, buf []byte, s string) []byte { - if ctx.Option.Flag&HTMLEscapeOption == 0 { - return appendString(buf, s) - } - valLen := len(s) - if valLen == 0 { - return append(buf, `""`...) - } - buf = append(buf, '"') - var ( - i, j int - ) - if valLen >= 8 { - chunks := stringToUint64Slice(s) - for _, n := range chunks { - // combine masks before checking for the MSB of each byte. We include - // `n` in the mask to check whether any of the *input* byte MSBs were - // set (i.e. the byte was outside the ASCII range). - mask := n | (n - (lsb * 0x20)) | - ((n ^ (lsb * '"')) - lsb) | - ((n ^ (lsb * '\\')) - lsb) | - ((n ^ (lsb * '<')) - lsb) | - ((n ^ (lsb * '>')) - lsb) | - ((n ^ (lsb * '&')) - lsb) - if (mask & msb) != 0 { - j = bits.TrailingZeros64(mask&msb) / 8 - goto ESCAPE_END - } - } - for i := len(chunks) * 8; i < valLen; i++ { - if needEscapeWithHTML[s[i]] { - j = i - goto ESCAPE_END - } - } - // no found any escape characters. - return append(append(buf, s...), '"') - } -ESCAPE_END: - for j < valLen { - c := s[j] - - if !needEscapeWithHTML[c] { - // fast path: most of the time, printable ascii characters are used - j++ - continue - } - - switch c { - case '\\', '"': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', c) - i = j + 1 - j = j + 1 - continue - - case '\n': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 'n') - i = j + 1 - j = j + 1 - continue - - case '\r': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 'r') - i = j + 1 - j = j + 1 - continue - - case '\t': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 't') - i = j + 1 - j = j + 1 - continue - - case '<', '>', '&': - buf = append(buf, s[i:j]...) - buf = append(buf, `\u00`...) - buf = append(buf, hex[c>>4], hex[c&0xF]) - i = j + 1 - j = j + 1 - continue - } - - // This encodes bytes < 0x20 except for \t, \n and \r. - if c < 0x20 { - buf = append(buf, s[i:j]...) - buf = append(buf, `\u00`...) - buf = append(buf, hex[c>>4], hex[c&0xF]) - i = j + 1 - j = j + 1 - continue - } - - r, size := utf8.DecodeRuneInString(s[j:]) - - if r == utf8.RuneError && size == 1 { - buf = append(buf, s[i:j]...) - buf = append(buf, `\ufffd`...) - i = j + size - j = j + size - continue - } - - switch r { - case '\u2028', '\u2029': - // U+2028 is LINE SEPARATOR. - // U+2029 is PARAGRAPH SEPARATOR. - // They are both technically valid characters in JSON strings, - // but don't work in JSONP, which has to be evaluated as JavaScript, - // and can lead to security holes there. It is valid JSON to - // escape them, so we do so unconditionally. - // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion. - buf = append(buf, s[i:j]...) - buf = append(buf, `\u202`...) - buf = append(buf, hex[r&0xF]) - i = j + size - j = j + size - continue - } - - j += size - } - - return append(append(buf, s[i:]...), '"') -} - -func appendString(buf []byte, s string) []byte { - valLen := len(s) - if valLen == 0 { - return append(buf, `""`...) - } - buf = append(buf, '"') - var escapeIdx int - if valLen >= 8 { - if escapeIdx = escapeIndex(s); escapeIdx < 0 { - return append(append(buf, s...), '"') - } - } - - i := 0 - j := escapeIdx - for j < valLen { - c := s[j] - - if c >= 0x20 && c <= 0x7f && c != '\\' && c != '"' { - // fast path: most of the time, printable ascii characters are used - j++ - continue - } - - switch c { - case '\\', '"': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', c) - i = j + 1 - j = j + 1 - continue - - case '\n': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 'n') - i = j + 1 - j = j + 1 - continue - - case '\r': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 'r') - i = j + 1 - j = j + 1 - continue - - case '\t': - buf = append(buf, s[i:j]...) - buf = append(buf, '\\', 't') - i = j + 1 - j = j + 1 - continue - - case '<', '>', '&': - buf = append(buf, s[i:j]...) - buf = append(buf, `\u00`...) - buf = append(buf, hex[c>>4], hex[c&0xF]) - i = j + 1 - j = j + 1 - continue - } - - // This encodes bytes < 0x20 except for \t, \n and \r. - if c < 0x20 { - buf = append(buf, s[i:j]...) - buf = append(buf, `\u00`...) - buf = append(buf, hex[c>>4], hex[c&0xF]) - i = j + 1 - j = j + 1 - continue - } - - r, size := utf8.DecodeRuneInString(s[j:]) - - if r == utf8.RuneError && size == 1 { - buf = append(buf, s[i:j]...) - buf = append(buf, `\ufffd`...) - i = j + size - j = j + size - continue - } - - switch r { - case '\u2028', '\u2029': - // U+2028 is LINE SEPARATOR. - // U+2029 is PARAGRAPH SEPARATOR. - // They are both technically valid characters in JSON strings, - // but don't work in JSONP, which has to be evaluated as JavaScript, - // and can lead to security holes there. It is valid JSON to - // escape them, so we do so unconditionally. - // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion. - buf = append(buf, s[i:j]...) - buf = append(buf, `\u202`...) - buf = append(buf, hex[r&0xF]) - i = j + size - j = j + size - continue - } - - j += size - } - - return append(append(buf, s[i:]...), '"') -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go deleted file mode 100644 index 05509feda..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/debug_vm.go +++ /dev/null @@ -1,34 +0,0 @@ -package vm - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - defer func() { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - if err := recover(); err != nil { - fmt.Println("=============[DEBUG]===============") - fmt.Println("* [TYPE]") - fmt.Println(codeSet.Type) - fmt.Printf("\n") - fmt.Println("* [ALL OPCODE]") - fmt.Println(code.Dump()) - fmt.Printf("\n") - fmt.Println("* [CONTEXT]") - fmt.Printf("%+v\n", ctx) - fmt.Println("===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go deleted file mode 100644 index 65252b4a5..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_indent" -) diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go deleted file mode 100644 index f06f9c8c4..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/util.go +++ /dev/null @@ -1,191 +0,0 @@ -package vm - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendInt = encoder.AppendInt - appendUint = encoder.AppendUint - appendFloat32 = encoder.AppendFloat32 - appendFloat64 = encoder.AppendFloat64 - appendString = encoder.AppendString - appendByteSlice = encoder.AppendByteSlice - appendNumber = encoder.AppendNumber - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder: opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } -func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } -func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } -func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendBool(_ *encoder.RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -func appendNull(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -func appendComma(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ',') -} - -func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - last := len(b) - 1 - b[last] = ':' - return b -} - -func appendMapKeyValue(_ *encoder.RuntimeContext, _ *encoder.Opcode, b, key, value []byte) []byte { - b = append(b, key...) - b[len(b)-1] = ':' - return append(b, value...) -} - -func appendMapEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - b[len(b)-1] = '}' - b = append(b, ',') - return b -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSON(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalText(ctx, code, b, v) -} - -func appendArrayHead(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '[') -} - -func appendArrayEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = ']' - return append(b, ',') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',') -} - -func appendObjectEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - return append(b, ',') -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{') -} - -func appendStructKey(_ *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return append(b, code.Key...) -} - -func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '}', ',') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last] == ',' { - b[last] = '}' - return appendComma(ctx, b) - } - return appendStructEnd(ctx, code, b) -} - -func restoreIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, _ uintptr) {} -func storeIndent(_ uintptr, _ *encoder.Opcode, _ uintptr) {} -func appendMapKeyIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } -func appendArrayElemIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go deleted file mode 100644 index 5857249da..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm/vm.go +++ /dev/null @@ -1,5056 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm - -import ( - "math" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInt: - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpUint: - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintString: - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.itab.typ - } else { - iface := (*emptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.typ - } - if ifacePtr == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - break - } - b = appendStructHead(ctx, b) - iter := mapiterinit(code.Type, uptr) - ctx.KeepRefs = append(ctx.KeepRefs, iter) - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(mlen)) - store(ctxptr, code.MapIter, uintptr(iter)) - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx := encoder.NewMapContext(mlen) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - case encoder.OpMapKey: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < length { - b = appendMapKeyIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - b = appendObjectEnd(ctx, code, b) - code = code.End.Next - } - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.ElemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - case encoder.OpMapValue: - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendColon(ctx, b) - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - } - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - length := int(load(ctxptr, code.Length)) - ptr := load(ctxptr, code.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.Pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ - Key: b[startKey:startValue], - Value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.Slice) - buf := mapCtx.Buf - for _, item := range mapCtx.Slice.Items { - buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value) - } - buf = appendMapEnd(ctx, code, buf) - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructAnonymousEnd: - code = code.Next - case encoder.OpStructEnd: - b = appendStructEndSkipLast(ctx, code, b) - code = code.Next - case encoder.OpStructEndInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go deleted file mode 100644 index 6a6a33d22..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/debug_vm.go +++ /dev/null @@ -1,34 +0,0 @@ -package vm_color - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - defer func() { - if err := recover(); err != nil { - fmt.Println("=============[DEBUG]===============") - fmt.Println("* [TYPE]") - fmt.Println(codeSet.Type) - fmt.Printf("\n") - fmt.Println("* [ALL OPCODE]") - fmt.Println(code.Dump()) - fmt.Printf("\n") - fmt.Println("* [CONTEXT]") - fmt.Printf("%+v\n", ctx) - fmt.Println("===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go deleted file mode 100644 index 12ec56c5b..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm_color - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_color_indent" -) diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go deleted file mode 100644 index 710087f64..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/util.go +++ /dev/null @@ -1,255 +0,0 @@ -package vm_color - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder: opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } -func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } -func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } -func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendInt(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - b = encoder.AppendInt(ctx, b, v, code) - return append(b, format.Footer...) -} - -func appendUint(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Uint - b = append(b, format.Header...) - b = encoder.AppendUint(ctx, b, v, code) - return append(b, format.Footer...) -} - -func appendFloat32(ctx *encoder.RuntimeContext, b []byte, v float32) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat32(ctx, b, v) - return append(b, format.Footer...) -} - -func appendFloat64(ctx *encoder.RuntimeContext, b []byte, v float64) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat64(ctx, b, v) - return append(b, format.Footer...) -} - -func appendString(ctx *encoder.RuntimeContext, b []byte, v string) []byte { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - b = encoder.AppendString(ctx, b, v) - return append(b, format.Footer...) -} - -func appendByteSlice(ctx *encoder.RuntimeContext, b []byte, src []byte) []byte { - format := ctx.Option.ColorScheme.Binary - b = append(b, format.Header...) - b = encoder.AppendByteSlice(ctx, b, src) - return append(b, format.Footer...) -} - -func appendNumber(ctx *encoder.RuntimeContext, b []byte, n json.Number) ([]byte, error) { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - bb, err := encoder.AppendNumber(ctx, b, n) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendBool(ctx *encoder.RuntimeContext, b []byte, v bool) []byte { - format := ctx.Option.ColorScheme.Bool - b = append(b, format.Header...) - if v { - b = append(b, "true"...) - } else { - b = append(b, "false"...) - } - return append(b, format.Footer...) -} - -func appendNull(ctx *encoder.RuntimeContext, b []byte) []byte { - format := ctx.Option.ColorScheme.Null - b = append(b, format.Header...) - b = append(b, "null"...) - return append(b, format.Footer...) -} - -func appendComma(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ',') -} - -func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - last := len(b) - 1 - b[last] = ':' - return b -} - -func appendMapKeyValue(_ *encoder.RuntimeContext, _ *encoder.Opcode, b, key, value []byte) []byte { - b = append(b, key[:len(key)-1]...) - b = append(b, ':') - return append(b, value...) -} - -func appendMapEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - b = append(b, ',') - return b -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSON(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - bb, err := encoder.AppendMarshalText(ctx, code, b, v) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendArrayHead(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '[') -} - -func appendArrayEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = ']' - return append(b, ',') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',') -} - -func appendObjectEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '}' - return append(b, ',') -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - format := ctx.Option.ColorScheme.ObjectKey - b = append(b, format.Header...) - b = append(b, code.Key[:len(code.Key)-1]...) - b = append(b, format.Footer...) - - return append(b, ':') -} - -func appendStructEnd(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { - return append(b, '}', ',') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last] == ',' { - b[last] = '}' - return appendComma(ctx, b) - } - return appendStructEnd(ctx, code, b) -} - -func restoreIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, _ uintptr) {} -func storeIndent(_ uintptr, _ *encoder.Opcode, _ uintptr) {} -func appendMapKeyIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } -func appendArrayElemIndent(_ *encoder.RuntimeContext, _ *encoder.Opcode, b []byte) []byte { return b } diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go deleted file mode 100644 index 73af8842e..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color/vm.go +++ /dev/null @@ -1,5056 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_color - -import ( - "math" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInt: - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpUint: - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintString: - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.itab.typ - } else { - iface := (*emptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.typ - } - if ifacePtr == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - break - } - b = appendStructHead(ctx, b) - iter := mapiterinit(code.Type, uptr) - ctx.KeepRefs = append(ctx.KeepRefs, iter) - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(mlen)) - store(ctxptr, code.MapIter, uintptr(iter)) - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx := encoder.NewMapContext(mlen) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - case encoder.OpMapKey: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < length { - b = appendMapKeyIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - b = appendObjectEnd(ctx, code, b) - code = code.End.Next - } - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.ElemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - case encoder.OpMapValue: - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendColon(ctx, b) - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - } - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - length := int(load(ctxptr, code.Length)) - ptr := load(ctxptr, code.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.Pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ - Key: b[startKey:startValue], - Value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.Slice) - buf := mapCtx.Buf - for _, item := range mapCtx.Slice.Items { - buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value) - } - buf = appendMapEnd(ctx, code, buf) - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructAnonymousEnd: - code = code.Next - case encoder.OpStructEnd: - b = appendStructEndSkipLast(ctx, code, b) - code = code.Next - case encoder.OpStructEndInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go deleted file mode 100644 index a68bbf6bf..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/debug_vm.go +++ /dev/null @@ -1,34 +0,0 @@ -package vm_color_indent - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - defer func() { - if err := recover(); err != nil { - fmt.Println("=============[DEBUG]===============") - fmt.Println("* [TYPE]") - fmt.Println(codeSet.Type) - fmt.Printf("\n") - fmt.Println("* [ALL OPCODE]") - fmt.Println(code.Dump()) - fmt.Printf("\n") - fmt.Println("* [CONTEXT]") - fmt.Printf("%+v\n", ctx) - fmt.Println("===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go deleted file mode 100644 index 1399a25b6..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/util.go +++ /dev/null @@ -1,276 +0,0 @@ -package vm_color_indent - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendIndent = encoder.AppendIndent - appendStructEnd = encoder.AppendStructEndIndent - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder (indent): opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } -func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } -func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } -func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendInt(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - b = encoder.AppendInt(ctx, b, v, code) - return append(b, format.Footer...) -} - -func appendUint(ctx *encoder.RuntimeContext, b []byte, v uint64, code *encoder.Opcode) []byte { - format := ctx.Option.ColorScheme.Uint - b = append(b, format.Header...) - b = encoder.AppendUint(ctx, b, v, code) - return append(b, format.Footer...) -} - -func appendFloat32(ctx *encoder.RuntimeContext, b []byte, v float32) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat32(ctx, b, v) - return append(b, format.Footer...) -} - -func appendFloat64(ctx *encoder.RuntimeContext, b []byte, v float64) []byte { - format := ctx.Option.ColorScheme.Float - b = append(b, format.Header...) - b = encoder.AppendFloat64(ctx, b, v) - return append(b, format.Footer...) -} - -func appendString(ctx *encoder.RuntimeContext, b []byte, v string) []byte { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - b = encoder.AppendString(ctx, b, v) - return append(b, format.Footer...) -} - -func appendByteSlice(ctx *encoder.RuntimeContext, b []byte, src []byte) []byte { - format := ctx.Option.ColorScheme.Binary - b = append(b, format.Header...) - b = encoder.AppendByteSlice(ctx, b, src) - return append(b, format.Footer...) -} - -func appendNumber(ctx *encoder.RuntimeContext, b []byte, n json.Number) ([]byte, error) { - format := ctx.Option.ColorScheme.Int - b = append(b, format.Header...) - bb, err := encoder.AppendNumber(ctx, b, n) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendBool(ctx *encoder.RuntimeContext, b []byte, v bool) []byte { - format := ctx.Option.ColorScheme.Bool - b = append(b, format.Header...) - if v { - b = append(b, "true"...) - } else { - b = append(b, "false"...) - } - return append(b, format.Footer...) -} - -func appendNull(ctx *encoder.RuntimeContext, b []byte) []byte { - format := ctx.Option.ColorScheme.Null - b = append(b, format.Header...) - b = append(b, "null"...) - return append(b, format.Footer...) -} - -func appendComma(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ',', '\n') -} - -func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ':', ' ') -} - -func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { - b = appendIndent(ctx, b, code.Indent+1) - b = append(b, key...) - b[len(b)-2] = ':' - b[len(b)-1] = ' ' - return append(b, value...) -} - -func appendMapEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, '}', ',', '\n') -} - -func appendArrayHead(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = append(b, '[', '\n') - return appendIndent(ctx, b, code.Indent+1) -} - -func appendArrayEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, ']', ',', '\n') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',', '\n') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',', '\n') -} - -func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.Indent-1) - return append(b, '}', ',', '\n') -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSONIndent(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - format := ctx.Option.ColorScheme.String - b = append(b, format.Header...) - bb, err := encoder.AppendMarshalTextIndent(ctx, code, b, v) - if err != nil { - return nil, err - } - return append(bb, format.Footer...), nil -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '\n') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = appendIndent(ctx, b, code.Indent) - - format := ctx.Option.ColorScheme.ObjectKey - b = append(b, format.Header...) - b = append(b, code.Key[:len(code.Key)-1]...) - b = append(b, format.Footer...) - - return append(b, ':', ' ') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent-1) - b = append(b, '}') - } - return appendComma(ctx, b) -} - -func restoreIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, ctxptr uintptr) { - ctx.BaseIndent = uint32(load(ctxptr, code.Length)) -} - -func storeIndent(ctxptr uintptr, code *encoder.Opcode, indent uintptr) { - store(ctxptr, code.Length, indent) -} - -func appendArrayElemIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent+1) -} - -func appendMapKeyIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go deleted file mode 100644 index 7b7844ec5..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_color_indent/vm.go +++ /dev/null @@ -1,5056 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_color_indent - -import ( - "math" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInt: - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpUint: - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintString: - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.itab.typ - } else { - iface := (*emptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.typ - } - if ifacePtr == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - break - } - b = appendStructHead(ctx, b) - iter := mapiterinit(code.Type, uptr) - ctx.KeepRefs = append(ctx.KeepRefs, iter) - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(mlen)) - store(ctxptr, code.MapIter, uintptr(iter)) - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx := encoder.NewMapContext(mlen) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - case encoder.OpMapKey: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < length { - b = appendMapKeyIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - b = appendObjectEnd(ctx, code, b) - code = code.End.Next - } - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.ElemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - case encoder.OpMapValue: - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendColon(ctx, b) - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - } - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - length := int(load(ctxptr, code.Length)) - ptr := load(ctxptr, code.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.Pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ - Key: b[startKey:startValue], - Value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.Slice) - buf := mapCtx.Buf - for _, item := range mapCtx.Slice.Items { - buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value) - } - buf = appendMapEnd(ctx, code, buf) - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructAnonymousEnd: - code = code.Next - case encoder.OpStructEnd: - b = appendStructEndSkipLast(ctx, code, b) - code = code.Next - case encoder.OpStructEndInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go deleted file mode 100644 index 4cfd17ab2..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/debug_vm.go +++ /dev/null @@ -1,34 +0,0 @@ -package vm_indent - -import ( - "fmt" - - "github.com/goccy/go-json/internal/encoder" -) - -func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - defer func() { - if err := recover(); err != nil { - fmt.Println("=============[DEBUG]===============") - fmt.Println("* [TYPE]") - fmt.Println(codeSet.Type) - fmt.Printf("\n") - fmt.Println("* [ALL OPCODE]") - fmt.Println(code.Dump()) - fmt.Printf("\n") - fmt.Println("* [CONTEXT]") - fmt.Printf("%+v\n", ctx) - fmt.Println("===================================") - panic(err) - } - }() - - return Run(ctx, b, codeSet) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go deleted file mode 100644 index 9e245bfe5..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/hack.go +++ /dev/null @@ -1,9 +0,0 @@ -package vm_indent - -import ( - // HACK: compile order - // `vm`, `vm_indent`, `vm_color`, `vm_color_indent` packages uses a lot of memory to compile, - // so forcibly make dependencies and avoid compiling in concurrent. - // dependency order: vm => vm_indent => vm_color => vm_color_indent - _ "github.com/goccy/go-json/internal/encoder/vm_color" -) diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go deleted file mode 100644 index 2e3c35fb9..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/util.go +++ /dev/null @@ -1,213 +0,0 @@ -package vm_indent - -import ( - "encoding/json" - "fmt" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -const uintptrSize = 4 << (^uintptr(0) >> 63) - -var ( - appendInt = encoder.AppendInt - appendUint = encoder.AppendUint - appendFloat32 = encoder.AppendFloat32 - appendFloat64 = encoder.AppendFloat64 - appendString = encoder.AppendString - appendByteSlice = encoder.AppendByteSlice - appendNumber = encoder.AppendNumber - appendStructEnd = encoder.AppendStructEndIndent - appendIndent = encoder.AppendIndent - errUnsupportedValue = encoder.ErrUnsupportedValue - errUnsupportedFloat = encoder.ErrUnsupportedFloat - mapiterinit = encoder.MapIterInit - mapiterkey = encoder.MapIterKey - mapitervalue = encoder.MapIterValue - mapiternext = encoder.MapIterNext - maplen = encoder.MapLen -) - -type emptyInterface struct { - typ *runtime.Type - ptr unsafe.Pointer -} - -type nonEmptyInterface struct { - itab *struct { - ityp *runtime.Type // static interface type - typ *runtime.Type // dynamic concrete type - // unused fields... - } - ptr unsafe.Pointer -} - -func errUnimplementedOp(op encoder.OpType) error { - return fmt.Errorf("encoder (indent): opcode %s has not been implemented", op) -} - -func load(base uintptr, idx uint32) uintptr { - addr := base + uintptr(idx) - return **(**uintptr)(unsafe.Pointer(&addr)) -} - -func store(base uintptr, idx uint32, p uintptr) { - addr := base + uintptr(idx) - **(**uintptr)(unsafe.Pointer(&addr)) = p -} - -func loadNPtr(base uintptr, idx uint32, ptrNum uint8) uintptr { - addr := base + uintptr(idx) - p := **(**uintptr)(unsafe.Pointer(&addr)) - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) } -func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) } -func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) } -func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) } -func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) } -func ptrToNumber(p uintptr) json.Number { return **(**json.Number)(unsafe.Pointer(&p)) } -func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) } -func ptrToSlice(p uintptr) *runtime.SliceHeader { return *(**runtime.SliceHeader)(unsafe.Pointer(&p)) } -func ptrToPtr(p uintptr) uintptr { - return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p))) -} -func ptrToNPtr(p uintptr, ptrNum uint8) uintptr { - for i := uint8(0); i < ptrNum; i++ { - if p == 0 { - return 0 - } - p = ptrToPtr(p) - } - return p -} - -func ptrToUnsafePtr(p uintptr) unsafe.Pointer { - return *(*unsafe.Pointer)(unsafe.Pointer(&p)) -} -func ptrToInterface(code *encoder.Opcode, p uintptr) interface{} { - return *(*interface{})(unsafe.Pointer(&emptyInterface{ - typ: code.Type, - ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)), - })) -} - -func appendBool(_ *encoder.RuntimeContext, b []byte, v bool) []byte { - if v { - return append(b, "true"...) - } - return append(b, "false"...) -} - -func appendNull(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, "null"...) -} - -func appendComma(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ',', '\n') -} - -func appendColon(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, ':', ' ') -} - -func appendMapKeyValue(ctx *encoder.RuntimeContext, code *encoder.Opcode, b, key, value []byte) []byte { - b = appendIndent(ctx, b, code.Indent+1) - b = append(b, key...) - b[len(b)-2] = ':' - b[len(b)-1] = ' ' - return append(b, value...) -} - -func appendMapEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, '}', ',', '\n') -} - -func appendArrayHead(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = append(b, '[', '\n') - return appendIndent(ctx, b, code.Indent+1) -} - -func appendArrayEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = b[:len(b)-2] - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent) - return append(b, ']', ',', '\n') -} - -func appendEmptyArray(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '[', ']', ',', '\n') -} - -func appendEmptyObject(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '}', ',', '\n') -} - -func appendObjectEnd(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - b[last] = '\n' - b = appendIndent(ctx, b, code.Indent-1) - return append(b, '}', ',', '\n') -} - -func appendMarshalJSON(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalJSONIndent(ctx, code, b, v) -} - -func appendMarshalText(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte, v interface{}) ([]byte, error) { - return encoder.AppendMarshalTextIndent(ctx, code, b, v) -} - -func appendStructHead(_ *encoder.RuntimeContext, b []byte) []byte { - return append(b, '{', '\n') -} - -func appendStructKey(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - b = appendIndent(ctx, b, code.Indent) - b = append(b, code.Key...) - return append(b, ' ') -} - -func appendStructEndSkipLast(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - last := len(b) - 1 - if b[last-1] == '{' { - b[last] = '}' - } else { - if b[last] == '\n' { - // to remove ',' and '\n' characters - b = b[:len(b)-2] - } - b = append(b, '\n') - b = appendIndent(ctx, b, code.Indent-1) - b = append(b, '}') - } - return appendComma(ctx, b) -} - -func restoreIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, ctxptr uintptr) { - ctx.BaseIndent = uint32(load(ctxptr, code.Length)) -} - -func storeIndent(ctxptr uintptr, code *encoder.Opcode, indent uintptr) { - store(ctxptr, code.Length, indent) -} - -func appendArrayElemIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent+1) -} - -func appendMapKeyIndent(ctx *encoder.RuntimeContext, code *encoder.Opcode, b []byte) []byte { - return appendIndent(ctx, b, code.Indent) -} diff --git a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go b/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go deleted file mode 100644 index 6e05155f1..000000000 --- a/vendor/github.com/goccy/go-json/internal/encoder/vm_indent/vm.go +++ /dev/null @@ -1,5056 +0,0 @@ -// Code generated by internal/cmd/generator. DO NOT EDIT! -package vm_indent - -import ( - "math" - "sort" - "unsafe" - - "github.com/goccy/go-json/internal/encoder" - "github.com/goccy/go-json/internal/runtime" -) - -func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { - recursiveLevel := 0 - ptrOffset := uintptr(0) - ctxptr := ctx.Ptr() - var code *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - code = codeSet.EscapeKeyCode - } else { - code = codeSet.NoescapeKeyCode - } - - for { - switch code.Op { - default: - return nil, errUnimplementedOp(code.Op) - case encoder.OpPtr: - p := load(ctxptr, code.Idx) - code = code.Next - store(ctxptr, code.Idx, ptrToPtr(p)) - case encoder.OpIntPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInt: - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpUint: - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpIntString: - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpUintString: - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(load(ctxptr, code.Idx)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat32Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat32: - b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpFloat64Ptr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpFloat64: - v := ptrToFloat64(load(ctxptr, code.Idx)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStringPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpString: - b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBoolPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBool: - b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpBytesPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpBytes: - b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpNumberPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpNumber: - bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpInterfacePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpInterface: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if p == seen { - return nil, errUnsupportedValue(code, p) - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, p) - var ( - typ *runtime.Type - ifacePtr unsafe.Pointer - ) - up := ptrToUnsafePtr(p) - if code.Flags&encoder.NonEmptyInterfaceFlags != 0 { - iface := (*nonEmptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.itab.typ - } else { - iface := (*emptyInterface)(up) - ifacePtr = iface.ptr - typ = iface.typ - } - if ifacePtr == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - ctx.KeepRefs = append(ctx.KeepRefs, up) - ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ))) - if err != nil { - return nil, err - } - - totalLength := uintptr(code.Length) + 3 - nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3 - - var c *encoder.Opcode - if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { - c = ifaceCodeSet.InterfaceEscapeKeyCode - } else { - c = ifaceCodeSet.InterfaceNoescapeKeyCode - } - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += totalLength * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + totalLength + nextTotalLength - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - end := ifaceCodeSet.EndCode - store(ctxptr, c.Idx, uintptr(ifacePtr)) - store(ctxptr, end.Idx, oldOffset) - store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, end, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpInterfaceEnd: - recursiveLevel-- - - // restore ctxptr - offset := load(ctxptr, code.Idx) - restoreIndent(ctx, code, ctxptr) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToPtr(p)) - fallthrough - case encoder.OpMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - b = append(b, `""`...) - b = appendComma(ctx, b) - code = code.Next - break - } - if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p) - } - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpSlicePtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpSlice: - p := load(ctxptr, code.Idx) - slice := ptrToSlice(p) - if p == 0 || slice.Data == nil { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(slice.Len)) - store(ctxptr, code.Idx, uintptr(slice.Data)) - if slice.Len > 0 { - b = appendArrayHead(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, uintptr(slice.Data)) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpSliceElem: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if idx < length { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - data := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, data+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpArrayPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpArray: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - if code.Length > 0 { - b = appendArrayHead(ctx, code, b) - store(ctxptr, code.ElemIdx, 0) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - b = appendEmptyArray(ctx, b) - code = code.End.Next - } - case encoder.OpArrayElem: - idx := load(ctxptr, code.ElemIdx) - idx++ - if idx < uintptr(code.Length) { - b = appendArrayElemIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - p := load(ctxptr, code.Idx) - size := uintptr(code.Size) - code = code.Next - store(ctxptr, code.Idx, p+idx*size) - } else { - b = appendArrayEnd(ctx, code, b) - code = code.End.Next - } - case encoder.OpMapPtr: - p := loadNPtr(ctxptr, code.Idx, code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - store(ctxptr, code.Idx, p) - fallthrough - case encoder.OpMap: - p := load(ctxptr, code.Idx) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.End.Next - break - } - uptr := ptrToUnsafePtr(p) - mlen := maplen(uptr) - if mlen <= 0 { - b = appendEmptyObject(ctx, b) - code = code.End.Next - break - } - b = appendStructHead(ctx, b) - iter := mapiterinit(code.Type, uptr) - ctx.KeepRefs = append(ctx.KeepRefs, iter) - store(ctxptr, code.ElemIdx, 0) - store(ctxptr, code.Length, uintptr(mlen)) - store(ctxptr, code.MapIter, uintptr(iter)) - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendMapKeyIndent(ctx, code.Next, b) - } else { - mapCtx := encoder.NewMapContext(mlen) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx)) - store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx))) - } - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - case encoder.OpMapKey: - idx := load(ctxptr, code.ElemIdx) - length := load(ctxptr, code.Length) - idx++ - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - if idx < length { - b = appendMapKeyIndent(ctx, code, b) - store(ctxptr, code.ElemIdx, idx) - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - b = appendObjectEnd(ctx, code, b) - code = code.End.Next - } - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - if idx < length { - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - store(ctxptr, code.ElemIdx, idx) - key := mapiterkey(iter) - store(ctxptr, code.Next.Idx, uintptr(key)) - code = code.Next - } else { - code = code.End - } - } - case encoder.OpMapValue: - if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 { - b = appendColon(ctx, b) - } else { - ptr := load(ctxptr, code.End.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - mapCtx.Pos = append(mapCtx.Pos, len(b)) - } - ptr := load(ctxptr, code.MapIter) - iter := ptrToUnsafePtr(ptr) - value := mapitervalue(iter) - store(ctxptr, code.Next.Idx, uintptr(value)) - mapiternext(iter) - code = code.Next - case encoder.OpMapEnd: - // this operation only used by sorted map. - length := int(load(ctxptr, code.Length)) - ptr := load(ctxptr, code.MapPos) - mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr)) - pos := mapCtx.Pos - for i := 0; i < length; i++ { - startKey := pos[i*2] - startValue := pos[i*2+1] - var endValue int - if i+1 < length { - endValue = pos[i*2+2] - } else { - endValue = len(b) - } - mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{ - Key: b[startKey:startValue], - Value: b[startValue:endValue], - }) - } - sort.Sort(mapCtx.Slice) - buf := mapCtx.Buf - for _, item := range mapCtx.Slice.Items { - buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value) - } - buf = appendMapEnd(ctx, code, buf) - b = b[:pos[0]] - b = append(b, buf...) - mapCtx.Buf = buf - encoder.ReleaseMapContext(mapCtx) - code = code.Next - case encoder.OpRecursivePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - code = code.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpRecursive: - ptr := load(ctxptr, code.Idx) - if ptr != 0 { - if recursiveLevel > encoder.StartDetectingCyclesAfter { - for _, seen := range ctx.SeenPtr { - if ptr == seen { - return nil, errUnsupportedValue(code, ptr) - } - } - } - } - ctx.SeenPtr = append(ctx.SeenPtr, ptr) - c := code.Jmp.Code - curlen := uintptr(len(ctx.Ptrs)) - offsetNum := ptrOffset / uintptrSize - oldOffset := ptrOffset - ptrOffset += code.Jmp.CurLen * uintptrSize - oldBaseIndent := ctx.BaseIndent - indentDiffFromTop := c.Indent - 1 - ctx.BaseIndent += code.Indent - indentDiffFromTop - - newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen - if curlen < newLen { - ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...) - } - ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr - - store(ctxptr, c.Idx, ptr) - store(ctxptr, c.End.Next.Idx, oldOffset) - store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next))) - storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent)) - code = c - recursiveLevel++ - case encoder.OpRecursiveEnd: - recursiveLevel-- - - // restore ctxptr - restoreIndent(ctx, code, ctxptr) - offset := load(ctxptr, code.Idx) - ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1] - - codePtr := load(ctxptr, code.ElemIdx) - code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr)) - ctxptr = ctx.Ptr() + offset - ptrOffset = offset - case encoder.OpStructPtrHead: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHead: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if len(code.Key) > 0 { - if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - } - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmpty: - p := load(ctxptr, code.Idx) - if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyInt: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyInt: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyIntString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUint: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUint: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyUintString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat32(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64String: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToFloat64(p + uintptr(code.Offset)) - if v == 0 { - code = code.NextField - } else { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset))))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyStringString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToString(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBool: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBool: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - } else { - code = code.NextField - } - case encoder.OpStructPtrHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytes: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyBytes: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumber: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumber: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - } - case encoder.OpStructPtrHeadNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberString: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - v := ptrToNumber(p + uintptr(code.Offset)) - if v == "" { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructPtrHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadArray, encoder.OpStructHeadSlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyArray: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyArray: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptySlice: - if (code.Flags & encoder.IndirectFlags) != 0 { - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptySlice: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructPtrHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMap: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 { - p = ptrToPtr(p + uintptr(code.Offset)) - } - if maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - break - } - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 { - code = code.NextField - } else { - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructPtrHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - } - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText { - p = ptrToPtr(p + uintptr(code.Offset)) - } - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructPtrHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - b = appendStructKey(ctx, code, b) - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum)) - fallthrough - case encoder.OpStructHeadOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 { - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - } - code = code.End.Next - break - } - if (code.Flags & encoder.IndirectFlags) != 0 { - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - } - if code.Flags&encoder.AnonymousHeadFlags == 0 { - b = appendStructHead(ctx, b) - } - if p == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - b = appendComma(ctx, b) - code = code.Next - } - case encoder.OpStructField: - if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 { - b = appendStructKey(ctx, code, b) - } - p := load(ctxptr, code.Idx) + uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmpty: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - b = appendComma(ctx, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringString: - p := load(ctxptr, code.Idx) - s := ptrToString(p + uintptr(code.Offset)) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - b = appendStructKey(ctx, code, b) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendComma(ctx, b) - } - code = code.Next - case encoder.OpStructFieldMarshalJSON: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSON: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - iface := ptrToInterface(code, p) - if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, iface) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalJSONPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalJSONPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldMarshalText: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalText: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if (code.Flags & encoder.IsNilableTypeFlags) != 0 { - p = ptrToPtr(p) - } - if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 { - code = code.NextField - break - } - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - code = code.Next - case encoder.OpStructFieldMarshalTextPtr: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendComma(ctx, b) - code = code.Next - case encoder.OpStructFieldOmitEmptyMarshalTextPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p)) - if err != nil { - return nil, err - } - b = appendComma(ctx, bb) - } - code = code.Next - case encoder.OpStructFieldArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArray: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldArrayPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyArrayPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldSlice: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlice: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - slice := ptrToSlice(p) - if slice.Len == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldSlicePtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptySlicePtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldMap: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMap: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructFieldMapPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyMapPtr: - p := load(ctxptr, code.Idx) - p = ptrToPtr(p + uintptr(code.Offset)) - if p != 0 { - p = ptrToNPtr(p, code.PtrNum) - } - if p != 0 { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } else { - code = code.NextField - } - case encoder.OpStructFieldStruct: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - code = code.Next - store(ctxptr, code.Idx, p) - case encoder.OpStructFieldOmitEmptyStruct: - p := load(ctxptr, code.Idx) - p += uintptr(code.Offset) - if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 { - code = code.NextField - } else { - b = appendStructKey(ctx, code, b) - code = code.Next - store(ctxptr, code.Idx, p) - } - case encoder.OpStructAnonymousEnd: - code = code.Next - case encoder.OpStructEnd: - b = appendStructEndSkipLast(ctx, code, b) - code = code.Next - case encoder.OpStructEndInt: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyInt: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendInt(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendInt(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndIntPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyIntPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendInt(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUint: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUint: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, u64, code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p+uintptr(code.Offset)), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintString: - p := load(ctxptr, code.Idx) - u64 := ptrToUint64(p + uintptr(code.Offset)) - v := u64 & ((1 << code.NumBitSize) - 1) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, u64, code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendUint(ctx, b, ptrToUint64(p), code) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendUint(ctx, b, ptrToUint64(p), code) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndUintPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyUintPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendUint(ctx, b, ptrToUint64(p), code) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32String: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32String: - p := load(ctxptr, code.Idx) - v := ptrToFloat32(p + uintptr(code.Offset)) - if v != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendFloat32(ctx, b, ptrToFloat32(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat32PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat32PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat32(ctx, b, ptrToFloat32(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64String: - p := load(ctxptr, code.Idx) - v := ptrToFloat64(p + uintptr(code.Offset)) - if v != 0 { - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64Ptr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - b = appendStructEnd(ctx, code, b) - code = code.Next - break - } - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64Ptr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndFloat64PtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = appendFloat64(ctx, b, v) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyFloat64PtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - v := ptrToFloat64(p) - if math.IsInf(v, 0) || math.IsNaN(v) { - return nil, errUnsupportedFloat(v) - } - b = append(b, '"') - b = appendFloat64(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - s := ptrToString(p + uintptr(code.Offset)) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, s))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringString: - p := load(ctxptr, code.Idx) - v := ptrToString(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, v))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, ptrToString(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, ptrToString(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndStringPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyStringPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p)))) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBool: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBool: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset))) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolString: - p := load(ctxptr, code.Idx) - v := ptrToBool(p + uintptr(code.Offset)) - if v { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, v) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendBool(ctx, b, ptrToBool(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendBool(ctx, b, ptrToBool(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBoolPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBoolPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - b = appendBool(ctx, b, ptrToBool(p)) - b = append(b, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytes: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset))) - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytes: - p := load(ctxptr, code.Idx) - v := ptrToBytes(p + uintptr(code.Offset)) - if len(v) > 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, v) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndBytesPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = appendByteSlice(ctx, b, ptrToBytes(p)) - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyBytesPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = appendByteSlice(ctx, b, ptrToBytes(p)) - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumber: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - code = code.Next - case encoder.OpStructEndOmitEmptyNumber: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberString: - p := load(ctxptr, code.Idx) - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset))) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberString: - p := load(ctxptr, code.Idx) - v := ptrToNumber(p + uintptr(code.Offset)) - if v != "" { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, v) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtr: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = bb - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtr: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = appendStructEnd(ctx, code, bb) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpStructEndNumberPtrString: - b = appendStructKey(ctx, code, b) - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p == 0 { - b = appendNull(ctx, b) - } else { - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - } - b = appendStructEnd(ctx, code, b) - code = code.Next - case encoder.OpStructEndOmitEmptyNumberPtrString: - p := load(ctxptr, code.Idx) - p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum) - if p != 0 { - b = appendStructKey(ctx, code, b) - b = append(b, '"') - bb, err := appendNumber(ctx, b, ptrToNumber(p)) - if err != nil { - return nil, err - } - b = append(bb, '"') - b = appendStructEnd(ctx, code, b) - } else { - b = appendStructEndSkipLast(ctx, code, b) - } - code = code.Next - case encoder.OpEnd: - goto END - } - } -END: - return b, nil -} diff --git a/vendor/github.com/goccy/go-json/internal/errors/error.go b/vendor/github.com/goccy/go-json/internal/errors/error.go deleted file mode 100644 index d58e39f4e..000000000 --- a/vendor/github.com/goccy/go-json/internal/errors/error.go +++ /dev/null @@ -1,164 +0,0 @@ -package errors - -import ( - "fmt" - "reflect" - "strconv" -) - -type InvalidUTF8Error struct { - S string // the whole string value that caused the error -} - -func (e *InvalidUTF8Error) Error() string { - return fmt.Sprintf("json: invalid UTF-8 in string: %s", strconv.Quote(e.S)) -} - -type InvalidUnmarshalError struct { - Type reflect.Type -} - -func (e *InvalidUnmarshalError) Error() string { - if e.Type == nil { - return "json: Unmarshal(nil)" - } - - if e.Type.Kind() != reflect.Ptr { - return fmt.Sprintf("json: Unmarshal(non-pointer %s)", e.Type) - } - return fmt.Sprintf("json: Unmarshal(nil %s)", e.Type) -} - -// A MarshalerError represents an error from calling a MarshalJSON or MarshalText method. -type MarshalerError struct { - Type reflect.Type - Err error - sourceFunc string -} - -func (e *MarshalerError) Error() string { - srcFunc := e.sourceFunc - if srcFunc == "" { - srcFunc = "MarshalJSON" - } - return fmt.Sprintf("json: error calling %s for type %s: %s", srcFunc, e.Type, e.Err.Error()) -} - -// Unwrap returns the underlying error. -func (e *MarshalerError) Unwrap() error { return e.Err } - -// A SyntaxError is a description of a JSON syntax error. -type SyntaxError struct { - msg string // description of error - Offset int64 // error occurred after reading Offset bytes -} - -func (e *SyntaxError) Error() string { return e.msg } - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// -// Deprecated: No longer used; kept for compatibility. -type UnmarshalFieldError struct { - Key string - Type reflect.Type - Field reflect.StructField -} - -func (e *UnmarshalFieldError) Error() string { - return fmt.Sprintf("json: cannot unmarshal object key %s into unexported field %s of type %s", - strconv.Quote(e.Key), e.Field.Name, e.Type.String(), - ) -} - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError struct { - Value string // description of JSON value - "bool", "array", "number -5" - Type reflect.Type // type of Go value it could not be assigned to - Offset int64 // error occurred after reading Offset bytes - Struct string // name of the struct type containing the field - Field string // the full path from root node to the field -} - -func (e *UnmarshalTypeError) Error() string { - if e.Struct != "" || e.Field != "" { - return fmt.Sprintf("json: cannot unmarshal %s into Go struct field %s.%s of type %s", - e.Value, e.Struct, e.Field, e.Type, - ) - } - return fmt.Sprintf("json: cannot unmarshal %s into Go value of type %s", e.Value, e.Type) -} - -// An UnsupportedTypeError is returned by Marshal when attempting -// to encode an unsupported value type. -type UnsupportedTypeError struct { - Type reflect.Type -} - -func (e *UnsupportedTypeError) Error() string { - return fmt.Sprintf("json: unsupported type: %s", e.Type) -} - -type UnsupportedValueError struct { - Value reflect.Value - Str string -} - -func (e *UnsupportedValueError) Error() string { - return fmt.Sprintf("json: unsupported value: %s", e.Str) -} - -func ErrSyntax(msg string, offset int64) *SyntaxError { - return &SyntaxError{msg: msg, Offset: offset} -} - -func ErrMarshaler(typ reflect.Type, err error, msg string) *MarshalerError { - return &MarshalerError{ - Type: typ, - Err: err, - sourceFunc: msg, - } -} - -func ErrExceededMaxDepth(c byte, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf(`invalid character "%c" exceeded max depth`, c), - Offset: cursor, - } -} - -func ErrNotAtBeginningOfValue(cursor int64) *SyntaxError { - return &SyntaxError{msg: "not at beginning of value", Offset: cursor} -} - -func ErrUnexpectedEndOfJSON(msg string, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf("json: %s unexpected end of JSON input", msg), - Offset: cursor, - } -} - -func ErrExpected(msg string, cursor int64) *SyntaxError { - return &SyntaxError{msg: fmt.Sprintf("expected %s", msg), Offset: cursor} -} - -func ErrInvalidCharacter(c byte, context string, cursor int64) *SyntaxError { - if c == 0 { - return &SyntaxError{ - msg: fmt.Sprintf("json: invalid character as %s", context), - Offset: cursor, - } - } - return &SyntaxError{ - msg: fmt.Sprintf("json: invalid character %c as %s", c, context), - Offset: cursor, - } -} - -func ErrInvalidBeginningOfValue(c byte, cursor int64) *SyntaxError { - return &SyntaxError{ - msg: fmt.Sprintf("invalid character '%c' looking for beginning of value", c), - Offset: cursor, - } -} diff --git a/vendor/github.com/goccy/go-json/internal/runtime/rtype.go b/vendor/github.com/goccy/go-json/internal/runtime/rtype.go deleted file mode 100644 index 4db10debe..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/rtype.go +++ /dev/null @@ -1,263 +0,0 @@ -package runtime - -import ( - "reflect" - "unsafe" -) - -// Type representing reflect.rtype for noescape trick -type Type struct{} - -//go:linkname rtype_Align reflect.(*rtype).Align -//go:noescape -func rtype_Align(*Type) int - -func (t *Type) Align() int { - return rtype_Align(t) -} - -//go:linkname rtype_FieldAlign reflect.(*rtype).FieldAlign -//go:noescape -func rtype_FieldAlign(*Type) int - -func (t *Type) FieldAlign() int { - return rtype_FieldAlign(t) -} - -//go:linkname rtype_Method reflect.(*rtype).Method -//go:noescape -func rtype_Method(*Type, int) reflect.Method - -func (t *Type) Method(a0 int) reflect.Method { - return rtype_Method(t, a0) -} - -//go:linkname rtype_MethodByName reflect.(*rtype).MethodByName -//go:noescape -func rtype_MethodByName(*Type, string) (reflect.Method, bool) - -func (t *Type) MethodByName(a0 string) (reflect.Method, bool) { - return rtype_MethodByName(t, a0) -} - -//go:linkname rtype_NumMethod reflect.(*rtype).NumMethod -//go:noescape -func rtype_NumMethod(*Type) int - -func (t *Type) NumMethod() int { - return rtype_NumMethod(t) -} - -//go:linkname rtype_Name reflect.(*rtype).Name -//go:noescape -func rtype_Name(*Type) string - -func (t *Type) Name() string { - return rtype_Name(t) -} - -//go:linkname rtype_PkgPath reflect.(*rtype).PkgPath -//go:noescape -func rtype_PkgPath(*Type) string - -func (t *Type) PkgPath() string { - return rtype_PkgPath(t) -} - -//go:linkname rtype_Size reflect.(*rtype).Size -//go:noescape -func rtype_Size(*Type) uintptr - -func (t *Type) Size() uintptr { - return rtype_Size(t) -} - -//go:linkname rtype_String reflect.(*rtype).String -//go:noescape -func rtype_String(*Type) string - -func (t *Type) String() string { - return rtype_String(t) -} - -//go:linkname rtype_Kind reflect.(*rtype).Kind -//go:noescape -func rtype_Kind(*Type) reflect.Kind - -func (t *Type) Kind() reflect.Kind { - return rtype_Kind(t) -} - -//go:linkname rtype_Implements reflect.(*rtype).Implements -//go:noescape -func rtype_Implements(*Type, reflect.Type) bool - -func (t *Type) Implements(u reflect.Type) bool { - return rtype_Implements(t, u) -} - -//go:linkname rtype_AssignableTo reflect.(*rtype).AssignableTo -//go:noescape -func rtype_AssignableTo(*Type, reflect.Type) bool - -func (t *Type) AssignableTo(u reflect.Type) bool { - return rtype_AssignableTo(t, u) -} - -//go:linkname rtype_ConvertibleTo reflect.(*rtype).ConvertibleTo -//go:noescape -func rtype_ConvertibleTo(*Type, reflect.Type) bool - -func (t *Type) ConvertibleTo(u reflect.Type) bool { - return rtype_ConvertibleTo(t, u) -} - -//go:linkname rtype_Comparable reflect.(*rtype).Comparable -//go:noescape -func rtype_Comparable(*Type) bool - -func (t *Type) Comparable() bool { - return rtype_Comparable(t) -} - -//go:linkname rtype_Bits reflect.(*rtype).Bits -//go:noescape -func rtype_Bits(*Type) int - -func (t *Type) Bits() int { - return rtype_Bits(t) -} - -//go:linkname rtype_ChanDir reflect.(*rtype).ChanDir -//go:noescape -func rtype_ChanDir(*Type) reflect.ChanDir - -func (t *Type) ChanDir() reflect.ChanDir { - return rtype_ChanDir(t) -} - -//go:linkname rtype_IsVariadic reflect.(*rtype).IsVariadic -//go:noescape -func rtype_IsVariadic(*Type) bool - -func (t *Type) IsVariadic() bool { - return rtype_IsVariadic(t) -} - -//go:linkname rtype_Elem reflect.(*rtype).Elem -//go:noescape -func rtype_Elem(*Type) reflect.Type - -func (t *Type) Elem() *Type { - return Type2RType(rtype_Elem(t)) -} - -//go:linkname rtype_Field reflect.(*rtype).Field -//go:noescape -func rtype_Field(*Type, int) reflect.StructField - -func (t *Type) Field(i int) reflect.StructField { - return rtype_Field(t, i) -} - -//go:linkname rtype_FieldByIndex reflect.(*rtype).FieldByIndex -//go:noescape -func rtype_FieldByIndex(*Type, []int) reflect.StructField - -func (t *Type) FieldByIndex(index []int) reflect.StructField { - return rtype_FieldByIndex(t, index) -} - -//go:linkname rtype_FieldByName reflect.(*rtype).FieldByName -//go:noescape -func rtype_FieldByName(*Type, string) (reflect.StructField, bool) - -func (t *Type) FieldByName(name string) (reflect.StructField, bool) { - return rtype_FieldByName(t, name) -} - -//go:linkname rtype_FieldByNameFunc reflect.(*rtype).FieldByNameFunc -//go:noescape -func rtype_FieldByNameFunc(*Type, func(string) bool) (reflect.StructField, bool) - -func (t *Type) FieldByNameFunc(match func(string) bool) (reflect.StructField, bool) { - return rtype_FieldByNameFunc(t, match) -} - -//go:linkname rtype_In reflect.(*rtype).In -//go:noescape -func rtype_In(*Type, int) reflect.Type - -func (t *Type) In(i int) reflect.Type { - return rtype_In(t, i) -} - -//go:linkname rtype_Key reflect.(*rtype).Key -//go:noescape -func rtype_Key(*Type) reflect.Type - -func (t *Type) Key() *Type { - return Type2RType(rtype_Key(t)) -} - -//go:linkname rtype_Len reflect.(*rtype).Len -//go:noescape -func rtype_Len(*Type) int - -func (t *Type) Len() int { - return rtype_Len(t) -} - -//go:linkname rtype_NumField reflect.(*rtype).NumField -//go:noescape -func rtype_NumField(*Type) int - -func (t *Type) NumField() int { - return rtype_NumField(t) -} - -//go:linkname rtype_NumIn reflect.(*rtype).NumIn -//go:noescape -func rtype_NumIn(*Type) int - -func (t *Type) NumIn() int { - return rtype_NumIn(t) -} - -//go:linkname rtype_NumOut reflect.(*rtype).NumOut -//go:noescape -func rtype_NumOut(*Type) int - -func (t *Type) NumOut() int { - return rtype_NumOut(t) -} - -//go:linkname rtype_Out reflect.(*rtype).Out -//go:noescape -func rtype_Out(*Type, int) reflect.Type - -//go:linkname PtrTo reflect.(*rtype).ptrTo -//go:noescape -func PtrTo(*Type) *Type - -func (t *Type) Out(i int) reflect.Type { - return rtype_Out(t, i) -} - -//go:linkname IfaceIndir reflect.ifaceIndir -//go:noescape -func IfaceIndir(*Type) bool - -//go:linkname RType2Type reflect.toType -//go:noescape -func RType2Type(t *Type) reflect.Type - -//go:nolint structcheck -type emptyInterface struct { - _ *Type - ptr unsafe.Pointer -} - -func Type2RType(t reflect.Type) *Type { - return (*Type)(((*emptyInterface)(unsafe.Pointer(&t))).ptr) -} diff --git a/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go b/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go deleted file mode 100644 index c321180a3..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/struct_field.go +++ /dev/null @@ -1,87 +0,0 @@ -package runtime - -import ( - "reflect" - "strings" - "unicode" -) - -func getTag(field reflect.StructField) string { - return field.Tag.Get("json") -} - -func IsIgnoredStructField(field reflect.StructField) bool { - if field.PkgPath != "" { - if field.Anonymous { - if !(field.Type.Kind() == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct) && field.Type.Kind() != reflect.Struct { - return true - } - } else { - // private field - return true - } - } - tag := getTag(field) - return tag == "-" -} - -type StructTag struct { - Key string - IsTaggedKey bool - IsOmitEmpty bool - IsString bool - Field reflect.StructField -} - -type StructTags []*StructTag - -func (t StructTags) ExistsKey(key string) bool { - for _, tt := range t { - if tt.Key == key { - return true - } - } - return false -} - -func isValidTag(s string) bool { - if s == "" { - return false - } - for _, c := range s { - switch { - case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): - // Backslash and quote chars are reserved, but - // otherwise any punctuation chars are allowed - // in a tag name. - case !unicode.IsLetter(c) && !unicode.IsDigit(c): - return false - } - } - return true -} - -func StructTagFromField(field reflect.StructField) *StructTag { - keyName := field.Name - tag := getTag(field) - st := &StructTag{Field: field} - opts := strings.Split(tag, ",") - if len(opts) > 0 { - if opts[0] != "" && isValidTag(opts[0]) { - keyName = opts[0] - st.IsTaggedKey = true - } - } - st.Key = keyName - if len(opts) > 1 { - for _, opt := range opts[1:] { - switch opt { - case "omitempty": - st.IsOmitEmpty = true - case "string": - st.IsString = true - } - } - } - return st -} diff --git a/vendor/github.com/goccy/go-json/internal/runtime/type.go b/vendor/github.com/goccy/go-json/internal/runtime/type.go deleted file mode 100644 index 0167cd2c0..000000000 --- a/vendor/github.com/goccy/go-json/internal/runtime/type.go +++ /dev/null @@ -1,100 +0,0 @@ -package runtime - -import ( - "reflect" - "unsafe" -) - -type SliceHeader struct { - Data unsafe.Pointer - Len int - Cap int -} - -const ( - maxAcceptableTypeAddrRange = 1024 * 1024 * 2 // 2 Mib -) - -type TypeAddr struct { - BaseTypeAddr uintptr - MaxTypeAddr uintptr - AddrRange uintptr - AddrShift uintptr -} - -var ( - typeAddr *TypeAddr - alreadyAnalyzed bool -) - -//go:linkname typelinks reflect.typelinks -func typelinks() ([]unsafe.Pointer, [][]int32) - -//go:linkname rtypeOff reflect.rtypeOff -func rtypeOff(unsafe.Pointer, int32) unsafe.Pointer - -func AnalyzeTypeAddr() *TypeAddr { - defer func() { - alreadyAnalyzed = true - }() - if alreadyAnalyzed { - return typeAddr - } - sections, offsets := typelinks() - if len(sections) != 1 { - return nil - } - if len(offsets) != 1 { - return nil - } - section := sections[0] - offset := offsets[0] - var ( - min uintptr = uintptr(^uint(0)) - max uintptr = 0 - isAligned64 = true - isAligned32 = true - ) - for i := 0; i < len(offset); i++ { - typ := (*Type)(rtypeOff(section, offset[i])) - addr := uintptr(unsafe.Pointer(typ)) - if min > addr { - min = addr - } - if max < addr { - max = addr - } - if typ.Kind() == reflect.Ptr { - addr = uintptr(unsafe.Pointer(typ.Elem())) - if min > addr { - min = addr - } - if max < addr { - max = addr - } - } - isAligned64 = isAligned64 && (addr-min)&63 == 0 - isAligned32 = isAligned32 && (addr-min)&31 == 0 - } - addrRange := max - min - if addrRange == 0 { - return nil - } - var addrShift uintptr - if isAligned64 { - addrShift = 6 - } else if isAligned32 { - addrShift = 5 - } - cacheSize := addrRange >> addrShift - if cacheSize > maxAcceptableTypeAddrRange { - return nil - } - typeAddr = &TypeAddr{ - BaseTypeAddr: min, - MaxTypeAddr: max, - AddrRange: addrRange, - AddrShift: addrShift, - } - return typeAddr -} diff --git a/vendor/github.com/goccy/go-json/json.go b/vendor/github.com/goccy/go-json/json.go deleted file mode 100644 index 5c9448d8c..000000000 --- a/vendor/github.com/goccy/go-json/json.go +++ /dev/null @@ -1,366 +0,0 @@ -package json - -import ( - "bytes" - "context" - "encoding/json" - - "github.com/goccy/go-json/internal/encoder" -) - -// Marshaler is the interface implemented by types that -// can marshal themselves into valid JSON. -type Marshaler interface { - MarshalJSON() ([]byte, error) -} - -// MarshalerContext is the interface implemented by types that -// can marshal themselves into valid JSON with context.Context. -type MarshalerContext interface { - MarshalJSON(context.Context) ([]byte, error) -} - -// Unmarshaler is the interface implemented by types -// that can unmarshal a JSON description of themselves. -// The input can be assumed to be a valid encoding of -// a JSON value. UnmarshalJSON must copy the JSON data -// if it wishes to retain the data after returning. -// -// By convention, to approximate the behavior of Unmarshal itself, -// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op. -type Unmarshaler interface { - UnmarshalJSON([]byte) error -} - -// UnmarshalerContext is the interface implemented by types -// that can unmarshal with context.Context a JSON description of themselves. -type UnmarshalerContext interface { - UnmarshalJSON(context.Context, []byte) error -} - -// Marshal returns the JSON encoding of v. -// -// Marshal traverses the value v recursively. -// If an encountered value implements the Marshaler interface -// and is not a nil pointer, Marshal calls its MarshalJSON method -// to produce JSON. If no MarshalJSON method is present but the -// value implements encoding.TextMarshaler instead, Marshal calls -// its MarshalText method and encodes the result as a JSON string. -// The nil pointer exception is not strictly necessary -// but mimics a similar, necessary exception in the behavior of -// UnmarshalJSON. -// -// Otherwise, Marshal uses the following type-dependent default encodings: -// -// Boolean values encode as JSON booleans. -// -// Floating point, integer, and Number values encode as JSON numbers. -// -// String values encode as JSON strings coerced to valid UTF-8, -// replacing invalid bytes with the Unicode replacement rune. -// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e" -// to keep some browsers from misinterpreting JSON output as HTML. -// Ampersand "&" is also escaped to "\u0026" for the same reason. -// This escaping can be disabled using an Encoder that had SetEscapeHTML(false) -// called on it. -// -// Array and slice values encode as JSON arrays, except that -// []byte encodes as a base64-encoded string, and a nil slice -// encodes as the null JSON value. -// -// Struct values encode as JSON objects. -// Each exported struct field becomes a member of the object, using the -// field name as the object key, unless the field is omitted for one of the -// reasons given below. -// -// The encoding of each struct field can be customized by the format string -// stored under the "json" key in the struct field's tag. -// The format string gives the name of the field, possibly followed by a -// comma-separated list of options. The name may be empty in order to -// specify options without overriding the default field name. -// -// The "omitempty" option specifies that the field should be omitted -// from the encoding if the field has an empty value, defined as -// false, 0, a nil pointer, a nil interface value, and any empty array, -// slice, map, or string. -// -// As a special case, if the field tag is "-", the field is always omitted. -// Note that a field with name "-" can still be generated using the tag "-,". -// -// Examples of struct field tags and their meanings: -// -// // Field appears in JSON as key "myName". -// Field int `json:"myName"` -// -// // Field appears in JSON as key "myName" and -// // the field is omitted from the object if its value is empty, -// // as defined above. -// Field int `json:"myName,omitempty"` -// -// // Field appears in JSON as key "Field" (the default), but -// // the field is skipped if empty. -// // Note the leading comma. -// Field int `json:",omitempty"` -// -// // Field is ignored by this package. -// Field int `json:"-"` -// -// // Field appears in JSON as key "-". -// Field int `json:"-,"` -// -// The "string" option signals that a field is stored as JSON inside a -// JSON-encoded string. It applies only to fields of string, floating point, -// integer, or boolean types. This extra level of encoding is sometimes used -// when communicating with JavaScript programs: -// -// Int64String int64 `json:",string"` -// -// The key name will be used if it's a non-empty string consisting of -// only Unicode letters, digits, and ASCII punctuation except quotation -// marks, backslash, and comma. -// -// Anonymous struct fields are usually marshaled as if their inner exported fields -// were fields in the outer struct, subject to the usual Go visibility rules amended -// as described in the next paragraph. -// An anonymous struct field with a name given in its JSON tag is treated as -// having that name, rather than being anonymous. -// An anonymous struct field of interface type is treated the same as having -// that type as its name, rather than being anonymous. -// -// The Go visibility rules for struct fields are amended for JSON when -// deciding which field to marshal or unmarshal. If there are -// multiple fields at the same level, and that level is the least -// nested (and would therefore be the nesting level selected by the -// usual Go rules), the following extra rules apply: -// -// 1) Of those fields, if any are JSON-tagged, only tagged fields are considered, -// even if there are multiple untagged fields that would otherwise conflict. -// -// 2) If there is exactly one field (tagged or not according to the first rule), that is selected. -// -// 3) Otherwise there are multiple fields, and all are ignored; no error occurs. -// -// Handling of anonymous struct fields is new in Go 1.1. -// Prior to Go 1.1, anonymous struct fields were ignored. To force ignoring of -// an anonymous struct field in both current and earlier versions, give the field -// a JSON tag of "-". -// -// Map values encode as JSON objects. The map's key type must either be a -// string, an integer type, or implement encoding.TextMarshaler. The map keys -// are sorted and used as JSON object keys by applying the following rules, -// subject to the UTF-8 coercion described for string values above: -// - string keys are used directly -// - encoding.TextMarshalers are marshaled -// - integer keys are converted to strings -// -// Pointer values encode as the value pointed to. -// A nil pointer encodes as the null JSON value. -// -// Interface values encode as the value contained in the interface. -// A nil interface value encodes as the null JSON value. -// -// Channel, complex, and function values cannot be encoded in JSON. -// Attempting to encode such a value causes Marshal to return -// an UnsupportedTypeError. -// -// JSON cannot represent cyclic data structures and Marshal does not -// handle them. Passing cyclic structures to Marshal will result in -// an infinite recursion. -// -func Marshal(v interface{}) ([]byte, error) { - return MarshalWithOption(v) -} - -// MarshalNoEscape returns the JSON encoding of v and doesn't escape v. -func MarshalNoEscape(v interface{}) ([]byte, error) { - return marshalNoEscape(v) -} - -// MarshalContext returns the JSON encoding of v with context.Context and EncodeOption. -func MarshalContext(ctx context.Context, v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshalContext(ctx, v, optFuncs...) -} - -// MarshalWithOption returns the JSON encoding of v with EncodeOption. -func MarshalWithOption(v interface{}, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshal(v, optFuncs...) -} - -// MarshalIndent is like Marshal but applies Indent to format the output. -// Each JSON element in the output will begin on a new line beginning with prefix -// followed by one or more copies of indent according to the indentation nesting. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - return MarshalIndentWithOption(v, prefix, indent) -} - -// MarshalIndentWithOption is like Marshal but applies Indent to format the output with EncodeOption. -func MarshalIndentWithOption(v interface{}, prefix, indent string, optFuncs ...EncodeOptionFunc) ([]byte, error) { - return marshalIndent(v, prefix, indent, optFuncs...) -} - -// Unmarshal parses the JSON-encoded data and stores the result -// in the value pointed to by v. If v is nil or not a pointer, -// Unmarshal returns an InvalidUnmarshalError. -// -// Unmarshal uses the inverse of the encodings that -// Marshal uses, allocating maps, slices, and pointers as necessary, -// with the following additional rules: -// -// To unmarshal JSON into a pointer, Unmarshal first handles the case of -// the JSON being the JSON literal null. In that case, Unmarshal sets -// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into -// the value pointed at by the pointer. If the pointer is nil, Unmarshal -// allocates a new value for it to point to. -// -// To unmarshal JSON into a value implementing the Unmarshaler interface, -// Unmarshal calls that value's UnmarshalJSON method, including -// when the input is a JSON null. -// Otherwise, if the value implements encoding.TextUnmarshaler -// and the input is a JSON quoted string, Unmarshal calls that value's -// UnmarshalText method with the unquoted form of the string. -// -// To unmarshal JSON into a struct, Unmarshal matches incoming object -// keys to the keys used by Marshal (either the struct field name or its tag), -// preferring an exact match but also accepting a case-insensitive match. By -// default, object keys which don't have a corresponding struct field are -// ignored (see Decoder.DisallowUnknownFields for an alternative). -// -// To unmarshal JSON into an interface value, -// Unmarshal stores one of these in the interface value: -// -// bool, for JSON booleans -// float64, for JSON numbers -// string, for JSON strings -// []interface{}, for JSON arrays -// map[string]interface{}, for JSON objects -// nil for JSON null -// -// To unmarshal a JSON array into a slice, Unmarshal resets the slice length -// to zero and then appends each element to the slice. -// As a special case, to unmarshal an empty JSON array into a slice, -// Unmarshal replaces the slice with a new empty slice. -// -// To unmarshal a JSON array into a Go array, Unmarshal decodes -// JSON array elements into corresponding Go array elements. -// If the Go array is smaller than the JSON array, -// the additional JSON array elements are discarded. -// If the JSON array is smaller than the Go array, -// the additional Go array elements are set to zero values. -// -// To unmarshal a JSON object into a map, Unmarshal first establishes a map to -// use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal -// reuses the existing map, keeping existing entries. Unmarshal then stores -// key-value pairs from the JSON object into the map. The map's key type must -// either be any string type, an integer, implement json.Unmarshaler, or -// implement encoding.TextUnmarshaler. -// -// If a JSON value is not appropriate for a given target type, -// or if a JSON number overflows the target type, Unmarshal -// skips that field and completes the unmarshaling as best it can. -// If no more serious errors are encountered, Unmarshal returns -// an UnmarshalTypeError describing the earliest such error. In any -// case, it's not guaranteed that all the remaining fields following -// the problematic one will be unmarshaled into the target object. -// -// The JSON null value unmarshals into an interface, map, pointer, or slice -// by setting that Go value to nil. Because null is often used in JSON to mean -// ``not present,'' unmarshaling a JSON null into any other Go type has no effect -// on the value and produces no error. -// -// When unmarshaling quoted strings, invalid UTF-8 or -// invalid UTF-16 surrogate pairs are not treated as an error. -// Instead, they are replaced by the Unicode replacement -// character U+FFFD. -// -func Unmarshal(data []byte, v interface{}) error { - return unmarshal(data, v) -} - -// UnmarshalContext parses the JSON-encoded data and stores the result -// in the value pointed to by v. If you implement the UnmarshalerContext interface, -// call it with ctx as an argument. -func UnmarshalContext(ctx context.Context, data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshalContext(ctx, data, v) -} - -func UnmarshalWithOption(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshal(data, v, optFuncs...) -} - -func UnmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error { - return unmarshalNoEscape(data, v, optFuncs...) -} - -// A Token holds a value of one of these types: -// -// Delim, for the four JSON delimiters [ ] { } -// bool, for JSON booleans -// float64, for JSON numbers -// Number, for JSON numbers -// string, for JSON string literals -// nil, for JSON null -// -type Token = json.Token - -// A Number represents a JSON number literal. -type Number = json.Number - -// RawMessage is a raw encoded JSON value. -// It implements Marshaler and Unmarshaler and can -// be used to delay JSON decoding or precompute a JSON encoding. -type RawMessage = json.RawMessage - -// A Delim is a JSON array or object delimiter, one of [ ] { or }. -type Delim = json.Delim - -// Compact appends to dst the JSON-encoded src with -// insignificant space characters elided. -func Compact(dst *bytes.Buffer, src []byte) error { - return encoder.Compact(dst, src, false) -} - -// Indent appends to dst an indented form of the JSON-encoded src. -// Each element in a JSON object or array begins on a new, -// indented line beginning with prefix followed by one or more -// copies of indent according to the indentation nesting. -// The data appended to dst does not begin with the prefix nor -// any indentation, to make it easier to embed inside other formatted JSON data. -// Although leading space characters (space, tab, carriage return, newline) -// at the beginning of src are dropped, trailing space characters -// at the end of src are preserved and copied to dst. -// For example, if src has no trailing spaces, neither will dst; -// if src ends in a trailing newline, so will dst. -func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error { - return encoder.Indent(dst, src, prefix, indent) -} - -// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 -// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 -// so that the JSON will be safe to embed inside HTML