diff --git a/src/html_renderer.ml b/src/html_renderer.ml new file mode 100644 index 0000000..f8b38cb --- /dev/null +++ b/src/html_renderer.ml @@ -0,0 +1,46 @@ +(** HTML Renderer + + Renders the output of computations on a given program as an HTML webpage. + *) + +(** 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 + List.map (fun render_sub -> + [ + ("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_asm", List.map (fun row -> [ + ("instr_addr", box_string (render_addr row.instr_addr)); + ("instr_bytes", box_string ( + Format.asprintf "%a" Asm_acquire.pp_hex_bytes row.instr_bytes + )); + ("instr_asm", box_string row.instr_asm); + ("instr_events", (List.map (fun event -> + let typ, id, bound = Renderer.(match event with + | BoxStart(id, bound) -> "start", id, bound + | BoxEnd(id, bound) -> "end", id, bound + ) in + [ + ("typ", box_string typ); + ("id", box_int id); + ("bound", box_string @@ render_addr bound); + ] |> box_obj) + row.instr_annot.Renderer.events) + |> box_list); + ] |> box_obj) render_sub.sub_asm + |> box_list; + )] |> box_obj + ) annotated_prog + |> box_list + )) + +(** [render render_data] renders the given [render_data] to a string. *) +let render render_data = Jingoo.( + let annotated_prog = Renderer.render_data_to_annotated_asm render_data in + let models = [ + ("subroutines", render_prog_box annotated_prog); + ] in + Jg_template.from_file "src/render_html.jingoo" ~models:models +) diff --git a/src/render_html.jingoo b/src/render_html.jingoo new file mode 100644 index 0000000..d7db314 --- /dev/null +++ b/src/render_html.jingoo @@ -0,0 +1,67 @@ + + +
+ + + + + {% for subroutine in subroutines %} +{{ row.instr_bytes }}+ {{ row.instr_asm }} +