source: src/ControlStruct/LabelGenerator.cc @ 6d49ea3

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 6d49ea3 was d180746, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 2

  • Property mode set to 100644
File size: 1.5 KB
Line 
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 : Tue Jun 23 12:18:34 2015
13// Update Count     : 13
14//
15
16#include <iostream>             // for operator<<, basic_ostream, ostringstream
17#include <list>                 // for list
18
19#include "LabelGenerator.h"
20#include "SynTree/Attribute.h"  // for Attribute
21#include "SynTree/Label.h"      // for Label, operator<<
22#include "SynTree/Statement.h"  // for Statement
23
24namespace ControlStruct {
25        LabelGenerator *LabelGenerator::labelGenerator = 0;
26
27        LabelGenerator *LabelGenerator::getGenerator() {
28                if ( LabelGenerator::labelGenerator == 0 )
29                        LabelGenerator::labelGenerator = new LabelGenerator();
30
31                return labelGenerator;
32        }
33
34        Label LabelGenerator::newLabel( std::string suffix, Statement * stmt ) {
35                std::ostringstream os;
36                os << "__L" << current++ << "__" << suffix;
37                if ( stmt && ! stmt->get_labels().empty() ) {
38                        os << "_" << stmt->get_labels().front() << "__";
39                }
40                std::string ret = os.str();
41                Label l( ret );
42                l.get_attributes().push_back( new Attribute("unused") );
43                return l;
44        }
45} // namespace ControlStruct
46
47// Local Variables: //
48// tab-width: 4 //
49// mode: c++ //
50// compile-command: "make install" //
51// End: //
Note: See TracBrowser for help on using the repository browser.