diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-04 08:52:50 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-04 08:52:50 +0300 |
commit | cb92ab7aa657c57446cc9e0087f1364adaac8fee (patch) | |
tree | a3bb5c0d5bd18a2164e8e568596049d2107fb460 /profile.c | |
parent | a0d7edfff1b489e50ae8751429ebf925948b746f (diff) | |
download | egawk-cb92ab7aa657c57446cc9e0087f1364adaac8fee.tar.gz egawk-cb92ab7aa657c57446cc9e0087f1364adaac8fee.tar.bz2 egawk-cb92ab7aa657c57446cc9e0087f1364adaac8fee.zip |
Improve printing empty for loop header in profiler.
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -731,20 +731,28 @@ cleanup: ip = pc + 1; indent(ip->forloop_body->exec_count); fprintf(prof_fp, "%s (", op2str(pc->opcode)); - pprint(pc->nexti, ip->forloop_cond, true); - fprintf(prof_fp, "; "); - if (ip->forloop_cond->opcode == Op_no_op && - ip->forloop_cond->nexti == ip->forloop_body) + /* If empty for looop header, print it a little more nicely. */ + if ( pc->nexti->opcode == Op_no_op + && ip->forloop_cond == pc->nexti + && pc->target_continue->opcode == Op_jmp) { + fprintf(prof_fp, ";;"); + } else { + pprint(pc->nexti, ip->forloop_cond, true); fprintf(prof_fp, "; "); - else { - pprint(ip->forloop_cond, ip->forloop_body, true); - t1 = pp_pop(); - fprintf(prof_fp, "%s; ", t1->pp_str); - pp_free(t1); - } - pprint(pc->target_continue, pc->target_break, true); + if (ip->forloop_cond->opcode == Op_no_op && + ip->forloop_cond->nexti == ip->forloop_body) + fprintf(prof_fp, "; "); + else { + pprint(ip->forloop_cond, ip->forloop_body, true); + t1 = pp_pop(); + fprintf(prof_fp, "%s; ", t1->pp_str); + pp_free(t1); + } + + pprint(pc->target_continue, pc->target_break, true); + } fprintf(prof_fp, ") {\n"); indent_in(); pprint(ip->forloop_body->nexti, pc->target_continue, false); |