programs-react: resolve a local to its value region, not every region#268
Closed
gnidan wants to merge 4 commits into
Closed
programs-react: resolve a local to its value region, not every region#268gnidan wants to merge 4 commits into
gnidan wants to merge 4 commits into
Conversation
Contributor
|
gnidan
force-pushed
the
ui-local-value-reduce
branch
2 times, most recently
from
July 16, 2026 07:29
72121c8 to
9745c9e
Compare
resolveVariableValue joined every region of a resolved pointer, so a memory-homed local — whose pointer is a group carrying a frame scaffolding region plus the value region — rendered as two hex words (the frame pointer and the value) instead of one. Select the value region by the variable's identifier via Cursor.Regions.lookup (the last concrete region with that name) and read just that region. Falls back to the previous all-regions behavior when no identifier-named region exists, so nothing else regresses. This is the scalar-first slice of the value-reduce layer; it also sets up string/array locals later. Verified against a real trace: a frame-relative local resolved to a single clean value (0xaaaa) instead of frame-pointer + value.
The docs trace playground's drawer resolves variable/argument values with its own resolvePointer, which had the same all-regions-join bug as programs-react's resolveVariableValue — a memory-homed local rendered as frame pointer + value. Apply the identical scalar-first reduce here: select the value region by the variable/argument identifier via Cursor.Regions.lookup, falling back to the all-regions read when there is no identifier-named region. This is the surface the trace-playground preview actually shows, so the combined preview now renders locals as a single clean value.
gnidan
force-pushed
the
ui-local-value-reduce
branch
from
July 16, 2026 17:18
262fd26 to
b94b8ea
Compare
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.
Wire debugger's decodeValue into both variable resolvers so a located local renders as a readable value instead of raw hex: uint -> decimal, int -> signed, bool -> true/false, address -> checksummed, static bytesN -> hex; composite/unknown fall back to hex. The value region is already narrowed by identifier (the reduce); this decodes that region's bytes with the variable's static type. - programs-react resolveVariableValue: thread the variable type, decode the selected/single region. - TraceDrawer resolvePointer: same, keeping the raw type specifier on the extracted Variable; drop the render-side formatAsDecimal since decodeValue returns the final display string. Verified on a real trace: uint locals a/b render as 43690/48059.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #261 (base =
compiler-locals-emission) so the deploy preview shows #261's local emission and this reduce together — the combined view to eyeball before merging #261.Bug:
resolveVariableValue(TraceContext.tsx) joined every region of a resolved pointer. A memory-homed local's pointer is agroupcarrying a frame scaffolding region plus the value region, so a scalar local rendered as two hex words (frame pointer + value) — the "weird memory values."Fix (scalar-first reduce): select the value region by the variable's identifier via
Cursor.Regions.lookup(last concrete region with that name) and read just that one. Falls back to the previous all-regions behavior when there's no identifier-named region, so nothing else regresses. Wired the identifier through the locals and call-argument call sites.Verified against a real trace (
add(a,b), O0):a's pointer isgroup:[{name:"frame"},{name:"a"}]; old code returned0x…0100, 0x…aaaa(frame pointer + value), the fix returns0x…aaaa= 43690 — one clean value. All 66 programs-react tests pass; web build green.Coordinated the region API with debugger. This is the first slice of the value-reduce layer; it also sets up string/array locals later. Base can retarget to main (or fold into #261) once #261 lands.