about summary refs log tree commit diff homepage
path: root/stp/AST/ASTUtil.cpp
blob: bc36812c3d2eebe2946f34f5dc2acbf931b87275 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/********************************************************************
 * AUTHORS: Vijay Ganesh, David L. Dill
 *
 * BEGIN DATE: November, 2005
 *
 * LICENSE: Please view LICENSE file in the home dir of this Program
 ********************************************************************/
// -*- c++ -*-

#include "ASTUtil.h"
#include <ostream>

namespace BEEV {
  ostream &operator<<(ostream &os, const Spacer &sp) {
    // Instead of wrapping lines with hundreds of spaces, prints
    // a "+" at the beginning of the line for each wrap-around.
    // so lines print like: +14+		(XOR ...
    int blanks = sp._spaces % 60;
    int wraps = sp._spaces / 60;
    if (wraps > 0) {
      os << "+" << wraps;
    }
    for (int i = 0; i < blanks; i++)
      os << " ";  
    return os;
  }
   
  //this function accepts the name of a function (as a char *), and
  //records some stats about it. if the input is "print_func_stats",
  //the function will then print the stats that it has collected.
  void CountersAndStats(const char * functionname) {
    if(!stats)
      return;
    static function_counters s;
    
    if(!strcmp(functionname,"print_func_stats")) {
      cout << endl;
      for(hash_map<const char*,int,hash<const char*>,eqstr>::iterator it=s.begin(),itend=s.end();
	  it!=itend;it++)
	cout << "Number of times the function: " << it->first << ": is called: " << it->second << endl;
      return;
    }
    s[functionname] += 1;
  }
};// end of namespace