diff --git a/src/html_renderer.ml b/src/html_renderer.ml index d493b42..29e10ee 100644 --- a/src/html_renderer.ml +++ b/src/html_renderer.ml @@ -3,6 +3,22 @@ Renders the output of computations on a given program as an HTML webpage. *) +(** Generates a fresh unique identifier *) +let fresh_uuid = + let next = ref 0 in + fun () -> + let out = !next in + incr next ; out + +(** Checks whether a submethod is relevant to show, or whether it should be + hidden by default. *) +let is_sub_relevant sub = Renderer.AnnotAsm.( + List.exists + (fun instr -> instr.instr_annot.Renderer.events <> []) + sub.sub_asm +) + + (** Box `AnnotAsm.asm_info_t` as a Jingoo tvalue *) let render_prog_box annotated_prog = Jingoo.Jg_types.(Renderer.AnnotAsm.( let render_addr addr = (Format.sprintf "%04x" addr) in @@ -11,6 +27,10 @@ let render_prog_box annotated_prog = Jingoo.Jg_types.(Renderer.AnnotAsm.( ("sub_section", box_string render_sub.sub_section); ("sub_name", box_string render_sub.sub_name); ("sub_addr", box_string (Format.sprintf "%016x" render_sub.sub_addr)); + ("sub_uuid", box_int @@ fresh_uuid ()); + ("sub_relevant", box_int @@ (match is_sub_relevant render_sub with + | true -> 1 + | false -> 0)); ("sub_asm", List.map (fun row -> [ ("instr_addr", box_string (render_addr row.instr_addr)); ("instr_bytes", box_string ( diff --git a/src/render_html.jingoo b/src/render_html.jingoo index f63dc5d..4c46acc 100644 --- a/src/render_html.jingoo +++ b/src/render_html.jingoo @@ -28,6 +28,17 @@ .subroutine { margin: 20px 0; } + + .sub_collapser { + background-color: #8c8c8c; + color: white; + font-weight: bold; + border-radius: 50%; + text-align: center; + display: inline-block; + width: 1em; + } + .sub_body { margin-left: 4ex; } @@ -70,6 +81,22 @@ } } + +
@@ -79,11 +106,17 @@ {% for subroutine in prog.prog %}
+ + - + {{ subroutine.sub_addr }} [{{ subroutine.sub_section }}] <{{ subroutine.sub_name }}>:
-
+
{% for row in subroutine.sub_asm %} {% for event in row.instr_events %} {% if event.typ == "start" %} @@ -106,6 +139,9 @@ {% endfor %}
+ {% if not subroutine.sub_relevant %} + + {% endif %} {% endfor %}
{% endfor %}