1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // LabelGenerator.cc -- |
---|
8 | // |
---|
9 | // Author : Rodolfo G. Esteves |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Mon Jan 31 18:48:26 2022 |
---|
13 | // Update Count : 27 |
---|
14 | // |
---|
15 | |
---|
16 | #include <iostream> // for operator<<, basic_ostream |
---|
17 | #include <sstream> // for ostringstream |
---|
18 | #include <list> // for list |
---|
19 | using namespace std; |
---|
20 | |
---|
21 | #include "LabelGenerator.h" |
---|
22 | |
---|
23 | #include "SynTree/Attribute.h" // for Attribute |
---|
24 | #include "SynTree/Label.h" // for Label, operator<< |
---|
25 | #include "SynTree/Statement.h" // for Statement |
---|
26 | |
---|
27 | namespace ControlStruct { |
---|
28 | |
---|
29 | int LabelGenerator::current = 0; |
---|
30 | LabelGenerator * LabelGenerator::labelGenerator = nullptr; |
---|
31 | |
---|
32 | LabelGenerator * LabelGenerator::getGenerator() { |
---|
33 | if ( LabelGenerator::labelGenerator == 0 ) |
---|
34 | LabelGenerator::labelGenerator = new LabelGenerator(); |
---|
35 | return labelGenerator; |
---|
36 | } |
---|
37 | |
---|
38 | Label LabelGenerator::newLabel( string suffix, Statement * stmt ) { |
---|
39 | ostringstream os; |
---|
40 | os << "__L_OLD" << current++ << "__" << suffix; |
---|
41 | if ( stmt && ! stmt->get_labels().empty() ) { |
---|
42 | os << "_" << stmt->get_labels().front() << "__"; |
---|
43 | } // if |
---|
44 | string ret = os.str(); |
---|
45 | Label l( ret ); |
---|
46 | l.get_attributes().push_back( new Attribute( "unused" ) ); |
---|
47 | return l; |
---|
48 | } |
---|
49 | |
---|
50 | } // namespace ControlStruct |
---|
51 | |
---|
52 | // Local Variables: // |
---|
53 | // mode: c++ // |
---|
54 | // End: // |
---|