Changeset de31a1d for src/ControlStruct
- Timestamp:
- Nov 8, 2021, 10:51:48 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- cb921d4
- Parents:
- 817bb3c
- Location:
- src/ControlStruct
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ControlStruct/FixLabels.cpp ¶
r817bb3c rde31a1d 28 28 class FixLabelsCore final : public ast::WithGuards { 29 29 LabelToStmt labelTable; 30 LabelGenerator _new* label_gen;30 LabelGenerator * label_gen; 31 31 public: 32 FixLabelsCore( LabelGenerator _new* gen = nullptr ) :32 FixLabelsCore( LabelGenerator * gen = nullptr ) : 33 33 labelTable(), 34 label_gen( gen ? gen : LabelGenerator _new::getGenerator() )34 label_gen( gen ? gen : LabelGenerator::getGenerator() ) 35 35 {} 36 36 -
TabularUnified src/ControlStruct/LabelGenerator.cc ¶
r817bb3c rde31a1d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Nov 1 12:21:00 202113 // Update Count : 1 612 // Last Modified On : Mon Nov 8 10:18:00 2021 13 // Update Count : 17 14 14 // 15 15 … … 28 28 29 29 namespace ControlStruct { 30 LabelGenerator * LabelGenerator::labelGenerator = 0; 30 31 int LabelGenerator::current = 0; 32 LabelGenerator * LabelGenerator::labelGenerator = nullptr; 31 33 32 34 LabelGenerator * LabelGenerator::getGenerator() { … … 48 50 } 49 51 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( 52 ast::Label LabelGenerator::newLabel( 60 53 const std::string & suffix, const ast::Stmt * stmt ) { 61 54 assert( stmt ); -
TabularUnified src/ControlStruct/LabelGenerator.h ¶
r817bb3c rde31a1d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Nov 1 12:19:00 202113 // Update Count : 712 // Last Modified On : Mon Nov 8 10:16:00 2021 13 // Update Count : 8 14 14 // 15 15 … … 27 27 28 28 namespace ControlStruct { 29 class LabelGenerator {30 public:31 static LabelGenerator *getGenerator();32 Label newLabel(std::string suffix, Statement * stmt = nullptr);33 void reset() { current = 0; }34 void rewind() { current--; }35 protected:36 LabelGenerator(): current(0) {}37 private:38 int current;39 static LabelGenerator *labelGenerator;40 };41 29 42 class LabelGenerator _new{43 int current;44 static LabelGenerator _new*labelGenerator;45 46 LabelGenerator _new() : current(0) {}30 class LabelGenerator { 31 static int current; 32 static LabelGenerator *labelGenerator; 33 protected: 34 LabelGenerator() {} 47 35 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; }36 static LabelGenerator *getGenerator(); 37 static Label newLabel(std::string suffix, Statement * stmt = nullptr); 38 static ast::Label newLabel( const std::string&, const ast::Stmt * ); 39 static void reset() { current = 0; } 40 static void rewind() { current--; } 53 41 }; 54 42 -
TabularUnified src/ControlStruct/MultiLevelExit.cpp ¶
r817bb3c rde31a1d 105 105 public ast::WithVisitorRef<MultiLevelExitCore>, 106 106 public ast::WithShortCircuiting, public ast::WithGuards { 107 MultiLevelExitCore( const LabelToStmt & lt, LabelGenerator _new* lg );107 MultiLevelExitCore( const LabelToStmt & lt, LabelGenerator * lg ); 108 108 109 109 void previsit( const ast::FunctionDecl * ); … … 131 131 std::vector<Entry> enclosing_control_structures; 132 132 ast::Label break_label; 133 LabelGenerator _new* label_gen;133 LabelGenerator * label_gen; 134 134 bool inFinally; 135 135 … … 155 155 156 156 MultiLevelExitCore::MultiLevelExitCore( 157 const LabelToStmt & lt, LabelGenerator _new* lg ) :157 const LabelToStmt & lt, LabelGenerator * lg ) : 158 158 target_table( lt ), break_label( CodeLocation(), "" ), label_gen( lg ), 159 159 inFinally( false ) … … 608 608 const ast::CompoundStmt * stmt, 609 609 const LabelToStmt & labelTable, 610 LabelGenerator _new* labelGen ) {610 LabelGenerator * labelGen ) { 611 611 // Must start in the body, so FunctionDecls can be a stopping point. 612 612 ast::Pass<MultiLevelExitCore> visitor( labelTable, labelGen ); -
TabularUnified src/ControlStruct/MultiLevelExit.hpp ¶
r817bb3c rde31a1d 26 26 namespace ControlStruct { 27 27 28 class LabelGenerator _new;28 class LabelGenerator; 29 29 using LabelToStmt = std::map<ast::Label, const ast::Stmt *>; 30 30 31 31 /// Mutate a function body to handle multi-level exits. 32 32 const ast::CompoundStmt * multiLevelExitUpdate( 33 const ast::CompoundStmt *, const LabelToStmt &, LabelGenerator _new*);33 const ast::CompoundStmt *, const LabelToStmt &, LabelGenerator *); 34 34 35 35 }
Note: See TracChangeset
for help on using the changeset viewer.