Debian Codegraph @

lib/prism/dot_visitor.rb

raw symbols SCIP
1 # frozen_string_literal: true
2 # :markup: markdown
3
4 =begin
5 --
6 This file is generated by the templates/template.rb script and should not be
7 modified manually. See templates/lib/prism/dot_visitor.rb.erb
8 if you are looking to modify the template
9 ++
10 =end
11
12 require "cgi/escape"
13 require "cgi/util" unless defined?(CGI::EscapeExt)
14
15 module Prism
16 # This visitor provides the ability to call Node#to_dot, which converts a
17 # subtree into a graphviz dot graph.
18 class DotVisitor < Visitor
19 class Field # :nodoc:
20 attr_reader :name, :value, :port
21
22 def initialize(name, value, port)
23 @name = name
24 @value = value
25 @port = port
26 end
27
28 def to_dot
29 if port
30 "<tr><td align=\"left\" colspan=\"2\" port=\"#{name}\">#{name}</td></tr>"
31 else
32 "<tr><td align=\"left\">#{name}</td><td>#{CGI.escapeHTML(value || raise)}</td></tr>"
33 end
34 end
35 end
36
37 class Table # :nodoc:
38 attr_reader :name, :fields
39
40 def initialize(name)
41 @name = name
42 @fields = []
43 end
44
45 def field(name, value = nil, port: false)
46 fields << Field.new(name, value, port)
47 end
48
49 def to_dot
50 dot = <<~DOT
51 <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
52 <tr><td colspan="2"><b>#{name}</b></td></tr>
53 DOT
54
55 if fields.any?
56 "#{dot} #{fields.map(&:to_dot).join("\n ")}\n</table>"
57 else
58 "#{dot}</table>"
59 end
60 end
61 end
62
63 class Digraph # :nodoc:
64 attr_reader :nodes, :waypoints, :edges
65
66 def initialize
67 @nodes = []
68 @waypoints = []
69 @edges = []
70 end
71
72 def node(value)
73 nodes << value
74 end
75
76 def waypoint(value)
77 waypoints << value
78 end
79
80 def edge(value)
81 edges << value
82 end
83
84 def to_dot
85 <<~DOT
86 digraph "Prism" {
87 node [
88 fontname=\"Courier New\"
89 shape=plain
90 style=filled
91 fillcolor=gray95
92 ];
93
94 #{nodes.map { |node| node.gsub(/\n/, "\n ") }.join("\n ")}
95 node [shape=point];
96 #{waypoints.join("\n ")}
97
98 #{edges.join("\n ")}
99 }
100 DOT
101 end
102 end
103
104 private_constant :Field, :Table, :Digraph
105
106 # The digraph that is being built.
107 attr_reader :digraph
108
109 # Initialize a new dot visitor.
110 def initialize
111 @digraph = Digraph.new
112 end
113
114 # Convert this visitor into a graphviz dot graph string.
115 def to_dot
116 digraph.to_dot
117 end
118
119 # Visit a AliasGlobalVariableNode node.
120 def visit_alias_global_variable_node(node)
121 table = Table.new("AliasGlobalVariableNode")
122 id = node_id(node)
123
124 # new_name
125 table.field("new_name", port: true)
126 digraph.edge("#{id}:new_name -> #{node_id(node.new_name)};")
127
128 # old_name
129 table.field("old_name", port: true)
130 digraph.edge("#{id}:old_name -> #{node_id(node.old_name)};")
131
132 # keyword_loc
133 table.field("keyword_loc", location_inspect(node.keyword_loc))
134
135 digraph.nodes << <<~DOT
136 #{id} [
137 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
138 ];
139 DOT
140
141 super
142 end
143
144 # Visit a AliasMethodNode node.
145 def visit_alias_method_node(node)
146 table = Table.new("AliasMethodNode")
147 id = node_id(node)
148
149 # new_name
150 table.field("new_name", port: true)
151 digraph.edge("#{id}:new_name -> #{node_id(node.new_name)};")
152
153 # old_name
154 table.field("old_name", port: true)
155 digraph.edge("#{id}:old_name -> #{node_id(node.old_name)};")
156
157 # keyword_loc
158 table.field("keyword_loc", location_inspect(node.keyword_loc))
159
160 digraph.nodes << <<~DOT
161 #{id} [
162 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
163 ];
164 DOT
165
166 super
167 end
168
169 # Visit a AlternationPatternNode node.
170 def visit_alternation_pattern_node(node)
171 table = Table.new("AlternationPatternNode")
172 id = node_id(node)
173
174 # left
175 table.field("left", port: true)
176 digraph.edge("#{id}:left -> #{node_id(node.left)};")
177
178 # right
179 table.field("right", port: true)
180 digraph.edge("#{id}:right -> #{node_id(node.right)};")
181
182 # operator_loc
183 table.field("operator_loc", location_inspect(node.operator_loc))
184
185 digraph.nodes << <<~DOT
186 #{id} [
187 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
188 ];
189 DOT
190
191 super
192 end
193
194 # Visit a AndNode node.
195 def visit_and_node(node)
196 table = Table.new("AndNode")
197 id = node_id(node)
198
199 # left
200 table.field("left", port: true)
201 digraph.edge("#{id}:left -> #{node_id(node.left)};")
202
203 # right
204 table.field("right", port: true)
205 digraph.edge("#{id}:right -> #{node_id(node.right)};")
206
207 # operator_loc
208 table.field("operator_loc", location_inspect(node.operator_loc))
209
210 digraph.nodes << <<~DOT
211 #{id} [
212 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
213 ];
214 DOT
215
216 super
217 end
218
219 # Visit a ArgumentsNode node.
220 def visit_arguments_node(node)
221 table = Table.new("ArgumentsNode")
222 id = node_id(node)
223
224 # flags
225 table.field("flags", arguments_node_flags_inspect(node))
226
227 # arguments
228 if node.arguments.any?
229 table.field("arguments", port: true)
230
231 waypoint = "#{id}_arguments"
232 digraph.waypoint("#{waypoint};")
233
234 digraph.edge("#{id}:arguments -> #{waypoint};")
235 node.arguments.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
236 else
237 table.field("arguments", "[]")
238 end
239
240 digraph.nodes << <<~DOT
241 #{id} [
242 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
243 ];
244 DOT
245
246 super
247 end
248
249 # Visit a ArrayNode node.
250 def visit_array_node(node)
251 table = Table.new("ArrayNode")
252 id = node_id(node)
253
254 # flags
255 table.field("flags", array_node_flags_inspect(node))
256
257 # elements
258 if node.elements.any?
259 table.field("elements", port: true)
260
261 waypoint = "#{id}_elements"
262 digraph.waypoint("#{waypoint};")
263
264 digraph.edge("#{id}:elements -> #{waypoint};")
265 node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
266 else
267 table.field("elements", "[]")
268 end
269
270 # opening_loc
271 unless (opening_loc = node.opening_loc).nil?
272 table.field("opening_loc", location_inspect(opening_loc))
273 end
274
275 # closing_loc
276 unless (closing_loc = node.closing_loc).nil?
277 table.field("closing_loc", location_inspect(closing_loc))
278 end
279
280 digraph.nodes << <<~DOT
281 #{id} [
282 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
283 ];
284 DOT
285
286 super
287 end
288
289 # Visit a ArrayPatternNode node.
290 def visit_array_pattern_node(node)
291 table = Table.new("ArrayPatternNode")
292 id = node_id(node)
293
294 # constant
295 unless (constant = node.constant).nil?
296 table.field("constant", port: true)
297 digraph.edge("#{id}:constant -> #{node_id(constant)};")
298 end
299
300 # requireds
301 if node.requireds.any?
302 table.field("requireds", port: true)
303
304 waypoint = "#{id}_requireds"
305 digraph.waypoint("#{waypoint};")
306
307 digraph.edge("#{id}:requireds -> #{waypoint};")
308 node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
309 else
310 table.field("requireds", "[]")
311 end
312
313 # rest
314 unless (rest = node.rest).nil?
315 table.field("rest", port: true)
316 digraph.edge("#{id}:rest -> #{node_id(rest)};")
317 end
318
319 # posts
320 if node.posts.any?
321 table.field("posts", port: true)
322
323 waypoint = "#{id}_posts"
324 digraph.waypoint("#{waypoint};")
325
326 digraph.edge("#{id}:posts -> #{waypoint};")
327 node.posts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
328 else
329 table.field("posts", "[]")
330 end
331
332 # opening_loc
333 unless (opening_loc = node.opening_loc).nil?
334 table.field("opening_loc", location_inspect(opening_loc))
335 end
336
337 # closing_loc
338 unless (closing_loc = node.closing_loc).nil?
339 table.field("closing_loc", location_inspect(closing_loc))
340 end
341
342 digraph.nodes << <<~DOT
343 #{id} [
344 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
345 ];
346 DOT
347
348 super
349 end
350
351 # Visit a AssocNode node.
352 def visit_assoc_node(node)
353 table = Table.new("AssocNode")
354 id = node_id(node)
355
356 # key
357 table.field("key", port: true)
358 digraph.edge("#{id}:key -> #{node_id(node.key)};")
359
360 # value
361 table.field("value", port: true)
362 digraph.edge("#{id}:value -> #{node_id(node.value)};")
363
364 # operator_loc
365 unless (operator_loc = node.operator_loc).nil?
366 table.field("operator_loc", location_inspect(operator_loc))
367 end
368
369 digraph.nodes << <<~DOT
370 #{id} [
371 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
372 ];
373 DOT
374
375 super
376 end
377
378 # Visit a AssocSplatNode node.
379 def visit_assoc_splat_node(node)
380 table = Table.new("AssocSplatNode")
381 id = node_id(node)
382
383 # value
384 unless (value = node.value).nil?
385 table.field("value", port: true)
386 digraph.edge("#{id}:value -> #{node_id(value)};")
387 end
388
389 # operator_loc
390 table.field("operator_loc", location_inspect(node.operator_loc))
391
392 digraph.nodes << <<~DOT
393 #{id} [
394 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
395 ];
396 DOT
397
398 super
399 end
400
401 # Visit a BackReferenceReadNode node.
402 def visit_back_reference_read_node(node)
403 table = Table.new("BackReferenceReadNode")
404 id = node_id(node)
405
406 # name
407 table.field("name", node.name.inspect)
408
409 digraph.nodes << <<~DOT
410 #{id} [
411 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
412 ];
413 DOT
414
415 super
416 end
417
418 # Visit a BeginNode node.
419 def visit_begin_node(node)
420 table = Table.new("BeginNode")
421 id = node_id(node)
422
423 # begin_keyword_loc
424 unless (begin_keyword_loc = node.begin_keyword_loc).nil?
425 table.field("begin_keyword_loc", location_inspect(begin_keyword_loc))
426 end
427
428 # statements
429 unless (statements = node.statements).nil?
430 table.field("statements", port: true)
431 digraph.edge("#{id}:statements -> #{node_id(statements)};")
432 end
433
434 # rescue_clause
435 unless (rescue_clause = node.rescue_clause).nil?
436 table.field("rescue_clause", port: true)
437 digraph.edge("#{id}:rescue_clause -> #{node_id(rescue_clause)};")
438 end
439
440 # else_clause
441 unless (else_clause = node.else_clause).nil?
442 table.field("else_clause", port: true)
443 digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
444 end
445
446 # ensure_clause
447 unless (ensure_clause = node.ensure_clause).nil?
448 table.field("ensure_clause", port: true)
449 digraph.edge("#{id}:ensure_clause -> #{node_id(ensure_clause)};")
450 end
451
452 # end_keyword_loc
453 unless (end_keyword_loc = node.end_keyword_loc).nil?
454 table.field("end_keyword_loc", location_inspect(end_keyword_loc))
455 end
456
457 digraph.nodes << <<~DOT
458 #{id} [
459 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
460 ];
461 DOT
462
463 super
464 end
465
466 # Visit a BlockArgumentNode node.
467 def visit_block_argument_node(node)
468 table = Table.new("BlockArgumentNode")
469 id = node_id(node)
470
471 # expression
472 unless (expression = node.expression).nil?
473 table.field("expression", port: true)
474 digraph.edge("#{id}:expression -> #{node_id(expression)};")
475 end
476
477 # operator_loc
478 table.field("operator_loc", location_inspect(node.operator_loc))
479
480 digraph.nodes << <<~DOT
481 #{id} [
482 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
483 ];
484 DOT
485
486 super
487 end
488
489 # Visit a BlockLocalVariableNode node.
490 def visit_block_local_variable_node(node)
491 table = Table.new("BlockLocalVariableNode")
492 id = node_id(node)
493
494 # flags
495 table.field("flags", parameter_flags_inspect(node))
496
497 # name
498 table.field("name", node.name.inspect)
499
500 digraph.nodes << <<~DOT
501 #{id} [
502 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
503 ];
504 DOT
505
506 super
507 end
508
509 # Visit a BlockNode node.
510 def visit_block_node(node)
511 table = Table.new("BlockNode")
512 id = node_id(node)
513
514 # locals
515 table.field("locals", node.locals.inspect)
516
517 # parameters
518 unless (parameters = node.parameters).nil?
519 table.field("parameters", port: true)
520 digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
521 end
522
523 # body
524 unless (body = node.body).nil?
525 table.field("body", port: true)
526 digraph.edge("#{id}:body -> #{node_id(body)};")
527 end
528
529 # opening_loc
530 table.field("opening_loc", location_inspect(node.opening_loc))
531
532 # closing_loc
533 table.field("closing_loc", location_inspect(node.closing_loc))
534
535 digraph.nodes << <<~DOT
536 #{id} [
537 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
538 ];
539 DOT
540
541 super
542 end
543
544 # Visit a BlockParameterNode node.
545 def visit_block_parameter_node(node)
546 table = Table.new("BlockParameterNode")
547 id = node_id(node)
548
549 # flags
550 table.field("flags", parameter_flags_inspect(node))
551
552 # name
553 table.field("name", node.name.inspect)
554
555 # name_loc
556 unless (name_loc = node.name_loc).nil?
557 table.field("name_loc", location_inspect(name_loc))
558 end
559
560 # operator_loc
561 table.field("operator_loc", location_inspect(node.operator_loc))
562
563 digraph.nodes << <<~DOT
564 #{id} [
565 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
566 ];
567 DOT
568
569 super
570 end
571
572 # Visit a BlockParametersNode node.
573 def visit_block_parameters_node(node)
574 table = Table.new("BlockParametersNode")
575 id = node_id(node)
576
577 # parameters
578 unless (parameters = node.parameters).nil?
579 table.field("parameters", port: true)
580 digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
581 end
582
583 # locals
584 if node.locals.any?
585 table.field("locals", port: true)
586
587 waypoint = "#{id}_locals"
588 digraph.waypoint("#{waypoint};")
589
590 digraph.edge("#{id}:locals -> #{waypoint};")
591 node.locals.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
592 else
593 table.field("locals", "[]")
594 end
595
596 # opening_loc
597 unless (opening_loc = node.opening_loc).nil?
598 table.field("opening_loc", location_inspect(opening_loc))
599 end
600
601 # closing_loc
602 unless (closing_loc = node.closing_loc).nil?
603 table.field("closing_loc", location_inspect(closing_loc))
604 end
605
606 digraph.nodes << <<~DOT
607 #{id} [
608 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
609 ];
610 DOT
611
612 super
613 end
614
615 # Visit a BreakNode node.
616 def visit_break_node(node)
617 table = Table.new("BreakNode")
618 id = node_id(node)
619
620 # arguments
621 unless (arguments = node.arguments).nil?
622 table.field("arguments", port: true)
623 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
624 end
625
626 # keyword_loc
627 table.field("keyword_loc", location_inspect(node.keyword_loc))
628
629 digraph.nodes << <<~DOT
630 #{id} [
631 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
632 ];
633 DOT
634
635 super
636 end
637
638 # Visit a CallAndWriteNode node.
639 def visit_call_and_write_node(node)
640 table = Table.new("CallAndWriteNode")
641 id = node_id(node)
642
643 # flags
644 table.field("flags", call_node_flags_inspect(node))
645
646 # receiver
647 unless (receiver = node.receiver).nil?
648 table.field("receiver", port: true)
649 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
650 end
651
652 # call_operator_loc
653 unless (call_operator_loc = node.call_operator_loc).nil?
654 table.field("call_operator_loc", location_inspect(call_operator_loc))
655 end
656
657 # message_loc
658 unless (message_loc = node.message_loc).nil?
659 table.field("message_loc", location_inspect(message_loc))
660 end
661
662 # read_name
663 table.field("read_name", node.read_name.inspect)
664
665 # write_name
666 table.field("write_name", node.write_name.inspect)
667
668 # operator_loc
669 table.field("operator_loc", location_inspect(node.operator_loc))
670
671 # value
672 table.field("value", port: true)
673 digraph.edge("#{id}:value -> #{node_id(node.value)};")
674
675 digraph.nodes << <<~DOT
676 #{id} [
677 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
678 ];
679 DOT
680
681 super
682 end
683
684 # Visit a CallNode node.
685 def visit_call_node(node)
686 table = Table.new("CallNode")
687 id = node_id(node)
688
689 # flags
690 table.field("flags", call_node_flags_inspect(node))
691
692 # receiver
693 unless (receiver = node.receiver).nil?
694 table.field("receiver", port: true)
695 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
696 end
697
698 # call_operator_loc
699 unless (call_operator_loc = node.call_operator_loc).nil?
700 table.field("call_operator_loc", location_inspect(call_operator_loc))
701 end
702
703 # name
704 table.field("name", node.name.inspect)
705
706 # message_loc
707 unless (message_loc = node.message_loc).nil?
708 table.field("message_loc", location_inspect(message_loc))
709 end
710
711 # opening_loc
712 unless (opening_loc = node.opening_loc).nil?
713 table.field("opening_loc", location_inspect(opening_loc))
714 end
715
716 # arguments
717 unless (arguments = node.arguments).nil?
718 table.field("arguments", port: true)
719 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
720 end
721
722 # closing_loc
723 unless (closing_loc = node.closing_loc).nil?
724 table.field("closing_loc", location_inspect(closing_loc))
725 end
726
727 # equal_loc
728 unless (equal_loc = node.equal_loc).nil?
729 table.field("equal_loc", location_inspect(equal_loc))
730 end
731
732 # block
733 unless (block = node.block).nil?
734 table.field("block", port: true)
735 digraph.edge("#{id}:block -> #{node_id(block)};")
736 end
737
738 digraph.nodes << <<~DOT
739 #{id} [
740 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
741 ];
742 DOT
743
744 super
745 end
746
747 # Visit a CallOperatorWriteNode node.
748 def visit_call_operator_write_node(node)
749 table = Table.new("CallOperatorWriteNode")
750 id = node_id(node)
751
752 # flags
753 table.field("flags", call_node_flags_inspect(node))
754
755 # receiver
756 unless (receiver = node.receiver).nil?
757 table.field("receiver", port: true)
758 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
759 end
760
761 # call_operator_loc
762 unless (call_operator_loc = node.call_operator_loc).nil?
763 table.field("call_operator_loc", location_inspect(call_operator_loc))
764 end
765
766 # message_loc
767 unless (message_loc = node.message_loc).nil?
768 table.field("message_loc", location_inspect(message_loc))
769 end
770
771 # read_name
772 table.field("read_name", node.read_name.inspect)
773
774 # write_name
775 table.field("write_name", node.write_name.inspect)
776
777 # binary_operator
778 table.field("binary_operator", node.binary_operator.inspect)
779
780 # binary_operator_loc
781 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
782
783 # value
784 table.field("value", port: true)
785 digraph.edge("#{id}:value -> #{node_id(node.value)};")
786
787 digraph.nodes << <<~DOT
788 #{id} [
789 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
790 ];
791 DOT
792
793 super
794 end
795
796 # Visit a CallOrWriteNode node.
797 def visit_call_or_write_node(node)
798 table = Table.new("CallOrWriteNode")
799 id = node_id(node)
800
801 # flags
802 table.field("flags", call_node_flags_inspect(node))
803
804 # receiver
805 unless (receiver = node.receiver).nil?
806 table.field("receiver", port: true)
807 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
808 end
809
810 # call_operator_loc
811 unless (call_operator_loc = node.call_operator_loc).nil?
812 table.field("call_operator_loc", location_inspect(call_operator_loc))
813 end
814
815 # message_loc
816 unless (message_loc = node.message_loc).nil?
817 table.field("message_loc", location_inspect(message_loc))
818 end
819
820 # read_name
821 table.field("read_name", node.read_name.inspect)
822
823 # write_name
824 table.field("write_name", node.write_name.inspect)
825
826 # operator_loc
827 table.field("operator_loc", location_inspect(node.operator_loc))
828
829 # value
830 table.field("value", port: true)
831 digraph.edge("#{id}:value -> #{node_id(node.value)};")
832
833 digraph.nodes << <<~DOT
834 #{id} [
835 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
836 ];
837 DOT
838
839 super
840 end
841
842 # Visit a CallTargetNode node.
843 def visit_call_target_node(node)
844 table = Table.new("CallTargetNode")
845 id = node_id(node)
846
847 # flags
848 table.field("flags", call_node_flags_inspect(node))
849
850 # receiver
851 table.field("receiver", port: true)
852 digraph.edge("#{id}:receiver -> #{node_id(node.receiver)};")
853
854 # call_operator_loc
855 table.field("call_operator_loc", location_inspect(node.call_operator_loc))
856
857 # name
858 table.field("name", node.name.inspect)
859
860 # message_loc
861 table.field("message_loc", location_inspect(node.message_loc))
862
863 digraph.nodes << <<~DOT
864 #{id} [
865 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
866 ];
867 DOT
868
869 super
870 end
871
872 # Visit a CapturePatternNode node.
873 def visit_capture_pattern_node(node)
874 table = Table.new("CapturePatternNode")
875 id = node_id(node)
876
877 # value
878 table.field("value", port: true)
879 digraph.edge("#{id}:value -> #{node_id(node.value)};")
880
881 # target
882 table.field("target", port: true)
883 digraph.edge("#{id}:target -> #{node_id(node.target)};")
884
885 # operator_loc
886 table.field("operator_loc", location_inspect(node.operator_loc))
887
888 digraph.nodes << <<~DOT
889 #{id} [
890 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
891 ];
892 DOT
893
894 super
895 end
896
897 # Visit a CaseMatchNode node.
898 def visit_case_match_node(node)
899 table = Table.new("CaseMatchNode")
900 id = node_id(node)
901
902 # predicate
903 unless (predicate = node.predicate).nil?
904 table.field("predicate", port: true)
905 digraph.edge("#{id}:predicate -> #{node_id(predicate)};")
906 end
907
908 # conditions
909 if node.conditions.any?
910 table.field("conditions", port: true)
911
912 waypoint = "#{id}_conditions"
913 digraph.waypoint("#{waypoint};")
914
915 digraph.edge("#{id}:conditions -> #{waypoint};")
916 node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
917 else
918 table.field("conditions", "[]")
919 end
920
921 # else_clause
922 unless (else_clause = node.else_clause).nil?
923 table.field("else_clause", port: true)
924 digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
925 end
926
927 # case_keyword_loc
928 table.field("case_keyword_loc", location_inspect(node.case_keyword_loc))
929
930 # end_keyword_loc
931 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
932
933 digraph.nodes << <<~DOT
934 #{id} [
935 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
936 ];
937 DOT
938
939 super
940 end
941
942 # Visit a CaseNode node.
943 def visit_case_node(node)
944 table = Table.new("CaseNode")
945 id = node_id(node)
946
947 # predicate
948 unless (predicate = node.predicate).nil?
949 table.field("predicate", port: true)
950 digraph.edge("#{id}:predicate -> #{node_id(predicate)};")
951 end
952
953 # conditions
954 if node.conditions.any?
955 table.field("conditions", port: true)
956
957 waypoint = "#{id}_conditions"
958 digraph.waypoint("#{waypoint};")
959
960 digraph.edge("#{id}:conditions -> #{waypoint};")
961 node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
962 else
963 table.field("conditions", "[]")
964 end
965
966 # else_clause
967 unless (else_clause = node.else_clause).nil?
968 table.field("else_clause", port: true)
969 digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
970 end
971
972 # case_keyword_loc
973 table.field("case_keyword_loc", location_inspect(node.case_keyword_loc))
974
975 # end_keyword_loc
976 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
977
978 digraph.nodes << <<~DOT
979 #{id} [
980 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
981 ];
982 DOT
983
984 super
985 end
986
987 # Visit a ClassNode node.
988 def visit_class_node(node)
989 table = Table.new("ClassNode")
990 id = node_id(node)
991
992 # locals
993 table.field("locals", node.locals.inspect)
994
995 # class_keyword_loc
996 table.field("class_keyword_loc", location_inspect(node.class_keyword_loc))
997
998 # constant_path
999 table.field("constant_path", port: true)
1000 digraph.edge("#{id}:constant_path -> #{node_id(node.constant_path)};")
1001
1002 # inheritance_operator_loc
1003 unless (inheritance_operator_loc = node.inheritance_operator_loc).nil?
1004 table.field("inheritance_operator_loc", location_inspect(inheritance_operator_loc))
1005 end
1006
1007 # superclass
1008 unless (superclass = node.superclass).nil?
1009 table.field("superclass", port: true)
1010 digraph.edge("#{id}:superclass -> #{node_id(superclass)};")
1011 end
1012
1013 # body
1014 unless (body = node.body).nil?
1015 table.field("body", port: true)
1016 digraph.edge("#{id}:body -> #{node_id(body)};")
1017 end
1018
1019 # end_keyword_loc
1020 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1021
1022 # name
1023 table.field("name", node.name.inspect)
1024
1025 digraph.nodes << <<~DOT
1026 #{id} [
1027 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1028 ];
1029 DOT
1030
1031 super
1032 end
1033
1034 # Visit a ClassVariableAndWriteNode node.
1035 def visit_class_variable_and_write_node(node)
1036 table = Table.new("ClassVariableAndWriteNode")
1037 id = node_id(node)
1038
1039 # name
1040 table.field("name", node.name.inspect)
1041
1042 # name_loc
1043 table.field("name_loc", location_inspect(node.name_loc))
1044
1045 # operator_loc
1046 table.field("operator_loc", location_inspect(node.operator_loc))
1047
1048 # value
1049 table.field("value", port: true)
1050 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1051
1052 digraph.nodes << <<~DOT
1053 #{id} [
1054 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1055 ];
1056 DOT
1057
1058 super
1059 end
1060
1061 # Visit a ClassVariableOperatorWriteNode node.
1062 def visit_class_variable_operator_write_node(node)
1063 table = Table.new("ClassVariableOperatorWriteNode")
1064 id = node_id(node)
1065
1066 # name
1067 table.field("name", node.name.inspect)
1068
1069 # name_loc
1070 table.field("name_loc", location_inspect(node.name_loc))
1071
1072 # binary_operator_loc
1073 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1074
1075 # value
1076 table.field("value", port: true)
1077 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1078
1079 # binary_operator
1080 table.field("binary_operator", node.binary_operator.inspect)
1081
1082 digraph.nodes << <<~DOT
1083 #{id} [
1084 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1085 ];
1086 DOT
1087
1088 super
1089 end
1090
1091 # Visit a ClassVariableOrWriteNode node.
1092 def visit_class_variable_or_write_node(node)
1093 table = Table.new("ClassVariableOrWriteNode")
1094 id = node_id(node)
1095
1096 # name
1097 table.field("name", node.name.inspect)
1098
1099 # name_loc
1100 table.field("name_loc", location_inspect(node.name_loc))
1101
1102 # operator_loc
1103 table.field("operator_loc", location_inspect(node.operator_loc))
1104
1105 # value
1106 table.field("value", port: true)
1107 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1108
1109 digraph.nodes << <<~DOT
1110 #{id} [
1111 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1112 ];
1113 DOT
1114
1115 super
1116 end
1117
1118 # Visit a ClassVariableReadNode node.
1119 def visit_class_variable_read_node(node)
1120 table = Table.new("ClassVariableReadNode")
1121 id = node_id(node)
1122
1123 # name
1124 table.field("name", node.name.inspect)
1125
1126 digraph.nodes << <<~DOT
1127 #{id} [
1128 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1129 ];
1130 DOT
1131
1132 super
1133 end
1134
1135 # Visit a ClassVariableTargetNode node.
1136 def visit_class_variable_target_node(node)
1137 table = Table.new("ClassVariableTargetNode")
1138 id = node_id(node)
1139
1140 # name
1141 table.field("name", node.name.inspect)
1142
1143 digraph.nodes << <<~DOT
1144 #{id} [
1145 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1146 ];
1147 DOT
1148
1149 super
1150 end
1151
1152 # Visit a ClassVariableWriteNode node.
1153 def visit_class_variable_write_node(node)
1154 table = Table.new("ClassVariableWriteNode")
1155 id = node_id(node)
1156
1157 # name
1158 table.field("name", node.name.inspect)
1159
1160 # name_loc
1161 table.field("name_loc", location_inspect(node.name_loc))
1162
1163 # value
1164 table.field("value", port: true)
1165 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1166
1167 # operator_loc
1168 table.field("operator_loc", location_inspect(node.operator_loc))
1169
1170 digraph.nodes << <<~DOT
1171 #{id} [
1172 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1173 ];
1174 DOT
1175
1176 super
1177 end
1178
1179 # Visit a ConstantAndWriteNode node.
1180 def visit_constant_and_write_node(node)
1181 table = Table.new("ConstantAndWriteNode")
1182 id = node_id(node)
1183
1184 # name
1185 table.field("name", node.name.inspect)
1186
1187 # name_loc
1188 table.field("name_loc", location_inspect(node.name_loc))
1189
1190 # operator_loc
1191 table.field("operator_loc", location_inspect(node.operator_loc))
1192
1193 # value
1194 table.field("value", port: true)
1195 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1196
1197 digraph.nodes << <<~DOT
1198 #{id} [
1199 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1200 ];
1201 DOT
1202
1203 super
1204 end
1205
1206 # Visit a ConstantOperatorWriteNode node.
1207 def visit_constant_operator_write_node(node)
1208 table = Table.new("ConstantOperatorWriteNode")
1209 id = node_id(node)
1210
1211 # name
1212 table.field("name", node.name.inspect)
1213
1214 # name_loc
1215 table.field("name_loc", location_inspect(node.name_loc))
1216
1217 # binary_operator_loc
1218 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1219
1220 # value
1221 table.field("value", port: true)
1222 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1223
1224 # binary_operator
1225 table.field("binary_operator", node.binary_operator.inspect)
1226
1227 digraph.nodes << <<~DOT
1228 #{id} [
1229 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1230 ];
1231 DOT
1232
1233 super
1234 end
1235
1236 # Visit a ConstantOrWriteNode node.
1237 def visit_constant_or_write_node(node)
1238 table = Table.new("ConstantOrWriteNode")
1239 id = node_id(node)
1240
1241 # name
1242 table.field("name", node.name.inspect)
1243
1244 # name_loc
1245 table.field("name_loc", location_inspect(node.name_loc))
1246
1247 # operator_loc
1248 table.field("operator_loc", location_inspect(node.operator_loc))
1249
1250 # value
1251 table.field("value", port: true)
1252 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1253
1254 digraph.nodes << <<~DOT
1255 #{id} [
1256 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1257 ];
1258 DOT
1259
1260 super
1261 end
1262
1263 # Visit a ConstantPathAndWriteNode node.
1264 def visit_constant_path_and_write_node(node)
1265 table = Table.new("ConstantPathAndWriteNode")
1266 id = node_id(node)
1267
1268 # target
1269 table.field("target", port: true)
1270 digraph.edge("#{id}:target -> #{node_id(node.target)};")
1271
1272 # operator_loc
1273 table.field("operator_loc", location_inspect(node.operator_loc))
1274
1275 # value
1276 table.field("value", port: true)
1277 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1278
1279 digraph.nodes << <<~DOT
1280 #{id} [
1281 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1282 ];
1283 DOT
1284
1285 super
1286 end
1287
1288 # Visit a ConstantPathNode node.
1289 def visit_constant_path_node(node)
1290 table = Table.new("ConstantPathNode")
1291 id = node_id(node)
1292
1293 # parent
1294 unless (parent = node.parent).nil?
1295 table.field("parent", port: true)
1296 digraph.edge("#{id}:parent -> #{node_id(parent)};")
1297 end
1298
1299 # name
1300 table.field("name", node.name.inspect)
1301
1302 # delimiter_loc
1303 table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1304
1305 # name_loc
1306 table.field("name_loc", location_inspect(node.name_loc))
1307
1308 digraph.nodes << <<~DOT
1309 #{id} [
1310 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1311 ];
1312 DOT
1313
1314 super
1315 end
1316
1317 # Visit a ConstantPathOperatorWriteNode node.
1318 def visit_constant_path_operator_write_node(node)
1319 table = Table.new("ConstantPathOperatorWriteNode")
1320 id = node_id(node)
1321
1322 # target
1323 table.field("target", port: true)
1324 digraph.edge("#{id}:target -> #{node_id(node.target)};")
1325
1326 # binary_operator_loc
1327 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1328
1329 # value
1330 table.field("value", port: true)
1331 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1332
1333 # binary_operator
1334 table.field("binary_operator", node.binary_operator.inspect)
1335
1336 digraph.nodes << <<~DOT
1337 #{id} [
1338 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1339 ];
1340 DOT
1341
1342 super
1343 end
1344
1345 # Visit a ConstantPathOrWriteNode node.
1346 def visit_constant_path_or_write_node(node)
1347 table = Table.new("ConstantPathOrWriteNode")
1348 id = node_id(node)
1349
1350 # target
1351 table.field("target", port: true)
1352 digraph.edge("#{id}:target -> #{node_id(node.target)};")
1353
1354 # operator_loc
1355 table.field("operator_loc", location_inspect(node.operator_loc))
1356
1357 # value
1358 table.field("value", port: true)
1359 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1360
1361 digraph.nodes << <<~DOT
1362 #{id} [
1363 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1364 ];
1365 DOT
1366
1367 super
1368 end
1369
1370 # Visit a ConstantPathTargetNode node.
1371 def visit_constant_path_target_node(node)
1372 table = Table.new("ConstantPathTargetNode")
1373 id = node_id(node)
1374
1375 # parent
1376 unless (parent = node.parent).nil?
1377 table.field("parent", port: true)
1378 digraph.edge("#{id}:parent -> #{node_id(parent)};")
1379 end
1380
1381 # name
1382 table.field("name", node.name.inspect)
1383
1384 # delimiter_loc
1385 table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1386
1387 # name_loc
1388 table.field("name_loc", location_inspect(node.name_loc))
1389
1390 digraph.nodes << <<~DOT
1391 #{id} [
1392 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1393 ];
1394 DOT
1395
1396 super
1397 end
1398
1399 # Visit a ConstantPathWriteNode node.
1400 def visit_constant_path_write_node(node)
1401 table = Table.new("ConstantPathWriteNode")
1402 id = node_id(node)
1403
1404 # target
1405 table.field("target", port: true)
1406 digraph.edge("#{id}:target -> #{node_id(node.target)};")
1407
1408 # operator_loc
1409 table.field("operator_loc", location_inspect(node.operator_loc))
1410
1411 # value
1412 table.field("value", port: true)
1413 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1414
1415 digraph.nodes << <<~DOT
1416 #{id} [
1417 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1418 ];
1419 DOT
1420
1421 super
1422 end
1423
1424 # Visit a ConstantReadNode node.
1425 def visit_constant_read_node(node)
1426 table = Table.new("ConstantReadNode")
1427 id = node_id(node)
1428
1429 # name
1430 table.field("name", node.name.inspect)
1431
1432 digraph.nodes << <<~DOT
1433 #{id} [
1434 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1435 ];
1436 DOT
1437
1438 super
1439 end
1440
1441 # Visit a ConstantTargetNode node.
1442 def visit_constant_target_node(node)
1443 table = Table.new("ConstantTargetNode")
1444 id = node_id(node)
1445
1446 # name
1447 table.field("name", node.name.inspect)
1448
1449 digraph.nodes << <<~DOT
1450 #{id} [
1451 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1452 ];
1453 DOT
1454
1455 super
1456 end
1457
1458 # Visit a ConstantWriteNode node.
1459 def visit_constant_write_node(node)
1460 table = Table.new("ConstantWriteNode")
1461 id = node_id(node)
1462
1463 # name
1464 table.field("name", node.name.inspect)
1465
1466 # name_loc
1467 table.field("name_loc", location_inspect(node.name_loc))
1468
1469 # value
1470 table.field("value", port: true)
1471 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1472
1473 # operator_loc
1474 table.field("operator_loc", location_inspect(node.operator_loc))
1475
1476 digraph.nodes << <<~DOT
1477 #{id} [
1478 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1479 ];
1480 DOT
1481
1482 super
1483 end
1484
1485 # Visit a DefNode node.
1486 def visit_def_node(node)
1487 table = Table.new("DefNode")
1488 id = node_id(node)
1489
1490 # name
1491 table.field("name", node.name.inspect)
1492
1493 # name_loc
1494 table.field("name_loc", location_inspect(node.name_loc))
1495
1496 # receiver
1497 unless (receiver = node.receiver).nil?
1498 table.field("receiver", port: true)
1499 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
1500 end
1501
1502 # parameters
1503 unless (parameters = node.parameters).nil?
1504 table.field("parameters", port: true)
1505 digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
1506 end
1507
1508 # body
1509 unless (body = node.body).nil?
1510 table.field("body", port: true)
1511 digraph.edge("#{id}:body -> #{node_id(body)};")
1512 end
1513
1514 # locals
1515 table.field("locals", node.locals.inspect)
1516
1517 # def_keyword_loc
1518 table.field("def_keyword_loc", location_inspect(node.def_keyword_loc))
1519
1520 # operator_loc
1521 unless (operator_loc = node.operator_loc).nil?
1522 table.field("operator_loc", location_inspect(operator_loc))
1523 end
1524
1525 # lparen_loc
1526 unless (lparen_loc = node.lparen_loc).nil?
1527 table.field("lparen_loc", location_inspect(lparen_loc))
1528 end
1529
1530 # rparen_loc
1531 unless (rparen_loc = node.rparen_loc).nil?
1532 table.field("rparen_loc", location_inspect(rparen_loc))
1533 end
1534
1535 # equal_loc
1536 unless (equal_loc = node.equal_loc).nil?
1537 table.field("equal_loc", location_inspect(equal_loc))
1538 end
1539
1540 # end_keyword_loc
1541 unless (end_keyword_loc = node.end_keyword_loc).nil?
1542 table.field("end_keyword_loc", location_inspect(end_keyword_loc))
1543 end
1544
1545 digraph.nodes << <<~DOT
1546 #{id} [
1547 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1548 ];
1549 DOT
1550
1551 super
1552 end
1553
1554 # Visit a DefinedNode node.
1555 def visit_defined_node(node)
1556 table = Table.new("DefinedNode")
1557 id = node_id(node)
1558
1559 # lparen_loc
1560 unless (lparen_loc = node.lparen_loc).nil?
1561 table.field("lparen_loc", location_inspect(lparen_loc))
1562 end
1563
1564 # value
1565 table.field("value", port: true)
1566 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1567
1568 # rparen_loc
1569 unless (rparen_loc = node.rparen_loc).nil?
1570 table.field("rparen_loc", location_inspect(rparen_loc))
1571 end
1572
1573 # keyword_loc
1574 table.field("keyword_loc", location_inspect(node.keyword_loc))
1575
1576 digraph.nodes << <<~DOT
1577 #{id} [
1578 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1579 ];
1580 DOT
1581
1582 super
1583 end
1584
1585 # Visit a ElseNode node.
1586 def visit_else_node(node)
1587 table = Table.new("ElseNode")
1588 id = node_id(node)
1589
1590 # else_keyword_loc
1591 table.field("else_keyword_loc", location_inspect(node.else_keyword_loc))
1592
1593 # statements
1594 unless (statements = node.statements).nil?
1595 table.field("statements", port: true)
1596 digraph.edge("#{id}:statements -> #{node_id(statements)};")
1597 end
1598
1599 # end_keyword_loc
1600 unless (end_keyword_loc = node.end_keyword_loc).nil?
1601 table.field("end_keyword_loc", location_inspect(end_keyword_loc))
1602 end
1603
1604 digraph.nodes << <<~DOT
1605 #{id} [
1606 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1607 ];
1608 DOT
1609
1610 super
1611 end
1612
1613 # Visit a EmbeddedStatementsNode node.
1614 def visit_embedded_statements_node(node)
1615 table = Table.new("EmbeddedStatementsNode")
1616 id = node_id(node)
1617
1618 # opening_loc
1619 table.field("opening_loc", location_inspect(node.opening_loc))
1620
1621 # statements
1622 unless (statements = node.statements).nil?
1623 table.field("statements", port: true)
1624 digraph.edge("#{id}:statements -> #{node_id(statements)};")
1625 end
1626
1627 # closing_loc
1628 table.field("closing_loc", location_inspect(node.closing_loc))
1629
1630 digraph.nodes << <<~DOT
1631 #{id} [
1632 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1633 ];
1634 DOT
1635
1636 super
1637 end
1638
1639 # Visit a EmbeddedVariableNode node.
1640 def visit_embedded_variable_node(node)
1641 table = Table.new("EmbeddedVariableNode")
1642 id = node_id(node)
1643
1644 # operator_loc
1645 table.field("operator_loc", location_inspect(node.operator_loc))
1646
1647 # variable
1648 table.field("variable", port: true)
1649 digraph.edge("#{id}:variable -> #{node_id(node.variable)};")
1650
1651 digraph.nodes << <<~DOT
1652 #{id} [
1653 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1654 ];
1655 DOT
1656
1657 super
1658 end
1659
1660 # Visit a EnsureNode node.
1661 def visit_ensure_node(node)
1662 table = Table.new("EnsureNode")
1663 id = node_id(node)
1664
1665 # ensure_keyword_loc
1666 table.field("ensure_keyword_loc", location_inspect(node.ensure_keyword_loc))
1667
1668 # statements
1669 unless (statements = node.statements).nil?
1670 table.field("statements", port: true)
1671 digraph.edge("#{id}:statements -> #{node_id(statements)};")
1672 end
1673
1674 # end_keyword_loc
1675 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1676
1677 digraph.nodes << <<~DOT
1678 #{id} [
1679 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1680 ];
1681 DOT
1682
1683 super
1684 end
1685
1686 # Visit a FalseNode node.
1687 def visit_false_node(node)
1688 table = Table.new("FalseNode")
1689 id = node_id(node)
1690
1691 digraph.nodes << <<~DOT
1692 #{id} [
1693 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1694 ];
1695 DOT
1696
1697 super
1698 end
1699
1700 # Visit a FindPatternNode node.
1701 def visit_find_pattern_node(node)
1702 table = Table.new("FindPatternNode")
1703 id = node_id(node)
1704
1705 # constant
1706 unless (constant = node.constant).nil?
1707 table.field("constant", port: true)
1708 digraph.edge("#{id}:constant -> #{node_id(constant)};")
1709 end
1710
1711 # left
1712 table.field("left", port: true)
1713 digraph.edge("#{id}:left -> #{node_id(node.left)};")
1714
1715 # requireds
1716 if node.requireds.any?
1717 table.field("requireds", port: true)
1718
1719 waypoint = "#{id}_requireds"
1720 digraph.waypoint("#{waypoint};")
1721
1722 digraph.edge("#{id}:requireds -> #{waypoint};")
1723 node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
1724 else
1725 table.field("requireds", "[]")
1726 end
1727
1728 # right
1729 table.field("right", port: true)
1730 digraph.edge("#{id}:right -> #{node_id(node.right)};")
1731
1732 # opening_loc
1733 unless (opening_loc = node.opening_loc).nil?
1734 table.field("opening_loc", location_inspect(opening_loc))
1735 end
1736
1737 # closing_loc
1738 unless (closing_loc = node.closing_loc).nil?
1739 table.field("closing_loc", location_inspect(closing_loc))
1740 end
1741
1742 digraph.nodes << <<~DOT
1743 #{id} [
1744 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1745 ];
1746 DOT
1747
1748 super
1749 end
1750
1751 # Visit a FlipFlopNode node.
1752 def visit_flip_flop_node(node)
1753 table = Table.new("FlipFlopNode")
1754 id = node_id(node)
1755
1756 # flags
1757 table.field("flags", range_flags_inspect(node))
1758
1759 # left
1760 unless (left = node.left).nil?
1761 table.field("left", port: true)
1762 digraph.edge("#{id}:left -> #{node_id(left)};")
1763 end
1764
1765 # right
1766 unless (right = node.right).nil?
1767 table.field("right", port: true)
1768 digraph.edge("#{id}:right -> #{node_id(right)};")
1769 end
1770
1771 # operator_loc
1772 table.field("operator_loc", location_inspect(node.operator_loc))
1773
1774 digraph.nodes << <<~DOT
1775 #{id} [
1776 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1777 ];
1778 DOT
1779
1780 super
1781 end
1782
1783 # Visit a FloatNode node.
1784 def visit_float_node(node)
1785 table = Table.new("FloatNode")
1786 id = node_id(node)
1787
1788 # value
1789 table.field("value", node.value.inspect)
1790
1791 digraph.nodes << <<~DOT
1792 #{id} [
1793 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1794 ];
1795 DOT
1796
1797 super
1798 end
1799
1800 # Visit a ForNode node.
1801 def visit_for_node(node)
1802 table = Table.new("ForNode")
1803 id = node_id(node)
1804
1805 # index
1806 table.field("index", port: true)
1807 digraph.edge("#{id}:index -> #{node_id(node.index)};")
1808
1809 # collection
1810 table.field("collection", port: true)
1811 digraph.edge("#{id}:collection -> #{node_id(node.collection)};")
1812
1813 # statements
1814 unless (statements = node.statements).nil?
1815 table.field("statements", port: true)
1816 digraph.edge("#{id}:statements -> #{node_id(statements)};")
1817 end
1818
1819 # for_keyword_loc
1820 table.field("for_keyword_loc", location_inspect(node.for_keyword_loc))
1821
1822 # in_keyword_loc
1823 table.field("in_keyword_loc", location_inspect(node.in_keyword_loc))
1824
1825 # do_keyword_loc
1826 unless (do_keyword_loc = node.do_keyword_loc).nil?
1827 table.field("do_keyword_loc", location_inspect(do_keyword_loc))
1828 end
1829
1830 # end_keyword_loc
1831 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
1832
1833 digraph.nodes << <<~DOT
1834 #{id} [
1835 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1836 ];
1837 DOT
1838
1839 super
1840 end
1841
1842 # Visit a ForwardingArgumentsNode node.
1843 def visit_forwarding_arguments_node(node)
1844 table = Table.new("ForwardingArgumentsNode")
1845 id = node_id(node)
1846
1847 digraph.nodes << <<~DOT
1848 #{id} [
1849 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1850 ];
1851 DOT
1852
1853 super
1854 end
1855
1856 # Visit a ForwardingParameterNode node.
1857 def visit_forwarding_parameter_node(node)
1858 table = Table.new("ForwardingParameterNode")
1859 id = node_id(node)
1860
1861 digraph.nodes << <<~DOT
1862 #{id} [
1863 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1864 ];
1865 DOT
1866
1867 super
1868 end
1869
1870 # Visit a ForwardingSuperNode node.
1871 def visit_forwarding_super_node(node)
1872 table = Table.new("ForwardingSuperNode")
1873 id = node_id(node)
1874
1875 # block
1876 unless (block = node.block).nil?
1877 table.field("block", port: true)
1878 digraph.edge("#{id}:block -> #{node_id(block)};")
1879 end
1880
1881 digraph.nodes << <<~DOT
1882 #{id} [
1883 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1884 ];
1885 DOT
1886
1887 super
1888 end
1889
1890 # Visit a GlobalVariableAndWriteNode node.
1891 def visit_global_variable_and_write_node(node)
1892 table = Table.new("GlobalVariableAndWriteNode")
1893 id = node_id(node)
1894
1895 # name
1896 table.field("name", node.name.inspect)
1897
1898 # name_loc
1899 table.field("name_loc", location_inspect(node.name_loc))
1900
1901 # operator_loc
1902 table.field("operator_loc", location_inspect(node.operator_loc))
1903
1904 # value
1905 table.field("value", port: true)
1906 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1907
1908 digraph.nodes << <<~DOT
1909 #{id} [
1910 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1911 ];
1912 DOT
1913
1914 super
1915 end
1916
1917 # Visit a GlobalVariableOperatorWriteNode node.
1918 def visit_global_variable_operator_write_node(node)
1919 table = Table.new("GlobalVariableOperatorWriteNode")
1920 id = node_id(node)
1921
1922 # name
1923 table.field("name", node.name.inspect)
1924
1925 # name_loc
1926 table.field("name_loc", location_inspect(node.name_loc))
1927
1928 # binary_operator_loc
1929 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
1930
1931 # value
1932 table.field("value", port: true)
1933 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1934
1935 # binary_operator
1936 table.field("binary_operator", node.binary_operator.inspect)
1937
1938 digraph.nodes << <<~DOT
1939 #{id} [
1940 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1941 ];
1942 DOT
1943
1944 super
1945 end
1946
1947 # Visit a GlobalVariableOrWriteNode node.
1948 def visit_global_variable_or_write_node(node)
1949 table = Table.new("GlobalVariableOrWriteNode")
1950 id = node_id(node)
1951
1952 # name
1953 table.field("name", node.name.inspect)
1954
1955 # name_loc
1956 table.field("name_loc", location_inspect(node.name_loc))
1957
1958 # operator_loc
1959 table.field("operator_loc", location_inspect(node.operator_loc))
1960
1961 # value
1962 table.field("value", port: true)
1963 digraph.edge("#{id}:value -> #{node_id(node.value)};")
1964
1965 digraph.nodes << <<~DOT
1966 #{id} [
1967 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1968 ];
1969 DOT
1970
1971 super
1972 end
1973
1974 # Visit a GlobalVariableReadNode node.
1975 def visit_global_variable_read_node(node)
1976 table = Table.new("GlobalVariableReadNode")
1977 id = node_id(node)
1978
1979 # name
1980 table.field("name", node.name.inspect)
1981
1982 digraph.nodes << <<~DOT
1983 #{id} [
1984 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
1985 ];
1986 DOT
1987
1988 super
1989 end
1990
1991 # Visit a GlobalVariableTargetNode node.
1992 def visit_global_variable_target_node(node)
1993 table = Table.new("GlobalVariableTargetNode")
1994 id = node_id(node)
1995
1996 # name
1997 table.field("name", node.name.inspect)
1998
1999 digraph.nodes << <<~DOT
2000 #{id} [
2001 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2002 ];
2003 DOT
2004
2005 super
2006 end
2007
2008 # Visit a GlobalVariableWriteNode node.
2009 def visit_global_variable_write_node(node)
2010 table = Table.new("GlobalVariableWriteNode")
2011 id = node_id(node)
2012
2013 # name
2014 table.field("name", node.name.inspect)
2015
2016 # name_loc
2017 table.field("name_loc", location_inspect(node.name_loc))
2018
2019 # value
2020 table.field("value", port: true)
2021 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2022
2023 # operator_loc
2024 table.field("operator_loc", location_inspect(node.operator_loc))
2025
2026 digraph.nodes << <<~DOT
2027 #{id} [
2028 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2029 ];
2030 DOT
2031
2032 super
2033 end
2034
2035 # Visit a HashNode node.
2036 def visit_hash_node(node)
2037 table = Table.new("HashNode")
2038 id = node_id(node)
2039
2040 # opening_loc
2041 table.field("opening_loc", location_inspect(node.opening_loc))
2042
2043 # elements
2044 if node.elements.any?
2045 table.field("elements", port: true)
2046
2047 waypoint = "#{id}_elements"
2048 digraph.waypoint("#{waypoint};")
2049
2050 digraph.edge("#{id}:elements -> #{waypoint};")
2051 node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2052 else
2053 table.field("elements", "[]")
2054 end
2055
2056 # closing_loc
2057 table.field("closing_loc", location_inspect(node.closing_loc))
2058
2059 digraph.nodes << <<~DOT
2060 #{id} [
2061 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2062 ];
2063 DOT
2064
2065 super
2066 end
2067
2068 # Visit a HashPatternNode node.
2069 def visit_hash_pattern_node(node)
2070 table = Table.new("HashPatternNode")
2071 id = node_id(node)
2072
2073 # constant
2074 unless (constant = node.constant).nil?
2075 table.field("constant", port: true)
2076 digraph.edge("#{id}:constant -> #{node_id(constant)};")
2077 end
2078
2079 # elements
2080 if node.elements.any?
2081 table.field("elements", port: true)
2082
2083 waypoint = "#{id}_elements"
2084 digraph.waypoint("#{waypoint};")
2085
2086 digraph.edge("#{id}:elements -> #{waypoint};")
2087 node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2088 else
2089 table.field("elements", "[]")
2090 end
2091
2092 # rest
2093 unless (rest = node.rest).nil?
2094 table.field("rest", port: true)
2095 digraph.edge("#{id}:rest -> #{node_id(rest)};")
2096 end
2097
2098 # opening_loc
2099 unless (opening_loc = node.opening_loc).nil?
2100 table.field("opening_loc", location_inspect(opening_loc))
2101 end
2102
2103 # closing_loc
2104 unless (closing_loc = node.closing_loc).nil?
2105 table.field("closing_loc", location_inspect(closing_loc))
2106 end
2107
2108 digraph.nodes << <<~DOT
2109 #{id} [
2110 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2111 ];
2112 DOT
2113
2114 super
2115 end
2116
2117 # Visit a IfNode node.
2118 def visit_if_node(node)
2119 table = Table.new("IfNode")
2120 id = node_id(node)
2121
2122 # if_keyword_loc
2123 unless (if_keyword_loc = node.if_keyword_loc).nil?
2124 table.field("if_keyword_loc", location_inspect(if_keyword_loc))
2125 end
2126
2127 # predicate
2128 table.field("predicate", port: true)
2129 digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
2130
2131 # then_keyword_loc
2132 unless (then_keyword_loc = node.then_keyword_loc).nil?
2133 table.field("then_keyword_loc", location_inspect(then_keyword_loc))
2134 end
2135
2136 # statements
2137 unless (statements = node.statements).nil?
2138 table.field("statements", port: true)
2139 digraph.edge("#{id}:statements -> #{node_id(statements)};")
2140 end
2141
2142 # subsequent
2143 unless (subsequent = node.subsequent).nil?
2144 table.field("subsequent", port: true)
2145 digraph.edge("#{id}:subsequent -> #{node_id(subsequent)};")
2146 end
2147
2148 # end_keyword_loc
2149 unless (end_keyword_loc = node.end_keyword_loc).nil?
2150 table.field("end_keyword_loc", location_inspect(end_keyword_loc))
2151 end
2152
2153 digraph.nodes << <<~DOT
2154 #{id} [
2155 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2156 ];
2157 DOT
2158
2159 super
2160 end
2161
2162 # Visit a ImaginaryNode node.
2163 def visit_imaginary_node(node)
2164 table = Table.new("ImaginaryNode")
2165 id = node_id(node)
2166
2167 # numeric
2168 table.field("numeric", port: true)
2169 digraph.edge("#{id}:numeric -> #{node_id(node.numeric)};")
2170
2171 digraph.nodes << <<~DOT
2172 #{id} [
2173 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2174 ];
2175 DOT
2176
2177 super
2178 end
2179
2180 # Visit a ImplicitNode node.
2181 def visit_implicit_node(node)
2182 table = Table.new("ImplicitNode")
2183 id = node_id(node)
2184
2185 # value
2186 table.field("value", port: true)
2187 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2188
2189 digraph.nodes << <<~DOT
2190 #{id} [
2191 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2192 ];
2193 DOT
2194
2195 super
2196 end
2197
2198 # Visit a ImplicitRestNode node.
2199 def visit_implicit_rest_node(node)
2200 table = Table.new("ImplicitRestNode")
2201 id = node_id(node)
2202
2203 digraph.nodes << <<~DOT
2204 #{id} [
2205 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2206 ];
2207 DOT
2208
2209 super
2210 end
2211
2212 # Visit a InNode node.
2213 def visit_in_node(node)
2214 table = Table.new("InNode")
2215 id = node_id(node)
2216
2217 # pattern
2218 table.field("pattern", port: true)
2219 digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
2220
2221 # statements
2222 unless (statements = node.statements).nil?
2223 table.field("statements", port: true)
2224 digraph.edge("#{id}:statements -> #{node_id(statements)};")
2225 end
2226
2227 # in_loc
2228 table.field("in_loc", location_inspect(node.in_loc))
2229
2230 # then_loc
2231 unless (then_loc = node.then_loc).nil?
2232 table.field("then_loc", location_inspect(then_loc))
2233 end
2234
2235 digraph.nodes << <<~DOT
2236 #{id} [
2237 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2238 ];
2239 DOT
2240
2241 super
2242 end
2243
2244 # Visit a IndexAndWriteNode node.
2245 def visit_index_and_write_node(node)
2246 table = Table.new("IndexAndWriteNode")
2247 id = node_id(node)
2248
2249 # flags
2250 table.field("flags", call_node_flags_inspect(node))
2251
2252 # receiver
2253 unless (receiver = node.receiver).nil?
2254 table.field("receiver", port: true)
2255 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2256 end
2257
2258 # call_operator_loc
2259 unless (call_operator_loc = node.call_operator_loc).nil?
2260 table.field("call_operator_loc", location_inspect(call_operator_loc))
2261 end
2262
2263 # opening_loc
2264 table.field("opening_loc", location_inspect(node.opening_loc))
2265
2266 # arguments
2267 unless (arguments = node.arguments).nil?
2268 table.field("arguments", port: true)
2269 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2270 end
2271
2272 # closing_loc
2273 table.field("closing_loc", location_inspect(node.closing_loc))
2274
2275 # block
2276 unless (block = node.block).nil?
2277 table.field("block", port: true)
2278 digraph.edge("#{id}:block -> #{node_id(block)};")
2279 end
2280
2281 # operator_loc
2282 table.field("operator_loc", location_inspect(node.operator_loc))
2283
2284 # value
2285 table.field("value", port: true)
2286 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2287
2288 digraph.nodes << <<~DOT
2289 #{id} [
2290 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2291 ];
2292 DOT
2293
2294 super
2295 end
2296
2297 # Visit a IndexOperatorWriteNode node.
2298 def visit_index_operator_write_node(node)
2299 table = Table.new("IndexOperatorWriteNode")
2300 id = node_id(node)
2301
2302 # flags
2303 table.field("flags", call_node_flags_inspect(node))
2304
2305 # receiver
2306 unless (receiver = node.receiver).nil?
2307 table.field("receiver", port: true)
2308 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2309 end
2310
2311 # call_operator_loc
2312 unless (call_operator_loc = node.call_operator_loc).nil?
2313 table.field("call_operator_loc", location_inspect(call_operator_loc))
2314 end
2315
2316 # opening_loc
2317 table.field("opening_loc", location_inspect(node.opening_loc))
2318
2319 # arguments
2320 unless (arguments = node.arguments).nil?
2321 table.field("arguments", port: true)
2322 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2323 end
2324
2325 # closing_loc
2326 table.field("closing_loc", location_inspect(node.closing_loc))
2327
2328 # block
2329 unless (block = node.block).nil?
2330 table.field("block", port: true)
2331 digraph.edge("#{id}:block -> #{node_id(block)};")
2332 end
2333
2334 # binary_operator
2335 table.field("binary_operator", node.binary_operator.inspect)
2336
2337 # binary_operator_loc
2338 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2339
2340 # value
2341 table.field("value", port: true)
2342 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2343
2344 digraph.nodes << <<~DOT
2345 #{id} [
2346 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2347 ];
2348 DOT
2349
2350 super
2351 end
2352
2353 # Visit a IndexOrWriteNode node.
2354 def visit_index_or_write_node(node)
2355 table = Table.new("IndexOrWriteNode")
2356 id = node_id(node)
2357
2358 # flags
2359 table.field("flags", call_node_flags_inspect(node))
2360
2361 # receiver
2362 unless (receiver = node.receiver).nil?
2363 table.field("receiver", port: true)
2364 digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
2365 end
2366
2367 # call_operator_loc
2368 unless (call_operator_loc = node.call_operator_loc).nil?
2369 table.field("call_operator_loc", location_inspect(call_operator_loc))
2370 end
2371
2372 # opening_loc
2373 table.field("opening_loc", location_inspect(node.opening_loc))
2374
2375 # arguments
2376 unless (arguments = node.arguments).nil?
2377 table.field("arguments", port: true)
2378 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2379 end
2380
2381 # closing_loc
2382 table.field("closing_loc", location_inspect(node.closing_loc))
2383
2384 # block
2385 unless (block = node.block).nil?
2386 table.field("block", port: true)
2387 digraph.edge("#{id}:block -> #{node_id(block)};")
2388 end
2389
2390 # operator_loc
2391 table.field("operator_loc", location_inspect(node.operator_loc))
2392
2393 # value
2394 table.field("value", port: true)
2395 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2396
2397 digraph.nodes << <<~DOT
2398 #{id} [
2399 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2400 ];
2401 DOT
2402
2403 super
2404 end
2405
2406 # Visit a IndexTargetNode node.
2407 def visit_index_target_node(node)
2408 table = Table.new("IndexTargetNode")
2409 id = node_id(node)
2410
2411 # flags
2412 table.field("flags", call_node_flags_inspect(node))
2413
2414 # receiver
2415 table.field("receiver", port: true)
2416 digraph.edge("#{id}:receiver -> #{node_id(node.receiver)};")
2417
2418 # opening_loc
2419 table.field("opening_loc", location_inspect(node.opening_loc))
2420
2421 # arguments
2422 unless (arguments = node.arguments).nil?
2423 table.field("arguments", port: true)
2424 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
2425 end
2426
2427 # closing_loc
2428 table.field("closing_loc", location_inspect(node.closing_loc))
2429
2430 # block
2431 unless (block = node.block).nil?
2432 table.field("block", port: true)
2433 digraph.edge("#{id}:block -> #{node_id(block)};")
2434 end
2435
2436 digraph.nodes << <<~DOT
2437 #{id} [
2438 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2439 ];
2440 DOT
2441
2442 super
2443 end
2444
2445 # Visit a InstanceVariableAndWriteNode node.
2446 def visit_instance_variable_and_write_node(node)
2447 table = Table.new("InstanceVariableAndWriteNode")
2448 id = node_id(node)
2449
2450 # name
2451 table.field("name", node.name.inspect)
2452
2453 # name_loc
2454 table.field("name_loc", location_inspect(node.name_loc))
2455
2456 # operator_loc
2457 table.field("operator_loc", location_inspect(node.operator_loc))
2458
2459 # value
2460 table.field("value", port: true)
2461 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2462
2463 digraph.nodes << <<~DOT
2464 #{id} [
2465 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2466 ];
2467 DOT
2468
2469 super
2470 end
2471
2472 # Visit a InstanceVariableOperatorWriteNode node.
2473 def visit_instance_variable_operator_write_node(node)
2474 table = Table.new("InstanceVariableOperatorWriteNode")
2475 id = node_id(node)
2476
2477 # name
2478 table.field("name", node.name.inspect)
2479
2480 # name_loc
2481 table.field("name_loc", location_inspect(node.name_loc))
2482
2483 # binary_operator_loc
2484 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2485
2486 # value
2487 table.field("value", port: true)
2488 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2489
2490 # binary_operator
2491 table.field("binary_operator", node.binary_operator.inspect)
2492
2493 digraph.nodes << <<~DOT
2494 #{id} [
2495 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2496 ];
2497 DOT
2498
2499 super
2500 end
2501
2502 # Visit a InstanceVariableOrWriteNode node.
2503 def visit_instance_variable_or_write_node(node)
2504 table = Table.new("InstanceVariableOrWriteNode")
2505 id = node_id(node)
2506
2507 # name
2508 table.field("name", node.name.inspect)
2509
2510 # name_loc
2511 table.field("name_loc", location_inspect(node.name_loc))
2512
2513 # operator_loc
2514 table.field("operator_loc", location_inspect(node.operator_loc))
2515
2516 # value
2517 table.field("value", port: true)
2518 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2519
2520 digraph.nodes << <<~DOT
2521 #{id} [
2522 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2523 ];
2524 DOT
2525
2526 super
2527 end
2528
2529 # Visit a InstanceVariableReadNode node.
2530 def visit_instance_variable_read_node(node)
2531 table = Table.new("InstanceVariableReadNode")
2532 id = node_id(node)
2533
2534 # name
2535 table.field("name", node.name.inspect)
2536
2537 digraph.nodes << <<~DOT
2538 #{id} [
2539 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2540 ];
2541 DOT
2542
2543 super
2544 end
2545
2546 # Visit a InstanceVariableTargetNode node.
2547 def visit_instance_variable_target_node(node)
2548 table = Table.new("InstanceVariableTargetNode")
2549 id = node_id(node)
2550
2551 # name
2552 table.field("name", node.name.inspect)
2553
2554 digraph.nodes << <<~DOT
2555 #{id} [
2556 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2557 ];
2558 DOT
2559
2560 super
2561 end
2562
2563 # Visit a InstanceVariableWriteNode node.
2564 def visit_instance_variable_write_node(node)
2565 table = Table.new("InstanceVariableWriteNode")
2566 id = node_id(node)
2567
2568 # name
2569 table.field("name", node.name.inspect)
2570
2571 # name_loc
2572 table.field("name_loc", location_inspect(node.name_loc))
2573
2574 # value
2575 table.field("value", port: true)
2576 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2577
2578 # operator_loc
2579 table.field("operator_loc", location_inspect(node.operator_loc))
2580
2581 digraph.nodes << <<~DOT
2582 #{id} [
2583 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2584 ];
2585 DOT
2586
2587 super
2588 end
2589
2590 # Visit a IntegerNode node.
2591 def visit_integer_node(node)
2592 table = Table.new("IntegerNode")
2593 id = node_id(node)
2594
2595 # flags
2596 table.field("flags", integer_base_flags_inspect(node))
2597
2598 # value
2599 table.field("value", node.value.inspect)
2600
2601 digraph.nodes << <<~DOT
2602 #{id} [
2603 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2604 ];
2605 DOT
2606
2607 super
2608 end
2609
2610 # Visit a InterpolatedMatchLastLineNode node.
2611 def visit_interpolated_match_last_line_node(node)
2612 table = Table.new("InterpolatedMatchLastLineNode")
2613 id = node_id(node)
2614
2615 # flags
2616 table.field("flags", regular_expression_flags_inspect(node))
2617
2618 # opening_loc
2619 table.field("opening_loc", location_inspect(node.opening_loc))
2620
2621 # parts
2622 if node.parts.any?
2623 table.field("parts", port: true)
2624
2625 waypoint = "#{id}_parts"
2626 digraph.waypoint("#{waypoint};")
2627
2628 digraph.edge("#{id}:parts -> #{waypoint};")
2629 node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2630 else
2631 table.field("parts", "[]")
2632 end
2633
2634 # closing_loc
2635 table.field("closing_loc", location_inspect(node.closing_loc))
2636
2637 digraph.nodes << <<~DOT
2638 #{id} [
2639 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2640 ];
2641 DOT
2642
2643 super
2644 end
2645
2646 # Visit a InterpolatedRegularExpressionNode node.
2647 def visit_interpolated_regular_expression_node(node)
2648 table = Table.new("InterpolatedRegularExpressionNode")
2649 id = node_id(node)
2650
2651 # flags
2652 table.field("flags", regular_expression_flags_inspect(node))
2653
2654 # opening_loc
2655 table.field("opening_loc", location_inspect(node.opening_loc))
2656
2657 # parts
2658 if node.parts.any?
2659 table.field("parts", port: true)
2660
2661 waypoint = "#{id}_parts"
2662 digraph.waypoint("#{waypoint};")
2663
2664 digraph.edge("#{id}:parts -> #{waypoint};")
2665 node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2666 else
2667 table.field("parts", "[]")
2668 end
2669
2670 # closing_loc
2671 table.field("closing_loc", location_inspect(node.closing_loc))
2672
2673 digraph.nodes << <<~DOT
2674 #{id} [
2675 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2676 ];
2677 DOT
2678
2679 super
2680 end
2681
2682 # Visit a InterpolatedStringNode node.
2683 def visit_interpolated_string_node(node)
2684 table = Table.new("InterpolatedStringNode")
2685 id = node_id(node)
2686
2687 # flags
2688 table.field("flags", interpolated_string_node_flags_inspect(node))
2689
2690 # opening_loc
2691 unless (opening_loc = node.opening_loc).nil?
2692 table.field("opening_loc", location_inspect(opening_loc))
2693 end
2694
2695 # parts
2696 if node.parts.any?
2697 table.field("parts", port: true)
2698
2699 waypoint = "#{id}_parts"
2700 digraph.waypoint("#{waypoint};")
2701
2702 digraph.edge("#{id}:parts -> #{waypoint};")
2703 node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2704 else
2705 table.field("parts", "[]")
2706 end
2707
2708 # closing_loc
2709 unless (closing_loc = node.closing_loc).nil?
2710 table.field("closing_loc", location_inspect(closing_loc))
2711 end
2712
2713 digraph.nodes << <<~DOT
2714 #{id} [
2715 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2716 ];
2717 DOT
2718
2719 super
2720 end
2721
2722 # Visit a InterpolatedSymbolNode node.
2723 def visit_interpolated_symbol_node(node)
2724 table = Table.new("InterpolatedSymbolNode")
2725 id = node_id(node)
2726
2727 # opening_loc
2728 unless (opening_loc = node.opening_loc).nil?
2729 table.field("opening_loc", location_inspect(opening_loc))
2730 end
2731
2732 # parts
2733 if node.parts.any?
2734 table.field("parts", port: true)
2735
2736 waypoint = "#{id}_parts"
2737 digraph.waypoint("#{waypoint};")
2738
2739 digraph.edge("#{id}:parts -> #{waypoint};")
2740 node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2741 else
2742 table.field("parts", "[]")
2743 end
2744
2745 # closing_loc
2746 unless (closing_loc = node.closing_loc).nil?
2747 table.field("closing_loc", location_inspect(closing_loc))
2748 end
2749
2750 digraph.nodes << <<~DOT
2751 #{id} [
2752 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2753 ];
2754 DOT
2755
2756 super
2757 end
2758
2759 # Visit a InterpolatedXStringNode node.
2760 def visit_interpolated_x_string_node(node)
2761 table = Table.new("InterpolatedXStringNode")
2762 id = node_id(node)
2763
2764 # opening_loc
2765 table.field("opening_loc", location_inspect(node.opening_loc))
2766
2767 # parts
2768 if node.parts.any?
2769 table.field("parts", port: true)
2770
2771 waypoint = "#{id}_parts"
2772 digraph.waypoint("#{waypoint};")
2773
2774 digraph.edge("#{id}:parts -> #{waypoint};")
2775 node.parts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2776 else
2777 table.field("parts", "[]")
2778 end
2779
2780 # closing_loc
2781 table.field("closing_loc", location_inspect(node.closing_loc))
2782
2783 digraph.nodes << <<~DOT
2784 #{id} [
2785 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2786 ];
2787 DOT
2788
2789 super
2790 end
2791
2792 # Visit a ItLocalVariableReadNode node.
2793 def visit_it_local_variable_read_node(node)
2794 table = Table.new("ItLocalVariableReadNode")
2795 id = node_id(node)
2796
2797 digraph.nodes << <<~DOT
2798 #{id} [
2799 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2800 ];
2801 DOT
2802
2803 super
2804 end
2805
2806 # Visit a ItParametersNode node.
2807 def visit_it_parameters_node(node)
2808 table = Table.new("ItParametersNode")
2809 id = node_id(node)
2810
2811 digraph.nodes << <<~DOT
2812 #{id} [
2813 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2814 ];
2815 DOT
2816
2817 super
2818 end
2819
2820 # Visit a KeywordHashNode node.
2821 def visit_keyword_hash_node(node)
2822 table = Table.new("KeywordHashNode")
2823 id = node_id(node)
2824
2825 # flags
2826 table.field("flags", keyword_hash_node_flags_inspect(node))
2827
2828 # elements
2829 if node.elements.any?
2830 table.field("elements", port: true)
2831
2832 waypoint = "#{id}_elements"
2833 digraph.waypoint("#{waypoint};")
2834
2835 digraph.edge("#{id}:elements -> #{waypoint};")
2836 node.elements.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
2837 else
2838 table.field("elements", "[]")
2839 end
2840
2841 digraph.nodes << <<~DOT
2842 #{id} [
2843 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2844 ];
2845 DOT
2846
2847 super
2848 end
2849
2850 # Visit a KeywordRestParameterNode node.
2851 def visit_keyword_rest_parameter_node(node)
2852 table = Table.new("KeywordRestParameterNode")
2853 id = node_id(node)
2854
2855 # flags
2856 table.field("flags", parameter_flags_inspect(node))
2857
2858 # name
2859 table.field("name", node.name.inspect)
2860
2861 # name_loc
2862 unless (name_loc = node.name_loc).nil?
2863 table.field("name_loc", location_inspect(name_loc))
2864 end
2865
2866 # operator_loc
2867 table.field("operator_loc", location_inspect(node.operator_loc))
2868
2869 digraph.nodes << <<~DOT
2870 #{id} [
2871 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2872 ];
2873 DOT
2874
2875 super
2876 end
2877
2878 # Visit a LambdaNode node.
2879 def visit_lambda_node(node)
2880 table = Table.new("LambdaNode")
2881 id = node_id(node)
2882
2883 # locals
2884 table.field("locals", node.locals.inspect)
2885
2886 # operator_loc
2887 table.field("operator_loc", location_inspect(node.operator_loc))
2888
2889 # opening_loc
2890 table.field("opening_loc", location_inspect(node.opening_loc))
2891
2892 # closing_loc
2893 table.field("closing_loc", location_inspect(node.closing_loc))
2894
2895 # parameters
2896 unless (parameters = node.parameters).nil?
2897 table.field("parameters", port: true)
2898 digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
2899 end
2900
2901 # body
2902 unless (body = node.body).nil?
2903 table.field("body", port: true)
2904 digraph.edge("#{id}:body -> #{node_id(body)};")
2905 end
2906
2907 digraph.nodes << <<~DOT
2908 #{id} [
2909 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2910 ];
2911 DOT
2912
2913 super
2914 end
2915
2916 # Visit a LocalVariableAndWriteNode node.
2917 def visit_local_variable_and_write_node(node)
2918 table = Table.new("LocalVariableAndWriteNode")
2919 id = node_id(node)
2920
2921 # name_loc
2922 table.field("name_loc", location_inspect(node.name_loc))
2923
2924 # operator_loc
2925 table.field("operator_loc", location_inspect(node.operator_loc))
2926
2927 # value
2928 table.field("value", port: true)
2929 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2930
2931 # name
2932 table.field("name", node.name.inspect)
2933
2934 # depth
2935 table.field("depth", node.depth.inspect)
2936
2937 digraph.nodes << <<~DOT
2938 #{id} [
2939 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2940 ];
2941 DOT
2942
2943 super
2944 end
2945
2946 # Visit a LocalVariableOperatorWriteNode node.
2947 def visit_local_variable_operator_write_node(node)
2948 table = Table.new("LocalVariableOperatorWriteNode")
2949 id = node_id(node)
2950
2951 # name_loc
2952 table.field("name_loc", location_inspect(node.name_loc))
2953
2954 # binary_operator_loc
2955 table.field("binary_operator_loc", location_inspect(node.binary_operator_loc))
2956
2957 # value
2958 table.field("value", port: true)
2959 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2960
2961 # name
2962 table.field("name", node.name.inspect)
2963
2964 # binary_operator
2965 table.field("binary_operator", node.binary_operator.inspect)
2966
2967 # depth
2968 table.field("depth", node.depth.inspect)
2969
2970 digraph.nodes << <<~DOT
2971 #{id} [
2972 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
2973 ];
2974 DOT
2975
2976 super
2977 end
2978
2979 # Visit a LocalVariableOrWriteNode node.
2980 def visit_local_variable_or_write_node(node)
2981 table = Table.new("LocalVariableOrWriteNode")
2982 id = node_id(node)
2983
2984 # name_loc
2985 table.field("name_loc", location_inspect(node.name_loc))
2986
2987 # operator_loc
2988 table.field("operator_loc", location_inspect(node.operator_loc))
2989
2990 # value
2991 table.field("value", port: true)
2992 digraph.edge("#{id}:value -> #{node_id(node.value)};")
2993
2994 # name
2995 table.field("name", node.name.inspect)
2996
2997 # depth
2998 table.field("depth", node.depth.inspect)
2999
3000 digraph.nodes << <<~DOT
3001 #{id} [
3002 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3003 ];
3004 DOT
3005
3006 super
3007 end
3008
3009 # Visit a LocalVariableReadNode node.
3010 def visit_local_variable_read_node(node)
3011 table = Table.new("LocalVariableReadNode")
3012 id = node_id(node)
3013
3014 # name
3015 table.field("name", node.name.inspect)
3016
3017 # depth
3018 table.field("depth", node.depth.inspect)
3019
3020 digraph.nodes << <<~DOT
3021 #{id} [
3022 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3023 ];
3024 DOT
3025
3026 super
3027 end
3028
3029 # Visit a LocalVariableTargetNode node.
3030 def visit_local_variable_target_node(node)
3031 table = Table.new("LocalVariableTargetNode")
3032 id = node_id(node)
3033
3034 # name
3035 table.field("name", node.name.inspect)
3036
3037 # depth
3038 table.field("depth", node.depth.inspect)
3039
3040 digraph.nodes << <<~DOT
3041 #{id} [
3042 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3043 ];
3044 DOT
3045
3046 super
3047 end
3048
3049 # Visit a LocalVariableWriteNode node.
3050 def visit_local_variable_write_node(node)
3051 table = Table.new("LocalVariableWriteNode")
3052 id = node_id(node)
3053
3054 # name
3055 table.field("name", node.name.inspect)
3056
3057 # depth
3058 table.field("depth", node.depth.inspect)
3059
3060 # name_loc
3061 table.field("name_loc", location_inspect(node.name_loc))
3062
3063 # value
3064 table.field("value", port: true)
3065 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3066
3067 # operator_loc
3068 table.field("operator_loc", location_inspect(node.operator_loc))
3069
3070 digraph.nodes << <<~DOT
3071 #{id} [
3072 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3073 ];
3074 DOT
3075
3076 super
3077 end
3078
3079 # Visit a MatchLastLineNode node.
3080 def visit_match_last_line_node(node)
3081 table = Table.new("MatchLastLineNode")
3082 id = node_id(node)
3083
3084 # flags
3085 table.field("flags", regular_expression_flags_inspect(node))
3086
3087 # opening_loc
3088 table.field("opening_loc", location_inspect(node.opening_loc))
3089
3090 # content_loc
3091 table.field("content_loc", location_inspect(node.content_loc))
3092
3093 # closing_loc
3094 table.field("closing_loc", location_inspect(node.closing_loc))
3095
3096 # unescaped
3097 table.field("unescaped", node.unescaped.inspect)
3098
3099 digraph.nodes << <<~DOT
3100 #{id} [
3101 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3102 ];
3103 DOT
3104
3105 super
3106 end
3107
3108 # Visit a MatchPredicateNode node.
3109 def visit_match_predicate_node(node)
3110 table = Table.new("MatchPredicateNode")
3111 id = node_id(node)
3112
3113 # value
3114 table.field("value", port: true)
3115 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3116
3117 # pattern
3118 table.field("pattern", port: true)
3119 digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
3120
3121 # operator_loc
3122 table.field("operator_loc", location_inspect(node.operator_loc))
3123
3124 digraph.nodes << <<~DOT
3125 #{id} [
3126 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3127 ];
3128 DOT
3129
3130 super
3131 end
3132
3133 # Visit a MatchRequiredNode node.
3134 def visit_match_required_node(node)
3135 table = Table.new("MatchRequiredNode")
3136 id = node_id(node)
3137
3138 # value
3139 table.field("value", port: true)
3140 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3141
3142 # pattern
3143 table.field("pattern", port: true)
3144 digraph.edge("#{id}:pattern -> #{node_id(node.pattern)};")
3145
3146 # operator_loc
3147 table.field("operator_loc", location_inspect(node.operator_loc))
3148
3149 digraph.nodes << <<~DOT
3150 #{id} [
3151 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3152 ];
3153 DOT
3154
3155 super
3156 end
3157
3158 # Visit a MatchWriteNode node.
3159 def visit_match_write_node(node)
3160 table = Table.new("MatchWriteNode")
3161 id = node_id(node)
3162
3163 # call
3164 table.field("call", port: true)
3165 digraph.edge("#{id}:call -> #{node_id(node.call)};")
3166
3167 # targets
3168 if node.targets.any?
3169 table.field("targets", port: true)
3170
3171 waypoint = "#{id}_targets"
3172 digraph.waypoint("#{waypoint};")
3173
3174 digraph.edge("#{id}:targets -> #{waypoint};")
3175 node.targets.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3176 else
3177 table.field("targets", "[]")
3178 end
3179
3180 digraph.nodes << <<~DOT
3181 #{id} [
3182 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3183 ];
3184 DOT
3185
3186 super
3187 end
3188
3189 # Visit a MissingNode node.
3190 def visit_missing_node(node)
3191 table = Table.new("MissingNode")
3192 id = node_id(node)
3193
3194 digraph.nodes << <<~DOT
3195 #{id} [
3196 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3197 ];
3198 DOT
3199
3200 super
3201 end
3202
3203 # Visit a ModuleNode node.
3204 def visit_module_node(node)
3205 table = Table.new("ModuleNode")
3206 id = node_id(node)
3207
3208 # locals
3209 table.field("locals", node.locals.inspect)
3210
3211 # module_keyword_loc
3212 table.field("module_keyword_loc", location_inspect(node.module_keyword_loc))
3213
3214 # constant_path
3215 table.field("constant_path", port: true)
3216 digraph.edge("#{id}:constant_path -> #{node_id(node.constant_path)};")
3217
3218 # body
3219 unless (body = node.body).nil?
3220 table.field("body", port: true)
3221 digraph.edge("#{id}:body -> #{node_id(body)};")
3222 end
3223
3224 # end_keyword_loc
3225 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
3226
3227 # name
3228 table.field("name", node.name.inspect)
3229
3230 digraph.nodes << <<~DOT
3231 #{id} [
3232 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3233 ];
3234 DOT
3235
3236 super
3237 end
3238
3239 # Visit a MultiTargetNode node.
3240 def visit_multi_target_node(node)
3241 table = Table.new("MultiTargetNode")
3242 id = node_id(node)
3243
3244 # lefts
3245 if node.lefts.any?
3246 table.field("lefts", port: true)
3247
3248 waypoint = "#{id}_lefts"
3249 digraph.waypoint("#{waypoint};")
3250
3251 digraph.edge("#{id}:lefts -> #{waypoint};")
3252 node.lefts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3253 else
3254 table.field("lefts", "[]")
3255 end
3256
3257 # rest
3258 unless (rest = node.rest).nil?
3259 table.field("rest", port: true)
3260 digraph.edge("#{id}:rest -> #{node_id(rest)};")
3261 end
3262
3263 # rights
3264 if node.rights.any?
3265 table.field("rights", port: true)
3266
3267 waypoint = "#{id}_rights"
3268 digraph.waypoint("#{waypoint};")
3269
3270 digraph.edge("#{id}:rights -> #{waypoint};")
3271 node.rights.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3272 else
3273 table.field("rights", "[]")
3274 end
3275
3276 # lparen_loc
3277 unless (lparen_loc = node.lparen_loc).nil?
3278 table.field("lparen_loc", location_inspect(lparen_loc))
3279 end
3280
3281 # rparen_loc
3282 unless (rparen_loc = node.rparen_loc).nil?
3283 table.field("rparen_loc", location_inspect(rparen_loc))
3284 end
3285
3286 digraph.nodes << <<~DOT
3287 #{id} [
3288 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3289 ];
3290 DOT
3291
3292 super
3293 end
3294
3295 # Visit a MultiWriteNode node.
3296 def visit_multi_write_node(node)
3297 table = Table.new("MultiWriteNode")
3298 id = node_id(node)
3299
3300 # lefts
3301 if node.lefts.any?
3302 table.field("lefts", port: true)
3303
3304 waypoint = "#{id}_lefts"
3305 digraph.waypoint("#{waypoint};")
3306
3307 digraph.edge("#{id}:lefts -> #{waypoint};")
3308 node.lefts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3309 else
3310 table.field("lefts", "[]")
3311 end
3312
3313 # rest
3314 unless (rest = node.rest).nil?
3315 table.field("rest", port: true)
3316 digraph.edge("#{id}:rest -> #{node_id(rest)};")
3317 end
3318
3319 # rights
3320 if node.rights.any?
3321 table.field("rights", port: true)
3322
3323 waypoint = "#{id}_rights"
3324 digraph.waypoint("#{waypoint};")
3325
3326 digraph.edge("#{id}:rights -> #{waypoint};")
3327 node.rights.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3328 else
3329 table.field("rights", "[]")
3330 end
3331
3332 # lparen_loc
3333 unless (lparen_loc = node.lparen_loc).nil?
3334 table.field("lparen_loc", location_inspect(lparen_loc))
3335 end
3336
3337 # rparen_loc
3338 unless (rparen_loc = node.rparen_loc).nil?
3339 table.field("rparen_loc", location_inspect(rparen_loc))
3340 end
3341
3342 # operator_loc
3343 table.field("operator_loc", location_inspect(node.operator_loc))
3344
3345 # value
3346 table.field("value", port: true)
3347 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3348
3349 digraph.nodes << <<~DOT
3350 #{id} [
3351 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3352 ];
3353 DOT
3354
3355 super
3356 end
3357
3358 # Visit a NextNode node.
3359 def visit_next_node(node)
3360 table = Table.new("NextNode")
3361 id = node_id(node)
3362
3363 # arguments
3364 unless (arguments = node.arguments).nil?
3365 table.field("arguments", port: true)
3366 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
3367 end
3368
3369 # keyword_loc
3370 table.field("keyword_loc", location_inspect(node.keyword_loc))
3371
3372 digraph.nodes << <<~DOT
3373 #{id} [
3374 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3375 ];
3376 DOT
3377
3378 super
3379 end
3380
3381 # Visit a NilNode node.
3382 def visit_nil_node(node)
3383 table = Table.new("NilNode")
3384 id = node_id(node)
3385
3386 digraph.nodes << <<~DOT
3387 #{id} [
3388 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3389 ];
3390 DOT
3391
3392 super
3393 end
3394
3395 # Visit a NoKeywordsParameterNode node.
3396 def visit_no_keywords_parameter_node(node)
3397 table = Table.new("NoKeywordsParameterNode")
3398 id = node_id(node)
3399
3400 # operator_loc
3401 table.field("operator_loc", location_inspect(node.operator_loc))
3402
3403 # keyword_loc
3404 table.field("keyword_loc", location_inspect(node.keyword_loc))
3405
3406 digraph.nodes << <<~DOT
3407 #{id} [
3408 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3409 ];
3410 DOT
3411
3412 super
3413 end
3414
3415 # Visit a NumberedParametersNode node.
3416 def visit_numbered_parameters_node(node)
3417 table = Table.new("NumberedParametersNode")
3418 id = node_id(node)
3419
3420 # maximum
3421 table.field("maximum", node.maximum.inspect)
3422
3423 digraph.nodes << <<~DOT
3424 #{id} [
3425 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3426 ];
3427 DOT
3428
3429 super
3430 end
3431
3432 # Visit a NumberedReferenceReadNode node.
3433 def visit_numbered_reference_read_node(node)
3434 table = Table.new("NumberedReferenceReadNode")
3435 id = node_id(node)
3436
3437 # number
3438 table.field("number", node.number.inspect)
3439
3440 digraph.nodes << <<~DOT
3441 #{id} [
3442 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3443 ];
3444 DOT
3445
3446 super
3447 end
3448
3449 # Visit a OptionalKeywordParameterNode node.
3450 def visit_optional_keyword_parameter_node(node)
3451 table = Table.new("OptionalKeywordParameterNode")
3452 id = node_id(node)
3453
3454 # flags
3455 table.field("flags", parameter_flags_inspect(node))
3456
3457 # name
3458 table.field("name", node.name.inspect)
3459
3460 # name_loc
3461 table.field("name_loc", location_inspect(node.name_loc))
3462
3463 # value
3464 table.field("value", port: true)
3465 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3466
3467 digraph.nodes << <<~DOT
3468 #{id} [
3469 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3470 ];
3471 DOT
3472
3473 super
3474 end
3475
3476 # Visit a OptionalParameterNode node.
3477 def visit_optional_parameter_node(node)
3478 table = Table.new("OptionalParameterNode")
3479 id = node_id(node)
3480
3481 # flags
3482 table.field("flags", parameter_flags_inspect(node))
3483
3484 # name
3485 table.field("name", node.name.inspect)
3486
3487 # name_loc
3488 table.field("name_loc", location_inspect(node.name_loc))
3489
3490 # operator_loc
3491 table.field("operator_loc", location_inspect(node.operator_loc))
3492
3493 # value
3494 table.field("value", port: true)
3495 digraph.edge("#{id}:value -> #{node_id(node.value)};")
3496
3497 digraph.nodes << <<~DOT
3498 #{id} [
3499 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3500 ];
3501 DOT
3502
3503 super
3504 end
3505
3506 # Visit a OrNode node.
3507 def visit_or_node(node)
3508 table = Table.new("OrNode")
3509 id = node_id(node)
3510
3511 # left
3512 table.field("left", port: true)
3513 digraph.edge("#{id}:left -> #{node_id(node.left)};")
3514
3515 # right
3516 table.field("right", port: true)
3517 digraph.edge("#{id}:right -> #{node_id(node.right)};")
3518
3519 # operator_loc
3520 table.field("operator_loc", location_inspect(node.operator_loc))
3521
3522 digraph.nodes << <<~DOT
3523 #{id} [
3524 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3525 ];
3526 DOT
3527
3528 super
3529 end
3530
3531 # Visit a ParametersNode node.
3532 def visit_parameters_node(node)
3533 table = Table.new("ParametersNode")
3534 id = node_id(node)
3535
3536 # requireds
3537 if node.requireds.any?
3538 table.field("requireds", port: true)
3539
3540 waypoint = "#{id}_requireds"
3541 digraph.waypoint("#{waypoint};")
3542
3543 digraph.edge("#{id}:requireds -> #{waypoint};")
3544 node.requireds.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3545 else
3546 table.field("requireds", "[]")
3547 end
3548
3549 # optionals
3550 if node.optionals.any?
3551 table.field("optionals", port: true)
3552
3553 waypoint = "#{id}_optionals"
3554 digraph.waypoint("#{waypoint};")
3555
3556 digraph.edge("#{id}:optionals -> #{waypoint};")
3557 node.optionals.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3558 else
3559 table.field("optionals", "[]")
3560 end
3561
3562 # rest
3563 unless (rest = node.rest).nil?
3564 table.field("rest", port: true)
3565 digraph.edge("#{id}:rest -> #{node_id(rest)};")
3566 end
3567
3568 # posts
3569 if node.posts.any?
3570 table.field("posts", port: true)
3571
3572 waypoint = "#{id}_posts"
3573 digraph.waypoint("#{waypoint};")
3574
3575 digraph.edge("#{id}:posts -> #{waypoint};")
3576 node.posts.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3577 else
3578 table.field("posts", "[]")
3579 end
3580
3581 # keywords
3582 if node.keywords.any?
3583 table.field("keywords", port: true)
3584
3585 waypoint = "#{id}_keywords"
3586 digraph.waypoint("#{waypoint};")
3587
3588 digraph.edge("#{id}:keywords -> #{waypoint};")
3589 node.keywords.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3590 else
3591 table.field("keywords", "[]")
3592 end
3593
3594 # keyword_rest
3595 unless (keyword_rest = node.keyword_rest).nil?
3596 table.field("keyword_rest", port: true)
3597 digraph.edge("#{id}:keyword_rest -> #{node_id(keyword_rest)};")
3598 end
3599
3600 # block
3601 unless (block = node.block).nil?
3602 table.field("block", port: true)
3603 digraph.edge("#{id}:block -> #{node_id(block)};")
3604 end
3605
3606 digraph.nodes << <<~DOT
3607 #{id} [
3608 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3609 ];
3610 DOT
3611
3612 super
3613 end
3614
3615 # Visit a ParenthesesNode node.
3616 def visit_parentheses_node(node)
3617 table = Table.new("ParenthesesNode")
3618 id = node_id(node)
3619
3620 # flags
3621 table.field("flags", parentheses_node_flags_inspect(node))
3622
3623 # body
3624 unless (body = node.body).nil?
3625 table.field("body", port: true)
3626 digraph.edge("#{id}:body -> #{node_id(body)};")
3627 end
3628
3629 # opening_loc
3630 table.field("opening_loc", location_inspect(node.opening_loc))
3631
3632 # closing_loc
3633 table.field("closing_loc", location_inspect(node.closing_loc))
3634
3635 digraph.nodes << <<~DOT
3636 #{id} [
3637 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3638 ];
3639 DOT
3640
3641 super
3642 end
3643
3644 # Visit a PinnedExpressionNode node.
3645 def visit_pinned_expression_node(node)
3646 table = Table.new("PinnedExpressionNode")
3647 id = node_id(node)
3648
3649 # expression
3650 table.field("expression", port: true)
3651 digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
3652
3653 # operator_loc
3654 table.field("operator_loc", location_inspect(node.operator_loc))
3655
3656 # lparen_loc
3657 table.field("lparen_loc", location_inspect(node.lparen_loc))
3658
3659 # rparen_loc
3660 table.field("rparen_loc", location_inspect(node.rparen_loc))
3661
3662 digraph.nodes << <<~DOT
3663 #{id} [
3664 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3665 ];
3666 DOT
3667
3668 super
3669 end
3670
3671 # Visit a PinnedVariableNode node.
3672 def visit_pinned_variable_node(node)
3673 table = Table.new("PinnedVariableNode")
3674 id = node_id(node)
3675
3676 # variable
3677 table.field("variable", port: true)
3678 digraph.edge("#{id}:variable -> #{node_id(node.variable)};")
3679
3680 # operator_loc
3681 table.field("operator_loc", location_inspect(node.operator_loc))
3682
3683 digraph.nodes << <<~DOT
3684 #{id} [
3685 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3686 ];
3687 DOT
3688
3689 super
3690 end
3691
3692 # Visit a PostExecutionNode node.
3693 def visit_post_execution_node(node)
3694 table = Table.new("PostExecutionNode")
3695 id = node_id(node)
3696
3697 # statements
3698 unless (statements = node.statements).nil?
3699 table.field("statements", port: true)
3700 digraph.edge("#{id}:statements -> #{node_id(statements)};")
3701 end
3702
3703 # keyword_loc
3704 table.field("keyword_loc", location_inspect(node.keyword_loc))
3705
3706 # opening_loc
3707 table.field("opening_loc", location_inspect(node.opening_loc))
3708
3709 # closing_loc
3710 table.field("closing_loc", location_inspect(node.closing_loc))
3711
3712 digraph.nodes << <<~DOT
3713 #{id} [
3714 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3715 ];
3716 DOT
3717
3718 super
3719 end
3720
3721 # Visit a PreExecutionNode node.
3722 def visit_pre_execution_node(node)
3723 table = Table.new("PreExecutionNode")
3724 id = node_id(node)
3725
3726 # statements
3727 unless (statements = node.statements).nil?
3728 table.field("statements", port: true)
3729 digraph.edge("#{id}:statements -> #{node_id(statements)};")
3730 end
3731
3732 # keyword_loc
3733 table.field("keyword_loc", location_inspect(node.keyword_loc))
3734
3735 # opening_loc
3736 table.field("opening_loc", location_inspect(node.opening_loc))
3737
3738 # closing_loc
3739 table.field("closing_loc", location_inspect(node.closing_loc))
3740
3741 digraph.nodes << <<~DOT
3742 #{id} [
3743 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3744 ];
3745 DOT
3746
3747 super
3748 end
3749
3750 # Visit a ProgramNode node.
3751 def visit_program_node(node)
3752 table = Table.new("ProgramNode")
3753 id = node_id(node)
3754
3755 # locals
3756 table.field("locals", node.locals.inspect)
3757
3758 # statements
3759 table.field("statements", port: true)
3760 digraph.edge("#{id}:statements -> #{node_id(node.statements)};")
3761
3762 digraph.nodes << <<~DOT
3763 #{id} [
3764 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3765 ];
3766 DOT
3767
3768 super
3769 end
3770
3771 # Visit a RangeNode node.
3772 def visit_range_node(node)
3773 table = Table.new("RangeNode")
3774 id = node_id(node)
3775
3776 # flags
3777 table.field("flags", range_flags_inspect(node))
3778
3779 # left
3780 unless (left = node.left).nil?
3781 table.field("left", port: true)
3782 digraph.edge("#{id}:left -> #{node_id(left)};")
3783 end
3784
3785 # right
3786 unless (right = node.right).nil?
3787 table.field("right", port: true)
3788 digraph.edge("#{id}:right -> #{node_id(right)};")
3789 end
3790
3791 # operator_loc
3792 table.field("operator_loc", location_inspect(node.operator_loc))
3793
3794 digraph.nodes << <<~DOT
3795 #{id} [
3796 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3797 ];
3798 DOT
3799
3800 super
3801 end
3802
3803 # Visit a RationalNode node.
3804 def visit_rational_node(node)
3805 table = Table.new("RationalNode")
3806 id = node_id(node)
3807
3808 # flags
3809 table.field("flags", integer_base_flags_inspect(node))
3810
3811 # numerator
3812 table.field("numerator", node.numerator.inspect)
3813
3814 # denominator
3815 table.field("denominator", node.denominator.inspect)
3816
3817 digraph.nodes << <<~DOT
3818 #{id} [
3819 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3820 ];
3821 DOT
3822
3823 super
3824 end
3825
3826 # Visit a RedoNode node.
3827 def visit_redo_node(node)
3828 table = Table.new("RedoNode")
3829 id = node_id(node)
3830
3831 digraph.nodes << <<~DOT
3832 #{id} [
3833 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3834 ];
3835 DOT
3836
3837 super
3838 end
3839
3840 # Visit a RegularExpressionNode node.
3841 def visit_regular_expression_node(node)
3842 table = Table.new("RegularExpressionNode")
3843 id = node_id(node)
3844
3845 # flags
3846 table.field("flags", regular_expression_flags_inspect(node))
3847
3848 # opening_loc
3849 table.field("opening_loc", location_inspect(node.opening_loc))
3850
3851 # content_loc
3852 table.field("content_loc", location_inspect(node.content_loc))
3853
3854 # closing_loc
3855 table.field("closing_loc", location_inspect(node.closing_loc))
3856
3857 # unescaped
3858 table.field("unescaped", node.unescaped.inspect)
3859
3860 digraph.nodes << <<~DOT
3861 #{id} [
3862 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3863 ];
3864 DOT
3865
3866 super
3867 end
3868
3869 # Visit a RequiredKeywordParameterNode node.
3870 def visit_required_keyword_parameter_node(node)
3871 table = Table.new("RequiredKeywordParameterNode")
3872 id = node_id(node)
3873
3874 # flags
3875 table.field("flags", parameter_flags_inspect(node))
3876
3877 # name
3878 table.field("name", node.name.inspect)
3879
3880 # name_loc
3881 table.field("name_loc", location_inspect(node.name_loc))
3882
3883 digraph.nodes << <<~DOT
3884 #{id} [
3885 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3886 ];
3887 DOT
3888
3889 super
3890 end
3891
3892 # Visit a RequiredParameterNode node.
3893 def visit_required_parameter_node(node)
3894 table = Table.new("RequiredParameterNode")
3895 id = node_id(node)
3896
3897 # flags
3898 table.field("flags", parameter_flags_inspect(node))
3899
3900 # name
3901 table.field("name", node.name.inspect)
3902
3903 digraph.nodes << <<~DOT
3904 #{id} [
3905 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3906 ];
3907 DOT
3908
3909 super
3910 end
3911
3912 # Visit a RescueModifierNode node.
3913 def visit_rescue_modifier_node(node)
3914 table = Table.new("RescueModifierNode")
3915 id = node_id(node)
3916
3917 # expression
3918 table.field("expression", port: true)
3919 digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
3920
3921 # keyword_loc
3922 table.field("keyword_loc", location_inspect(node.keyword_loc))
3923
3924 # rescue_expression
3925 table.field("rescue_expression", port: true)
3926 digraph.edge("#{id}:rescue_expression -> #{node_id(node.rescue_expression)};")
3927
3928 digraph.nodes << <<~DOT
3929 #{id} [
3930 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3931 ];
3932 DOT
3933
3934 super
3935 end
3936
3937 # Visit a RescueNode node.
3938 def visit_rescue_node(node)
3939 table = Table.new("RescueNode")
3940 id = node_id(node)
3941
3942 # keyword_loc
3943 table.field("keyword_loc", location_inspect(node.keyword_loc))
3944
3945 # exceptions
3946 if node.exceptions.any?
3947 table.field("exceptions", port: true)
3948
3949 waypoint = "#{id}_exceptions"
3950 digraph.waypoint("#{waypoint};")
3951
3952 digraph.edge("#{id}:exceptions -> #{waypoint};")
3953 node.exceptions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
3954 else
3955 table.field("exceptions", "[]")
3956 end
3957
3958 # operator_loc
3959 unless (operator_loc = node.operator_loc).nil?
3960 table.field("operator_loc", location_inspect(operator_loc))
3961 end
3962
3963 # reference
3964 unless (reference = node.reference).nil?
3965 table.field("reference", port: true)
3966 digraph.edge("#{id}:reference -> #{node_id(reference)};")
3967 end
3968
3969 # then_keyword_loc
3970 unless (then_keyword_loc = node.then_keyword_loc).nil?
3971 table.field("then_keyword_loc", location_inspect(then_keyword_loc))
3972 end
3973
3974 # statements
3975 unless (statements = node.statements).nil?
3976 table.field("statements", port: true)
3977 digraph.edge("#{id}:statements -> #{node_id(statements)};")
3978 end
3979
3980 # subsequent
3981 unless (subsequent = node.subsequent).nil?
3982 table.field("subsequent", port: true)
3983 digraph.edge("#{id}:subsequent -> #{node_id(subsequent)};")
3984 end
3985
3986 digraph.nodes << <<~DOT
3987 #{id} [
3988 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
3989 ];
3990 DOT
3991
3992 super
3993 end
3994
3995 # Visit a RestParameterNode node.
3996 def visit_rest_parameter_node(node)
3997 table = Table.new("RestParameterNode")
3998 id = node_id(node)
3999
4000 # flags
4001 table.field("flags", parameter_flags_inspect(node))
4002
4003 # name
4004 table.field("name", node.name.inspect)
4005
4006 # name_loc
4007 unless (name_loc = node.name_loc).nil?
4008 table.field("name_loc", location_inspect(name_loc))
4009 end
4010
4011 # operator_loc
4012 table.field("operator_loc", location_inspect(node.operator_loc))
4013
4014 digraph.nodes << <<~DOT
4015 #{id} [
4016 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4017 ];
4018 DOT
4019
4020 super
4021 end
4022
4023 # Visit a RetryNode node.
4024 def visit_retry_node(node)
4025 table = Table.new("RetryNode")
4026 id = node_id(node)
4027
4028 digraph.nodes << <<~DOT
4029 #{id} [
4030 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4031 ];
4032 DOT
4033
4034 super
4035 end
4036
4037 # Visit a ReturnNode node.
4038 def visit_return_node(node)
4039 table = Table.new("ReturnNode")
4040 id = node_id(node)
4041
4042 # keyword_loc
4043 table.field("keyword_loc", location_inspect(node.keyword_loc))
4044
4045 # arguments
4046 unless (arguments = node.arguments).nil?
4047 table.field("arguments", port: true)
4048 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
4049 end
4050
4051 digraph.nodes << <<~DOT
4052 #{id} [
4053 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4054 ];
4055 DOT
4056
4057 super
4058 end
4059
4060 # Visit a SelfNode node.
4061 def visit_self_node(node)
4062 table = Table.new("SelfNode")
4063 id = node_id(node)
4064
4065 digraph.nodes << <<~DOT
4066 #{id} [
4067 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4068 ];
4069 DOT
4070
4071 super
4072 end
4073
4074 # Visit a ShareableConstantNode node.
4075 def visit_shareable_constant_node(node)
4076 table = Table.new("ShareableConstantNode")
4077 id = node_id(node)
4078
4079 # flags
4080 table.field("flags", shareable_constant_node_flags_inspect(node))
4081
4082 # write
4083 table.field("write", port: true)
4084 digraph.edge("#{id}:write -> #{node_id(node.write)};")
4085
4086 digraph.nodes << <<~DOT
4087 #{id} [
4088 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4089 ];
4090 DOT
4091
4092 super
4093 end
4094
4095 # Visit a SingletonClassNode node.
4096 def visit_singleton_class_node(node)
4097 table = Table.new("SingletonClassNode")
4098 id = node_id(node)
4099
4100 # locals
4101 table.field("locals", node.locals.inspect)
4102
4103 # class_keyword_loc
4104 table.field("class_keyword_loc", location_inspect(node.class_keyword_loc))
4105
4106 # operator_loc
4107 table.field("operator_loc", location_inspect(node.operator_loc))
4108
4109 # expression
4110 table.field("expression", port: true)
4111 digraph.edge("#{id}:expression -> #{node_id(node.expression)};")
4112
4113 # body
4114 unless (body = node.body).nil?
4115 table.field("body", port: true)
4116 digraph.edge("#{id}:body -> #{node_id(body)};")
4117 end
4118
4119 # end_keyword_loc
4120 table.field("end_keyword_loc", location_inspect(node.end_keyword_loc))
4121
4122 digraph.nodes << <<~DOT
4123 #{id} [
4124 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4125 ];
4126 DOT
4127
4128 super
4129 end
4130
4131 # Visit a SourceEncodingNode node.
4132 def visit_source_encoding_node(node)
4133 table = Table.new("SourceEncodingNode")
4134 id = node_id(node)
4135
4136 digraph.nodes << <<~DOT
4137 #{id} [
4138 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4139 ];
4140 DOT
4141
4142 super
4143 end
4144
4145 # Visit a SourceFileNode node.
4146 def visit_source_file_node(node)
4147 table = Table.new("SourceFileNode")
4148 id = node_id(node)
4149
4150 # flags
4151 table.field("flags", string_flags_inspect(node))
4152
4153 # filepath
4154 table.field("filepath", node.filepath.inspect)
4155
4156 digraph.nodes << <<~DOT
4157 #{id} [
4158 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4159 ];
4160 DOT
4161
4162 super
4163 end
4164
4165 # Visit a SourceLineNode node.
4166 def visit_source_line_node(node)
4167 table = Table.new("SourceLineNode")
4168 id = node_id(node)
4169
4170 digraph.nodes << <<~DOT
4171 #{id} [
4172 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4173 ];
4174 DOT
4175
4176 super
4177 end
4178
4179 # Visit a SplatNode node.
4180 def visit_splat_node(node)
4181 table = Table.new("SplatNode")
4182 id = node_id(node)
4183
4184 # operator_loc
4185 table.field("operator_loc", location_inspect(node.operator_loc))
4186
4187 # expression
4188 unless (expression = node.expression).nil?
4189 table.field("expression", port: true)
4190 digraph.edge("#{id}:expression -> #{node_id(expression)};")
4191 end
4192
4193 digraph.nodes << <<~DOT
4194 #{id} [
4195 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4196 ];
4197 DOT
4198
4199 super
4200 end
4201
4202 # Visit a StatementsNode node.
4203 def visit_statements_node(node)
4204 table = Table.new("StatementsNode")
4205 id = node_id(node)
4206
4207 # body
4208 if node.body.any?
4209 table.field("body", port: true)
4210
4211 waypoint = "#{id}_body"
4212 digraph.waypoint("#{waypoint};")
4213
4214 digraph.edge("#{id}:body -> #{waypoint};")
4215 node.body.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4216 else
4217 table.field("body", "[]")
4218 end
4219
4220 digraph.nodes << <<~DOT
4221 #{id} [
4222 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4223 ];
4224 DOT
4225
4226 super
4227 end
4228
4229 # Visit a StringNode node.
4230 def visit_string_node(node)
4231 table = Table.new("StringNode")
4232 id = node_id(node)
4233
4234 # flags
4235 table.field("flags", string_flags_inspect(node))
4236
4237 # opening_loc
4238 unless (opening_loc = node.opening_loc).nil?
4239 table.field("opening_loc", location_inspect(opening_loc))
4240 end
4241
4242 # content_loc
4243 table.field("content_loc", location_inspect(node.content_loc))
4244
4245 # closing_loc
4246 unless (closing_loc = node.closing_loc).nil?
4247 table.field("closing_loc", location_inspect(closing_loc))
4248 end
4249
4250 # unescaped
4251 table.field("unescaped", node.unescaped.inspect)
4252
4253 digraph.nodes << <<~DOT
4254 #{id} [
4255 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4256 ];
4257 DOT
4258
4259 super
4260 end
4261
4262 # Visit a SuperNode node.
4263 def visit_super_node(node)
4264 table = Table.new("SuperNode")
4265 id = node_id(node)
4266
4267 # keyword_loc
4268 table.field("keyword_loc", location_inspect(node.keyword_loc))
4269
4270 # lparen_loc
4271 unless (lparen_loc = node.lparen_loc).nil?
4272 table.field("lparen_loc", location_inspect(lparen_loc))
4273 end
4274
4275 # arguments
4276 unless (arguments = node.arguments).nil?
4277 table.field("arguments", port: true)
4278 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
4279 end
4280
4281 # rparen_loc
4282 unless (rparen_loc = node.rparen_loc).nil?
4283 table.field("rparen_loc", location_inspect(rparen_loc))
4284 end
4285
4286 # block
4287 unless (block = node.block).nil?
4288 table.field("block", port: true)
4289 digraph.edge("#{id}:block -> #{node_id(block)};")
4290 end
4291
4292 digraph.nodes << <<~DOT
4293 #{id} [
4294 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4295 ];
4296 DOT
4297
4298 super
4299 end
4300
4301 # Visit a SymbolNode node.
4302 def visit_symbol_node(node)
4303 table = Table.new("SymbolNode")
4304 id = node_id(node)
4305
4306 # flags
4307 table.field("flags", symbol_flags_inspect(node))
4308
4309 # opening_loc
4310 unless (opening_loc = node.opening_loc).nil?
4311 table.field("opening_loc", location_inspect(opening_loc))
4312 end
4313
4314 # value_loc
4315 unless (value_loc = node.value_loc).nil?
4316 table.field("value_loc", location_inspect(value_loc))
4317 end
4318
4319 # closing_loc
4320 unless (closing_loc = node.closing_loc).nil?
4321 table.field("closing_loc", location_inspect(closing_loc))
4322 end
4323
4324 # unescaped
4325 table.field("unescaped", node.unescaped.inspect)
4326
4327 digraph.nodes << <<~DOT
4328 #{id} [
4329 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4330 ];
4331 DOT
4332
4333 super
4334 end
4335
4336 # Visit a TrueNode node.
4337 def visit_true_node(node)
4338 table = Table.new("TrueNode")
4339 id = node_id(node)
4340
4341 digraph.nodes << <<~DOT
4342 #{id} [
4343 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4344 ];
4345 DOT
4346
4347 super
4348 end
4349
4350 # Visit a UndefNode node.
4351 def visit_undef_node(node)
4352 table = Table.new("UndefNode")
4353 id = node_id(node)
4354
4355 # names
4356 if node.names.any?
4357 table.field("names", port: true)
4358
4359 waypoint = "#{id}_names"
4360 digraph.waypoint("#{waypoint};")
4361
4362 digraph.edge("#{id}:names -> #{waypoint};")
4363 node.names.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4364 else
4365 table.field("names", "[]")
4366 end
4367
4368 # keyword_loc
4369 table.field("keyword_loc", location_inspect(node.keyword_loc))
4370
4371 digraph.nodes << <<~DOT
4372 #{id} [
4373 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4374 ];
4375 DOT
4376
4377 super
4378 end
4379
4380 # Visit a UnlessNode node.
4381 def visit_unless_node(node)
4382 table = Table.new("UnlessNode")
4383 id = node_id(node)
4384
4385 # keyword_loc
4386 table.field("keyword_loc", location_inspect(node.keyword_loc))
4387
4388 # predicate
4389 table.field("predicate", port: true)
4390 digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4391
4392 # then_keyword_loc
4393 unless (then_keyword_loc = node.then_keyword_loc).nil?
4394 table.field("then_keyword_loc", location_inspect(then_keyword_loc))
4395 end
4396
4397 # statements
4398 unless (statements = node.statements).nil?
4399 table.field("statements", port: true)
4400 digraph.edge("#{id}:statements -> #{node_id(statements)};")
4401 end
4402
4403 # else_clause
4404 unless (else_clause = node.else_clause).nil?
4405 table.field("else_clause", port: true)
4406 digraph.edge("#{id}:else_clause -> #{node_id(else_clause)};")
4407 end
4408
4409 # end_keyword_loc
4410 unless (end_keyword_loc = node.end_keyword_loc).nil?
4411 table.field("end_keyword_loc", location_inspect(end_keyword_loc))
4412 end
4413
4414 digraph.nodes << <<~DOT
4415 #{id} [
4416 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4417 ];
4418 DOT
4419
4420 super
4421 end
4422
4423 # Visit a UntilNode node.
4424 def visit_until_node(node)
4425 table = Table.new("UntilNode")
4426 id = node_id(node)
4427
4428 # flags
4429 table.field("flags", loop_flags_inspect(node))
4430
4431 # keyword_loc
4432 table.field("keyword_loc", location_inspect(node.keyword_loc))
4433
4434 # do_keyword_loc
4435 unless (do_keyword_loc = node.do_keyword_loc).nil?
4436 table.field("do_keyword_loc", location_inspect(do_keyword_loc))
4437 end
4438
4439 # closing_loc
4440 unless (closing_loc = node.closing_loc).nil?
4441 table.field("closing_loc", location_inspect(closing_loc))
4442 end
4443
4444 # predicate
4445 table.field("predicate", port: true)
4446 digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4447
4448 # statements
4449 unless (statements = node.statements).nil?
4450 table.field("statements", port: true)
4451 digraph.edge("#{id}:statements -> #{node_id(statements)};")
4452 end
4453
4454 digraph.nodes << <<~DOT
4455 #{id} [
4456 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4457 ];
4458 DOT
4459
4460 super
4461 end
4462
4463 # Visit a WhenNode node.
4464 def visit_when_node(node)
4465 table = Table.new("WhenNode")
4466 id = node_id(node)
4467
4468 # keyword_loc
4469 table.field("keyword_loc", location_inspect(node.keyword_loc))
4470
4471 # conditions
4472 if node.conditions.any?
4473 table.field("conditions", port: true)
4474
4475 waypoint = "#{id}_conditions"
4476 digraph.waypoint("#{waypoint};")
4477
4478 digraph.edge("#{id}:conditions -> #{waypoint};")
4479 node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
4480 else
4481 table.field("conditions", "[]")
4482 end
4483
4484 # then_keyword_loc
4485 unless (then_keyword_loc = node.then_keyword_loc).nil?
4486 table.field("then_keyword_loc", location_inspect(then_keyword_loc))
4487 end
4488
4489 # statements
4490 unless (statements = node.statements).nil?
4491 table.field("statements", port: true)
4492 digraph.edge("#{id}:statements -> #{node_id(statements)};")
4493 end
4494
4495 digraph.nodes << <<~DOT
4496 #{id} [
4497 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4498 ];
4499 DOT
4500
4501 super
4502 end
4503
4504 # Visit a WhileNode node.
4505 def visit_while_node(node)
4506 table = Table.new("WhileNode")
4507 id = node_id(node)
4508
4509 # flags
4510 table.field("flags", loop_flags_inspect(node))
4511
4512 # keyword_loc
4513 table.field("keyword_loc", location_inspect(node.keyword_loc))
4514
4515 # do_keyword_loc
4516 unless (do_keyword_loc = node.do_keyword_loc).nil?
4517 table.field("do_keyword_loc", location_inspect(do_keyword_loc))
4518 end
4519
4520 # closing_loc
4521 unless (closing_loc = node.closing_loc).nil?
4522 table.field("closing_loc", location_inspect(closing_loc))
4523 end
4524
4525 # predicate
4526 table.field("predicate", port: true)
4527 digraph.edge("#{id}:predicate -> #{node_id(node.predicate)};")
4528
4529 # statements
4530 unless (statements = node.statements).nil?
4531 table.field("statements", port: true)
4532 digraph.edge("#{id}:statements -> #{node_id(statements)};")
4533 end
4534
4535 digraph.nodes << <<~DOT
4536 #{id} [
4537 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4538 ];
4539 DOT
4540
4541 super
4542 end
4543
4544 # Visit a XStringNode node.
4545 def visit_x_string_node(node)
4546 table = Table.new("XStringNode")
4547 id = node_id(node)
4548
4549 # flags
4550 table.field("flags", encoding_flags_inspect(node))
4551
4552 # opening_loc
4553 table.field("opening_loc", location_inspect(node.opening_loc))
4554
4555 # content_loc
4556 table.field("content_loc", location_inspect(node.content_loc))
4557
4558 # closing_loc
4559 table.field("closing_loc", location_inspect(node.closing_loc))
4560
4561 # unescaped
4562 table.field("unescaped", node.unescaped.inspect)
4563
4564 digraph.nodes << <<~DOT
4565 #{id} [
4566 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4567 ];
4568 DOT
4569
4570 super
4571 end
4572
4573 # Visit a YieldNode node.
4574 def visit_yield_node(node)
4575 table = Table.new("YieldNode")
4576 id = node_id(node)
4577
4578 # keyword_loc
4579 table.field("keyword_loc", location_inspect(node.keyword_loc))
4580
4581 # lparen_loc
4582 unless (lparen_loc = node.lparen_loc).nil?
4583 table.field("lparen_loc", location_inspect(lparen_loc))
4584 end
4585
4586 # arguments
4587 unless (arguments = node.arguments).nil?
4588 table.field("arguments", port: true)
4589 digraph.edge("#{id}:arguments -> #{node_id(arguments)};")
4590 end
4591
4592 # rparen_loc
4593 unless (rparen_loc = node.rparen_loc).nil?
4594 table.field("rparen_loc", location_inspect(rparen_loc))
4595 end
4596
4597 digraph.nodes << <<~DOT
4598 #{id} [
4599 label=<#{table.to_dot.gsub(/\n/, "\n ")}>
4600 ];
4601 DOT
4602
4603 super
4604 end
4605
4606 private
4607
4608 # Generate a unique node ID for a node throughout the digraph.
4609 def node_id(node)
4610 "Node_#{node.object_id}"
4611 end
4612
4613 # Inspect a location to display the start and end line and column numbers.
4614 def location_inspect(location)
4615 "(#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column})"
4616 end
4617
4618 # Inspect a node that has arguments_node_flags flags to display the flags as a
4619 # comma-separated list.
4620 def arguments_node_flags_inspect(node)
4621 flags = [] #: Array[String]
4622 flags << "contains_forwarding" if node.contains_forwarding?
4623 flags << "contains_keywords" if node.contains_keywords?
4624 flags << "contains_keyword_splat" if node.contains_keyword_splat?
4625 flags << "contains_splat" if node.contains_splat?
4626 flags << "contains_multiple_splats" if node.contains_multiple_splats?
4627 flags.join(", ")
4628 end
4629
4630 # Inspect a node that has array_node_flags flags to display the flags as a
4631 # comma-separated list.
4632 def array_node_flags_inspect(node)
4633 flags = [] #: Array[String]
4634 flags << "contains_splat" if node.contains_splat?
4635 flags.join(", ")
4636 end
4637
4638 # Inspect a node that has call_node_flags flags to display the flags as a
4639 # comma-separated list.
4640 def call_node_flags_inspect(node)
4641 flags = [] #: Array[String]
4642 flags << "safe_navigation" if node.safe_navigation?
4643 flags << "variable_call" if node.variable_call?
4644 flags << "attribute_write" if node.attribute_write?
4645 flags << "ignore_visibility" if node.ignore_visibility?
4646 flags.join(", ")
4647 end
4648
4649 # Inspect a node that has encoding_flags flags to display the flags as a
4650 # comma-separated list.
4651 def encoding_flags_inspect(node)
4652 flags = [] #: Array[String]
4653 flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4654 flags << "forced_binary_encoding" if node.forced_binary_encoding?
4655 flags.join(", ")
4656 end
4657
4658 # Inspect a node that has integer_base_flags flags to display the flags as a
4659 # comma-separated list.
4660 def integer_base_flags_inspect(node)
4661 flags = [] #: Array[String]
4662 flags << "binary" if node.binary?
4663 flags << "decimal" if node.decimal?
4664 flags << "octal" if node.octal?
4665 flags << "hexadecimal" if node.hexadecimal?
4666 flags.join(", ")
4667 end
4668
4669 # Inspect a node that has interpolated_string_node_flags flags to display the flags as a
4670 # comma-separated list.
4671 def interpolated_string_node_flags_inspect(node)
4672 flags = [] #: Array[String]
4673 flags << "frozen" if node.frozen?
4674 flags << "mutable" if node.mutable?
4675 flags.join(", ")
4676 end
4677
4678 # Inspect a node that has keyword_hash_node_flags flags to display the flags as a
4679 # comma-separated list.
4680 def keyword_hash_node_flags_inspect(node)
4681 flags = [] #: Array[String]
4682 flags << "symbol_keys" if node.symbol_keys?
4683 flags.join(", ")
4684 end
4685
4686 # Inspect a node that has loop_flags flags to display the flags as a
4687 # comma-separated list.
4688 def loop_flags_inspect(node)
4689 flags = [] #: Array[String]
4690 flags << "begin_modifier" if node.begin_modifier?
4691 flags.join(", ")
4692 end
4693
4694 # Inspect a node that has parameter_flags flags to display the flags as a
4695 # comma-separated list.
4696 def parameter_flags_inspect(node)
4697 flags = [] #: Array[String]
4698 flags << "repeated_parameter" if node.repeated_parameter?
4699 flags.join(", ")
4700 end
4701
4702 # Inspect a node that has parentheses_node_flags flags to display the flags as a
4703 # comma-separated list.
4704 def parentheses_node_flags_inspect(node)
4705 flags = [] #: Array[String]
4706 flags << "multiple_statements" if node.multiple_statements?
4707 flags.join(", ")
4708 end
4709
4710 # Inspect a node that has range_flags flags to display the flags as a
4711 # comma-separated list.
4712 def range_flags_inspect(node)
4713 flags = [] #: Array[String]
4714 flags << "exclude_end" if node.exclude_end?
4715 flags.join(", ")
4716 end
4717
4718 # Inspect a node that has regular_expression_flags flags to display the flags as a
4719 # comma-separated list.
4720 def regular_expression_flags_inspect(node)
4721 flags = [] #: Array[String]
4722 flags << "ignore_case" if node.ignore_case?
4723 flags << "extended" if node.extended?
4724 flags << "multi_line" if node.multi_line?
4725 flags << "once" if node.once?
4726 flags << "euc_jp" if node.euc_jp?
4727 flags << "ascii_8bit" if node.ascii_8bit?
4728 flags << "windows_31j" if node.windows_31j?
4729 flags << "utf_8" if node.utf_8?
4730 flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4731 flags << "forced_binary_encoding" if node.forced_binary_encoding?
4732 flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding?
4733 flags.join(", ")
4734 end
4735
4736 # Inspect a node that has shareable_constant_node_flags flags to display the flags as a
4737 # comma-separated list.
4738 def shareable_constant_node_flags_inspect(node)
4739 flags = [] #: Array[String]
4740 flags << "literal" if node.literal?
4741 flags << "experimental_everything" if node.experimental_everything?
4742 flags << "experimental_copy" if node.experimental_copy?
4743 flags.join(", ")
4744 end
4745
4746 # Inspect a node that has string_flags flags to display the flags as a
4747 # comma-separated list.
4748 def string_flags_inspect(node)
4749 flags = [] #: Array[String]
4750 flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4751 flags << "forced_binary_encoding" if node.forced_binary_encoding?
4752 flags << "frozen" if node.frozen?
4753 flags << "mutable" if node.mutable?
4754 flags.join(", ")
4755 end
4756
4757 # Inspect a node that has symbol_flags flags to display the flags as a
4758 # comma-separated list.
4759 def symbol_flags_inspect(node)
4760 flags = [] #: Array[String]
4761 flags << "forced_utf8_encoding" if node.forced_utf8_encoding?
4762 flags << "forced_binary_encoding" if node.forced_binary_encoding?
4763 flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding?
4764 flags.join(", ")
4765 end
4766 end
4767 end