source: src/ControlStruct/LabelGenerator.cc @ 8419b76

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 8419b76 was ca8c0362, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

formatting

  • 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 : Mon Jan 31 22:30:26 2022
13// Update Count     : 28
14//
15
16#include <iostream>             // for operator<<, basic_ostream
17#include <sstream>              // for ostringstream
18#include <list>                 // for list
19using 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
27namespace ControlStruct {
28int LabelGenerator::current = 0;
29LabelGenerator * LabelGenerator::labelGenerator = nullptr;
30
31LabelGenerator * LabelGenerator::getGenerator() {
32        if ( LabelGenerator::labelGenerator == 0 )
33                LabelGenerator::labelGenerator = new LabelGenerator();
34        return labelGenerator;
35}
36
37Label LabelGenerator::newLabel( string suffix, Statement * stmt ) {
38        ostringstream os;
39        os << "__L_OLD" << current++ << "__" << suffix;
40        if ( stmt && ! stmt->get_labels().empty() ) {
41                os << "_" << stmt->get_labels().front() << "__";
42        } // if
43        string ret = os.str();
44        Label l( ret );
45        l.get_attributes().push_back( new Attribute( "unused" ) );
46        return l;
47}
48} // namespace ControlStruct
49
50// Local Variables: //
51// mode: c++ //
52// End: //
Note: See TracBrowser for help on using the repository browser.