Skip to content

pointers: add a scalar value decoder#269

Merged
gnidan merged 1 commit into
mainfrom
debugger-scalar-decode
Jul 16, 2026
Merged

pointers: add a scalar value decoder#269
gnidan merged 1 commit into
mainfrom
debugger-scalar-decode

Conversation

@gnidan

@gnidan gnidan commented Jul 16, 2026

Copy link
Copy Markdown
Member

Adds decodeValue(data, type) to @ethdebug/pointers: a pure function that
turns a resolved value region's bytes plus a variable's static type into a
readable string, so a uint256 local reads as 2 rather than
0x0000…0002.

This is the scalar-first slice of the value-rendering layer. Decoding is
location-blind: it operates on already-resolved bytes and the type, with no
machine state or pointer logic.

Handled types:

  • uint<N> — decimal
  • int<N> — signed decimal (two's complement over the region's byte width)
  • booltrue/false
  • address — EIP-55 checksummed 0x…
  • static bytes<N>0x… (left-aligned)

Anything else — dynamic bytes/string, arrays, structs, mappings,
fixed/ufixed, enum, an unresolved { id } type reference, or a missing
type — falls back to the raw hex of the region bytes, so callers never break
on an unhandled shape. Aggregate and dynamic decoding are left for later.

Tests cover each scalar kind — including tightly-stored vs. sign-extended
integers and the EIP-55 vector — and the hex fallbacks.

Adds decodeValue(data, type): a pure, framework-agnostic function that
turns a resolved value region's bytes + the variable's static type into a
readable string (uint256 -> "2", not 0x00..02) — the scalar-first slice of
the value-rendering reduce layer.

Handles uint (decimal), int (two's-complement over the region width), bool,
address (EIP-55 checksummed), and static bytesN (left-aligned). Dynamic
bytes/string, aggregates, fixed/ufixed, enum, unresolved {id} type refs, and
missing types fall back to raw hex so callers never break.
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-16 21:27 UTC

@gnidan
gnidan merged commit 4429ae8 into main Jul 16, 2026
4 checks passed
@gnidan
gnidan deleted the debugger-scalar-decode branch July 16, 2026 21:23
gnidan added a commit that referenced this pull request Jul 16, 2026
* Revert "bugc: sound per-instruction local-variable debug snapshot (#261)"

This reverts commit 885f962.

* Revert "pointers: add scalar-first type-directed value decoder (#269)"

This reverts commit 4429ae8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant