Changeset b8ab91a for src/ControlStruct
- Timestamp:
- Nov 5, 2021, 1:46:46 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 21fe17f
- Parents:
- 77c01ec
- Location:
- src/ControlStruct
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/LabelGenerator.cc
r77c01ec rb8ab91a 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Mar 11 22:23:20 201913 // Update Count : 1 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Nov 1 12:21:00 2021 13 // Update Count : 16 14 14 // 15 15 … … 19 19 20 20 #include "LabelGenerator.h" 21 22 #include "AST/Attribute.hpp" 23 #include "AST/Label.hpp" 24 #include "AST/Stmt.hpp" 21 25 #include "SynTree/Attribute.h" // for Attribute 22 26 #include "SynTree/Label.h" // for Label, operator<< … … 43 47 return l; 44 48 } 49 50 LabelGenerator_new * LabelGenerator_new::labelGenerator = nullptr; 51 52 LabelGenerator_new * LabelGenerator_new::getGenerator() { 53 if ( nullptr == labelGenerator ) { 54 labelGenerator = new LabelGenerator_new(); 55 } 56 return labelGenerator; 57 } 58 59 ast::Label LabelGenerator_new::newLabel( 60 const std::string & suffix, const ast::Stmt * stmt ) { 61 assert( stmt ); 62 63 std::ostringstream os; 64 os << "__L" << current++ << "__" << suffix; 65 if ( stmt && !stmt->labels.empty() ) { 66 os << "_" << stmt->labels.front() << "__"; 67 } 68 ast::Label ret_label( stmt->location, os.str() ); 69 ret_label.attributes.push_back( new ast::Attribute( "unused" ) ); 70 return ret_label; 71 } 72 45 73 } // namespace ControlStruct 46 74 -
src/ControlStruct/LabelGenerator.h
r77c01ec rb8ab91a 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:20:14 201713 // Update Count : 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Nov 1 12:19:00 2021 13 // Update Count : 7 14 14 // 15 15 … … 21 21 22 22 class Statement; 23 namespace ast { 24 class Stmt; 25 class Label; 26 } 23 27 24 28 namespace ControlStruct { … … 35 39 static LabelGenerator *labelGenerator; 36 40 }; 41 42 class LabelGenerator_new { 43 int current; 44 static LabelGenerator_new *labelGenerator; 45 46 LabelGenerator_new() : current(0) {} 47 public: 48 static LabelGenerator_new *getGenerator(); 49 50 ast::Label newLabel( const std::string& suffix, const ast::Stmt * stmt ); 51 void reset() { current = 0; } 52 void rewind() { --current; } 53 }; 54 37 55 } // namespace ControlStruct 38 56 -
src/ControlStruct/module.mk
r77c01ec rb8ab91a 18 18 ControlStruct/ExceptDecl.cc \ 19 19 ControlStruct/ExceptDecl.h \ 20 ControlStruct/FixLabels.cpp \ 21 ControlStruct/FixLabels.hpp \ 20 22 ControlStruct/ForExprMutator.cc \ 21 23 ControlStruct/ForExprMutator.h \ … … 26 28 ControlStruct/MLEMutator.cc \ 27 29 ControlStruct/MLEMutator.h \ 30 ControlStruct/MultiLevelExit.cpp \ 31 ControlStruct/MultiLevelExit.hpp \ 28 32 ControlStruct/Mutate.cc \ 29 33 ControlStruct/Mutate.h
Note: See TracChangeset
for help on using the changeset viewer.