Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
tags:
- '*'
pull_request:
branches: [ "main" ]

permissions:
contents: write
Expand Down Expand Up @@ -94,6 +93,17 @@ jobs:
- name: Run Java example integration tests
if: matrix.java-version == '25'
run: make test-examples
- name: Generate native layout coordination review package
id: layout-review
if: matrix.java-version == '25'
run: uv run python -m scripts.review_layout_coordinator --out .scratch/layout-coordinator-review
- name: Upload native layout coordination review package
if: always() && matrix.java-version == '25' && (steps.layout-review.outcome == 'success' || steps.layout-review.outcome == 'failure')
uses: actions/upload-artifact@v7
with:
name: layout-coordinator-review
path: .scratch/layout-coordinator-review/
if-no-files-found: error
- name: Build Python Distribution
run: uv build
- name: Check installed wheel installer commands
Expand Down
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ The rendering benchmark checks dimensions and decoded pixels and reports time an

For SVG changes, generate milestone screenshots and inspect PNG/SVG pairs using the [comparison gallery](docs/svg-gallery.md). Keep generated evidence under the ignored `.scratch/svg-gallery/` directory. Use JDK 25 for the full Java example suite; example 33 uses `java.lang.IO`. Multi-file examples use the tracer's file-input mode so companion sources are available.

For coordinated stack/heap layout changes, build the frontend first and capture
the public export fixtures with the native review tool:

```sh
make build-frontend
uv run python -m scripts.review_layout_coordinator --out .scratch/layout-coordinator-review
```

The output includes an offline gallery, 12 native PNG/SVG pairs, separately
reopened SVG rasters, and a manifest of source, bundle, input, and export hashes.
Use `--compare PATH` with a previous capture to compare decoded PNG pixels,
SVG routes and descriptions, and reopened SVG pixels independently. Source and
bundle hashes identify the captured files; they do not establish that the bundle
was rebuilt from those sources. Capture after a clean build and record its commit.
The JDK 25 CI job uploads the review package as `layout-coordinator-review`.

## Development artifacts

Use the ignored root `.scratch/` directory for proposals, throwaway prototypes,
Expand Down
38 changes: 38 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Execution visualization

The visualizer presents program state as reference-valued locations, stack
frames, and heap objects connected by directed reference paths.

## Language

**Placement model**:
Rules that select the order, grouping, positions, or sizes of the visual elements
in a region of a program-state diagram.

**Layout**:
The spatial arrangement of stack frames, globals, heap objects, and the space
reserved around them for a rendered program state.

**Routing**:
The selection of directed connector paths between reference locations and their
targets in a layout.

**Layout repair**:
A bounded adjustment to the arrangement or reserved space made to resolve an
obstruction found while constructing reference paths.

**Supplied sequence**:
The ordered program states available to a visualization; the sequence may be a
complete execution trace or selected snapshots with omitted history.

**Canonical layout**:
A layout determined by a program state and its declared planning and presentation
conditions, independently of the order in which a reader visits states.

**Frame render key**:
An identifier used to associate a frame's visual representation with a supplied
state; it does not necessarily identify a method invocation throughout its life.

**Invocation identity**:
An identifier for one method invocation across the program states in which that
invocation exists.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cs1302_code_visualizer/frontend/build/vis-module.bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cs1302_code_visualizer/frontend/js/CodeVisualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export function create({
},
destroy: () => {
element.removeEventListener("keydown", keyHandler);
visualizer.dataViz.jsPlumbInstance.dispose();
element.innerHTML = "";
},
element: element,
Expand Down
264 changes: 91 additions & 173 deletions cs1302_code_visualizer/frontend/js/connectorRouting.ts

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions cs1302_code_visualizer/frontend/js/connectorScene.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/** DOM measurement and SVG publication. The routing DTO has no DOM bindings. */
import { SOURCE_INSET } from "./connectorGeometry";
import { Attachment, Rect, bounds, expand, pathData } from "./referenceRouting";
import type { SvgConnection } from "./svgConnectors";
import type { ConnectorRoutePlan, MeasuredConnectorEdge, MeasuredConnectorScene } from "./connectorRouting";

const bodies=".instTbl,.classTbl,.dictTbl,.listTbl,.tupleTbl,.stackTbl,.queueTbl";
const ownerSelector=".heapObject,.stackFrame,.zombieStackFrame";

/** Private-to-the-host bindings, kept beside, never inside, the solver scene. */
export interface ConnectorMeasurement {
scene: MeasuredConnectorScene;
bindings: {
connections: readonly SvgConnection[];
owners: HTMLElement[];
targetBodies: Map<number, HTMLElement>;
sourceBoxes: Map<number, HTMLElement>;
};
}

/** Read each element rectangle once in this pass, including repair passes. No paint writes. */
export function measureConnectorScene(container: HTMLElement, connections: readonly SvgConnection[]): ConnectorMeasurement {
const origin=container.getBoundingClientRect(),cache=new Map<Element,Rect>();
const canvas={left:0,top:0,right:origin.width,bottom:origin.height};
cache.set(container,canvas);
const rect=(el:Element):Rect=>{
let r=cache.get(el);if(r)return r;
const b=el.getBoundingClientRect();
r={left:b.left-origin.left,top:b.top-origin.top,right:b.right-origin.left,bottom:b.bottom-origin.top};
cache.set(el,r);return r;
};
const root=container.querySelector("#dataViz")??container;
const elements=Array.from(root.querySelectorAll<HTMLElement>(ownerSelector));
const text:Rect[]=[],textOwners:number[]=[];
const walker=container.ownerDocument.createTreeWalker(root,NodeFilter.SHOW_TEXT);
const range=container.ownerDocument.createRange();
const visibility=new Map<Element,boolean>();
const visible=(el:Element|null):boolean=>{
if(!el||el===root.parentElement)return true;
const cached=visibility.get(el);if(cached!==undefined)return cached;
const style=getComputedStyle(el),ok=style.display!=="none"&&style.visibility!=="hidden"&&
style.visibility!=="collapse"&&style.opacity!=="0"&&visible(el.parentElement);
visibility.set(el,ok);return ok;
};
const objects=elements.map(el=>visible(el)?rect(el):{left:0,top:0,right:0,bottom:0});
while(walker.nextNode()) {
const n=walker.currentNode,parent=n.parentElement;
if(!n.textContent?.trim()||!parent||parent.closest("svg,script,style")||!visible(parent))continue;
range.selectNodeContents(n);
if(typeof range.getClientRects!=="function")continue;
for(const b of Array.from(range.getClientRects()))if(b.width&&b.height) {
text.push({left:b.left-origin.left,top:b.top-origin.top,right:b.right-origin.left,bottom:b.bottom-origin.top});
textOwners.push(elements.indexOf(parent.closest<HTMLElement>(ownerSelector)!));
}
}
const localEndpoints=Array.from(root.querySelectorAll(".compact-string-arrow circle,.compact-string-arrow polygon,.compact-string-arrow path"))
.filter(visible).map(el=>expand(rect(el),.5));
const targetBodies=new Map<number,HTMLElement>(),sourceBoxes=new Map<number,HTMLElement>();
const edges:MeasuredConnectorEdge[]=[];
connections.forEach((c,connectionIndex)=>{
const source=c.source[0],target=c.target[0];
if(!source||!target)return;
const box=source.closest<HTMLElement>(".value-box");
const sb=rect(box??source),t=rect(target);
if(!visible(source)||!visible(target)||sb.right<=sb.left||sb.bottom<=sb.top||t.right<=t.left||t.bottom<=t.top)return;
const enclosure=rect(source.closest(`${bodies},.stackFrame,.zombieStackFrame`)??source);
const so=elements.indexOf(source.closest<HTMLElement>(ownerSelector)!),to=elements.indexOf(target.closest<HTMLElement>(ownerSelector)!);
const body=(target.querySelector(bodies)??target) as HTMLElement;
const heapOrigin=!!source.closest(".heapObject");
const a:Attachment={source:[sb.right-(box?SOURCE_INSET:0),(sb.top+sb.bottom)/2],sourceBox:sb,enclosure,
target:rect(body),targetKey:c.targetId,legacyTarget:t,sourceOwner:so,targetOwner:to,
returning:so>=0&&to>=0&&heapOrigin&&objects[to].left<=objects[so].left,
width:Math.max(c.paintStyle.lineWidth??1,c.hoverPaintStyle.lineWidth??1)};
if(c.scope==="frameParentPointer") {
a.parent={sourceSide:c.anchors[0]==="LeftMiddle"?-1:1,
targetSide:c.anchors[1]==="RightMiddle"?1:-1,curviness:c.curviness??45};
a.source=[a.parent.sourceSide<0?sb.left:sb.right,(sb.top+sb.bottom)/2];
a.target=t;
}
targetBodies.set(connectionIndex,body);
if(box)sourceBoxes.set(connectionIndex,box);
edges.push({connectionIndex,sourceId:c.sourceId,targetId:c.targetId,heapOrigin,attachment:a});
});
edges.sort((a,b)=>Number(a.heapOrigin)-Number(b.heapOrigin)||
a.attachment.source[1]-b.attachment.source[1]||a.attachment.source[0]-b.attachment.source[0]||
a.attachment.target.left-b.attachment.target.left||a.attachment.target.top-b.attachment.target.top||
a.sourceId.replace(/^v\d+__/,"").localeCompare(b.sourceId.replace(/^v\d+__/,"")));
const content=objects.length?bounds(objects.flatMap(r=>[[r.left,r.top],[r.right,r.bottom]])):rect(root);
return {scene:{objects,heapOwners:elements.map(e=>e.matches(".heapObject")),text,textOwners,localEndpoints,edges,content,canvas},
bindings:{connections,owners:elements,targetBodies,sourceBoxes}};
}

/** Only the coordinator's final accepted plan is published. Invisible endpoints stay hidden. */
export function paintConnectorPlan(measurement: ConnectorMeasurement, plan: ConnectorRoutePlan): void {
for(const c of measurement.bindings.connections)c.groupElement.style.display="none";
for(const {connectionIndex,attachment:a,route:r} of plan.connectors) {
const c=measurement.bindings.connections[connectionIndex];
c.dotElement.setAttribute("cx",String(a.source[0]));c.dotElement.setAttribute("cy",String(a.source[1]));
c.pathElement.setAttribute("d",pathData(r));c.pathElement.dataset.routing=r.kind;
c.arrowElement.setAttribute("points",r.head.map(p=>p.join(",")).join(" "));
delete c.pathElement.dataset.returnLane;
c.groupElement.style.display="";
}
}

/** Failure/reset removes stale route geometry as well as hiding every group. */
export function clearConnectorPaint(connections: readonly SvgConnection[]): void {
for(const c of connections) {
c.groupElement.style.display="none";
c.pathElement.setAttribute("d","");c.arrowElement.setAttribute("points","");
c.dotElement.removeAttribute("cx");c.dotElement.removeAttribute("cy");
delete c.pathElement.dataset.routing;delete c.pathElement.dataset.returnLane;
}
}
Loading
Loading