let compute () =
let file = Ast.get () in
let v = new slocVisitor in
v#set_standalone true;
visitCilFileSameGlobals (v:>cilVisitor) file;
v#complete_stats ();
LastResult.set
{ call_statements = v#calls;
goto_statements = v#gotos;
assign_statements = v#assigns;
if_statements = v#ifs;
mem_access = v#mem_access;
loop_statements = v#loops;
function_definitions = v#funcs;
sloc = v#sloc;
functions_without_source = v#functions_no_source;
functions_with_source = v#functions_with_source;
cyclos = (v#ifs +v#loops) - v#exits +2*v#funcs
};
let cout = open_out "metrics.html" in
let fmt = formatter_of_out_channel cout in
fprintf fmt "<!DOCTYPE HTML PUBLIC >\n";
fprintf fmt "<html>\n";
fprintf fmt "<head>\n";
fprintf fmt "</head>\n";
fprintf fmt "<body>\n";
fprintf fmt "<div style=\"text-align: left;\">\n";
fprintf fmt "<h1><span style=\"font-weight: bold;\">Metrics</span></h1>\n";
fprintf fmt "<h2>Synthetic results</h2>\n";
fprintf fmt "<br>\n";
fprintf fmt "<span style=\"font-weight: bold;\">Defined function</span> (%d):<br>\n"
(VarinfoHashtbl.length v#functions_with_source);
fprintf fmt "@[ %a@]@ <br>\n" pretty_set v#functions_with_source;
fprintf fmt "<br>\n";
fprintf fmt "<span style=\"font-weight: bold;\">Undefined functions</span> (%d):<br>\n" (VarinfoHashtbl.length v#functions_no_source);
fprintf fmt "@[ %a@]@ <br>\n" pretty_set v#functions_no_source;
fprintf fmt "<br>\n";
fprintf fmt "<span style=\"font-weight: bold;\">Potential entry points</span> (%d):<br>\n" (number_entry_points v#functions_with_source);
fprintf fmt "@[ %a@]@ <br>\n" pretty_entry_points v#functions_with_source;
fprintf fmt "<br>\n";
fprintf fmt "<span style=\"font-weight: bold;\">SLOC:</span> (%d)<br>\n" v#sloc;
fprintf fmt "<span style=\"font-weight: bold;\">Number of if statements:</span> (%d)<br>\n" v#ifs;
fprintf fmt "<span style=\"font-weight: bold;\">Number of assignments:</span> (%d)<br>\n" v#assigns;
fprintf fmt "<span style=\"font-weight: bold;\">Number of loops:</span> (%d)<br>\n" v#loops;
fprintf fmt "<span style=\"font-weight: bold;\">Number of calls:</span> (%d)<br>\n" v#calls;
fprintf fmt "<span style=\"font-weight: bold;\">Number of gotos:</span> (%d)<br>\n" v#gotos;
fprintf fmt "<span style=\"font-weight: bold;\">Number of pointer access:</span> (%d)<br>\n" v#mem_access;
fprintf fmt "<br>\n";
fprintf fmt "<h2>Detailed results</h2>\n";
fprintf fmt "<br>\n";
v#print_stats fmt;
close_out cout;
Metrics_parameters.feedback "Metrics printed to file metrics.html"