@@ -17,7 +17,7 @@ const Y_TICK_DIST = BOX_HEIGHT + 2;
1717let HIT_BOXES = [ ] ;
1818// Index into UNIT_DATA of the last unit hovered over by mouse.
1919let 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.
2121let UNIT_COORDS = { } ;
2222// Map of unit index to the index it was unlocked by.
2323let REVERSE_UNIT_DEPS = { } ;
@@ -306,16 +306,30 @@ function get_section_color(name) {
306306 }
307307}
308308
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+ // We expect to have at least a codegen section,
316+ // so this should be unreachable in normal cases.
317+ return null ;
318+ }
319+ return codegen_section . start ;
320+ }
321+
309322// Draws lines from the given unit to the units it unlocks.
310323function draw_dep_lines ( ctx , unit_idx , highlighted ) {
311324 const unit = UNIT_DATA [ unit_idx ] ;
312- const { x, y, rmeta_x } = UNIT_COORDS [ unit_idx ] ;
325+ const { x, y, sections } = UNIT_COORDS [ unit_idx ] ;
313326 ctx . save ( ) ;
314327 for ( const unlocked of unit . unlocked_units ) {
315328 draw_one_dep_line ( ctx , x , y , unlocked , highlighted ) ;
316329 }
317330 for ( const unlocked of unit . unlocked_rmeta_units ) {
318- draw_one_dep_line ( ctx , rmeta_x , y , unlocked , highlighted ) ;
331+ const codegen_x = get_codegen_section_x ( sections ) ;
332+ draw_one_dep_line ( ctx , codegen_x , y , unlocked , highlighted ) ;
319333 }
320334 ctx . restore ( ) ;
321335}
@@ -589,15 +603,16 @@ function pipeline_mousemove(event) {
589603 if ( box . i in REVERSE_UNIT_DEPS ) {
590604 const dep_unit = REVERSE_UNIT_DEPS [ box . i ] ;
591605 if ( dep_unit in UNIT_COORDS ) {
592- const { x, y, rmeta_x } = UNIT_COORDS [ dep_unit ] ;
606+ const { x, y} = UNIT_COORDS [ dep_unit ] ;
593607 draw_one_dep_line ( ctx , x , y , box . i , true ) ;
594608 }
595609 }
596610 if ( box . i in REVERSE_UNIT_RMETA_DEPS ) {
597611 const dep_unit = REVERSE_UNIT_RMETA_DEPS [ box . i ] ;
598612 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 ) ;
613+ const { y, sections} = UNIT_COORDS [ dep_unit ] ;
614+ const codegen_x = get_codegen_section_x ( sections ) ;
615+ draw_one_dep_line ( ctx , codegen_x , y , box . i , true ) ;
601616 }
602617 }
603618 ctx . restore ( ) ;
0 commit comments