source: src/ControlStruct/LabelGenerator.cc @ 51ec1ab

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 51ec1ab was 51ec1ab, 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 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
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 {
28
29int LabelGenerator::current = 0;
30LabelGenerator * LabelGenerator::labelGenerator = nullptr;
31
32LabelGenerator * LabelGenerator::getGenerator() {
33        if ( LabelGenerator::labelGenerator == 0 )
34                LabelGenerator::labelGenerator = new LabelGenerator();
35        return labelGenerator;
36}
37
38Label 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: //
Note: See TracBrowser for help on using the repository browser.