Changeset 51ec1ab for src/ControlStruct/LabelGenerator.cc
- Timestamp:
- Jan 31, 2022, 10:29:23 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- ca8c0362
- Parents:
- 45040b61
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelGenerator.cc
r45040b61 r51ec1ab 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Mon Nov 8 10:18:00 202113 // Update Count : 1711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 31 18:48:26 2022 13 // Update Count : 27 14 14 // 15 15 … … 17 17 #include <sstream> // for ostringstream 18 18 #include <list> // for list 19 using namespace std; 19 20 20 21 #include "LabelGenerator.h" 21 22 22 #include "AST/Attribute.hpp"23 #include "AST/Label.hpp"24 #include "AST/Stmt.hpp"25 23 #include "SynTree/Attribute.h" // for Attribute 26 24 #include "SynTree/Label.h" // for Label, operator<< … … 32 30 LabelGenerator * LabelGenerator::labelGenerator = nullptr; 33 31 34 35 36 37 38 32 LabelGenerator * LabelGenerator::getGenerator() { 33 if ( LabelGenerator::labelGenerator == 0 ) 34 LabelGenerator::labelGenerator = new LabelGenerator(); 35 return labelGenerator; 36 } 39 37 40 Label LabelGenerator::newLabel( std::string suffix, Statement * stmt ) { 41 std::ostringstream os; 42 os << "__L" << current++ << "__" << suffix; 43 if ( stmt && ! stmt->get_labels().empty() ) { 44 os << "_" << stmt->get_labels().front() << "__"; 45 } // if 46 std::string ret = os.str(); 47 Label l( ret ); 48 l.get_attributes().push_back( new Attribute("unused") ); 49 return l; 50 } 51 52 ast::Label LabelGenerator::newLabel( 53 const std::string & suffix, const ast::Stmt * stmt ) { 54 assert( stmt ); 55 56 std::ostringstream os; 57 os << "__L" << current++ << "__" << suffix; 58 if ( stmt && !stmt->labels.empty() ) { 59 os << "_" << stmt->labels.front() << "__"; 60 } 61 ast::Label ret_label( stmt->location, os.str() ); 62 ret_label.attributes.push_back( new ast::Attribute( "unused" ) ); 63 return ret_label; 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; 64 48 } 65 49 … … 67 51 68 52 // Local Variables: // 69 // tab-width: 4 //70 53 // mode: c++ // 71 // compile-command: "make install" //72 54 // End: //
Note: See TracChangeset
for help on using the changeset viewer.