Commit e9395d9
Pr/83 (#111)
Summary
This PR enhances the MIR graph visualization with richer allocation
information and adds D2 as an alternative output format.
Key changes:
- Index-first architecture: Build `AllocIndex`, `TypeIndex`, and
`GraphContext` upfront before graph traversal, enabling context-aware
rendering throughout
- **ALLOCS legend**: New yellow info node showing all `GlobalAlloc`
entries with decoded values (strings as ASCII, small integers as numeric
values)
- Enhanced constant labels: Constants now show provenance references
like `const [alloc0: Int(I32) = 42]` instead of opaque `const ?_i32`
- D2 output format (--d2 flag): Alternative to DOT with modern
diagramming, viewable in browser at https://play.d2lang.com
## Addresses
#83
## Example
Before:
```rust
const ?_i32
```
After:
```rust
const [alloc0: Int(I32) = 42]
```
## New CLI usage
```console
cargo run -- --dot file.rs # Graphviz DOT (existing)
cargo run -- --d2 file.rs # D2 format (new)
```
## New Make targets
```console
make dot # Generate all dot files
make svg # Generate all svg files
make png # Generate all png files
make d2 # Generate all D2 files
```
## Test plan
- [ ] Run --dot on test programs, verify ALLOCS legend appears
- [ ] Run --d2 on test programs, verify output renders in D2 playground
- [ ] Verify make integration-test passes
---------
Co-authored-by: Daniel Cumming <124537596+dkcumming@users.noreply.github.com>1 parent b70cb77 commit e9395d9
11 files changed
+1500
-262
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
0 commit comments