source: src/ControlStruct/LabelGenerator.cc @ 3322180

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

formatting

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[51587aa]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//
[0f8e4ac]7// LabelGenerator.cc --
[51587aa]8//
[843054c2]9// Author           : Rodolfo G. Esteves
[51587aa]10// Created On       : Mon May 18 07:44:20 2015
[51ec1ab]11// Last Modified By : Peter A. Buhr
[ca8c0362]12// Last Modified On : Mon Jan 31 22:30:26 2022
13// Update Count     : 28
[51587aa]14//
[a08ba92]15
[21f0aa8]16#include <iostream>             // for operator<<, basic_ostream
17#include <sstream>              // for ostringstream
[d180746]18#include <list>                 // for list
[51ec1ab]19using namespace std;
[51b7345]20
21#include "LabelGenerator.h"
[b8ab91a]22
[d180746]23#include "SynTree/Attribute.h"  // for Attribute
24#include "SynTree/Label.h"      // for Label, operator<<
25#include "SynTree/Statement.h"  // for Statement
[51b7345]26
27namespace ControlStruct {
[de31a1d]28int LabelGenerator::current = 0;
29LabelGenerator * LabelGenerator::labelGenerator = nullptr;
[51b7345]30
[51ec1ab]31LabelGenerator * LabelGenerator::getGenerator() {
32        if ( LabelGenerator::labelGenerator == 0 )
33                LabelGenerator::labelGenerator = new LabelGenerator();
34        return labelGenerator;
35}
[b8ab91a]36
[51ec1ab]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;
[b8ab91a]47}
[51b7345]48} // namespace ControlStruct
[a08ba92]49
[51587aa]50// Local Variables: //
51// mode: c++ //
52// End: //
Note: See TracBrowser for help on using the repository browser.