Repository navigation
feat: breakpoint(), array highlighting, interpreter improvements - #4
Merged
Merged
Conversation
- bubble-sort.cpp: in-place bubble sort on int[6] array, demonstrates array visualization with element swapping - btree.cpp: manually constructed order-3 B-tree with root [10,20], three leaf nodes, arrays for keys and children pointers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move duplicate formatAddr/formatType/formatValue/isPointerValue to composables/interpreter/helpers.ts. Simplify DataStructureView (compute subCellAddresses as computed, O(1) addressToKey via Map), DanglingEdge as type alias, and minor cleanups across components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ghting - Fix allocStruct to allocate array elements for struct array fields (previously only created a placeholder with base=0, crashing on access) - Flatten array fields in DSValue and FieldTable: show keys[0], keys[1] instead of a single "keys" entry for struct array fields - Optimize DS view expression highlighting to target specific fields: field_expression (node->data) highlights only the data field row, subscript_expression (arr[i], root->keys[0]) highlights the element - Remove struct base from resolveFieldAddress output (field access now highlights only the specific field, not the whole item) - Add resolveSubscriptAddress for array element highlighting - Add B-tree unit test for struct array field allocation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
**Pointer graph**: Handle arrays of pointers to structs in edge building. For fields like \`BTreeNode *children[4]\`, iterate array elements and create edges for each non-null pointer. Fixes arrows not rendering for btree-style structs. **Pointer arithmetic**: Support ptr+int, int+ptr, ptr-int, ptr-ptr, pointer comparison (<, >, <=, >=), ptr++/ptr--, and ptr+=n/ptr-=n. Memory model is naturally compatible (arrays are contiguous cells). **N-d array rendering**: DSValue and FieldTable recursively flatten nested array fields with subscript prefixes (e.g. \`p[0][1]\`). **Tests**: 6 pointer arithmetic program tests (offset, subtract, difference, comparison, increment, iterator loop). Moved 3 scope cleanup tests from evaluate.test.ts to programs.test.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
**Inline arrays**: Struct array fields are now allocated contiguously within the struct's memory block instead of as separate heap allocations. BTreeNode layout: [header][numKeys][keys_hdr][k0][k1][k2] [children_hdr][c0][c1][c2][c3] — all 11 cells contiguous. This eliminates dangling array allocations after struct deletion. Refactored field addressing from `base + 1 + fieldIndex` to `base + 1 + structFieldOffset(name, defs)` across all consumers (usePointerGraph, DataStructureView, DSValue, FieldTable, MemoryMap, useStatementAddresses, declarations). **Variable-index highlighting**: `resolveSubscriptAddress` now resolves variable indices (e.g. `arr[j]`) by looking up the variable's current value in the env stack. Also handles simple binary expressions like `j + 1`. Fixes bubble sort array element highlighting. **Tests**: Updated btree test to verify contiguous inline memory layout with exact cell offsets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add `breakpoint()` as an interpreter builtin that pauses play mode via a context flag while still acting as a normal step when stepping manually. All templates now call `breakpoint()` before `return 0` so users can inspect the final state. Fix array element highlighting in both memory map and DS view by passing statement address props through to DSValue and adding conditional highlight classes on array leaf elements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for viz-list ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
breakpoint()interpreter builtin that pauses play mode while acting as a normal step when stepping manually. All templates callbreakpoint()beforereturn 0;.structFieldOffset)ptr+int,ptr-int,ptr-ptr, comparison,++/--)arr[j]wherejis a runtime variable)Test plan
bun run typecheckpassesbun run lintpassesbun run knippassesbun run test -- run— 138 tests passbun run buildsucceeds🤖 Generated with Claude Code