From b15c465c2238a4414925c8f6bce15c89bdd93e44 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Tue, 13 Oct 2009 14:44:29 +0200 Subject: PR10257: Add support for sprint[ln](@hist_*). * parse.cxx (parser::parse_symbol): Add sprint[ln] to @hist_* hack. * runtime/stat-common.c: Replace reprint with new reprint_buf, add more generic _stp_stat_print_histogram_buf and call it from the older one. Also correct some formatting issues. * translate.cxx (c_unparser::visit_print_format): Add sprint case. --- translate.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 1278a8d5..bc5d6158 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4083,6 +4083,14 @@ c_tmpcounter::visit_print_format (print_format* e) arr->indexes[i]->visit(this); } } + + // And the result for sprint[ln](@hist_*) + if (!e->print_to_stream) + { + exp_type ty = pe_string; + tmpvar res = parent->gensym(ty); + res.declare(*parent); + } } else { @@ -4145,8 +4153,18 @@ c_unparser::visit_print_format (print_format* e) o->newline() << "c->last_stmt = " << lex_cast_qstring(*e->tok) << ";"; o->newline() << "goto out;"; o->newline(-1) << "} else"; - o->newline(1) << "_stp_stat_print_histogram (" << v->hist() << ", " << agg.value() << ");"; - o->indent(-1); + if (e->print_to_stream) + { + o->newline(1) << "_stp_stat_print_histogram (" << v->hist() << ", " << agg.value() << ");"; + o->indent(-1); + } + else + { + exp_type ty = pe_string; + tmpvar res = gensym (ty); + o->newline(1) << "_stp_stat_print_histogram_buf (" << res.value() << ", MAXSTRINGLEN, " << v->hist() << ", " << agg.value() << ");"; + o->newline(-1) << res.value() << ";"; + } } delete v; -- cgit