@@ -17,7 +17,7 @@ const Y_TICK_DIST = BOX_HEIGHT + 2;
17
17
let HIT_BOXES = [ ] ;
18
18
// Index into UNIT_DATA of the last unit hovered over by mouse.
19
19
let LAST_HOVER = null ;
20
- // Key is unit index, value is {x, y, width, rmeta_x } of the box.
20
+ // Key is unit index, value is {x, y, width, sections } of the box.
21
21
let UNIT_COORDS = { } ;
22
22
// Map of unit index to the index it was unlocked by.
23
23
let REVERSE_UNIT_DEPS = { } ;
@@ -306,16 +306,29 @@ function get_section_color(name) {
306
306
}
307
307
}
308
308
309
+ // Gets the x-coordinate of the codegen section of a unit.
310
+ //
311
+ // This is for drawing rmeta dependency lines.
312
+ function get_codegen_section_x ( sections ) {
313
+ const codegen_section = sections . find ( s => s . name === "codegen" )
314
+ if ( ! codegen_section ) {
315
+ // This happens only when type-checking (e.g., `cargo check`)
316
+ return null ;
317
+ }
318
+ return codegen_section . start ;
319
+ }
320
+
309
321
// Draws lines from the given unit to the units it unlocks.
310
322
function draw_dep_lines ( ctx , unit_idx , highlighted ) {
311
323
const unit = UNIT_DATA [ unit_idx ] ;
312
- const { x, y, rmeta_x } = UNIT_COORDS [ unit_idx ] ;
324
+ const { x, y, sections } = UNIT_COORDS [ unit_idx ] ;
313
325
ctx . save ( ) ;
314
326
for ( const unlocked of unit . unlocked_units ) {
315
327
draw_one_dep_line ( ctx , x , y , unlocked , highlighted ) ;
316
328
}
317
329
for ( const unlocked of unit . unlocked_rmeta_units ) {
318
- draw_one_dep_line ( ctx , rmeta_x , y , unlocked , highlighted ) ;
330
+ const codegen_x = get_codegen_section_x ( sections ) ;
331
+ draw_one_dep_line ( ctx , codegen_x , y , unlocked , highlighted ) ;
319
332
}
320
333
ctx . restore ( ) ;
321
334
}
@@ -589,15 +602,16 @@ function pipeline_mousemove(event) {
589
602
if ( box . i in REVERSE_UNIT_DEPS ) {
590
603
const dep_unit = REVERSE_UNIT_DEPS [ box . i ] ;
591
604
if ( dep_unit in UNIT_COORDS ) {
592
- const { x, y, rmeta_x } = UNIT_COORDS [ dep_unit ] ;
605
+ const { x, y} = UNIT_COORDS [ dep_unit ] ;
593
606
draw_one_dep_line ( ctx , x , y , box . i , true ) ;
594
607
}
595
608
}
596
609
if ( box . i in REVERSE_UNIT_RMETA_DEPS ) {
597
610
const dep_unit = REVERSE_UNIT_RMETA_DEPS [ box . i ] ;
598
611
if ( dep_unit in UNIT_COORDS ) {
599
- const { x, y, rmeta_x} = UNIT_COORDS [ dep_unit ] ;
600
- draw_one_dep_line ( ctx , rmeta_x , y , box . i , true ) ;
612
+ const { y, sections} = UNIT_COORDS [ dep_unit ] ;
613
+ const codegen_x = get_codegen_section_x ( sections ) ;
614
+ draw_one_dep_line ( ctx , codegen_x , y , box . i , true ) ;
601
615
}
602
616
}
603
617
ctx . restore ( ) ;
0 commit comments