Changeset b8ab91a
- 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
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r77c01ec rb8ab91a 131 131 // declared type, derived from parameter declarations 132 132 ptr<FunctionType> type; 133 /// Null for the forward declaration of a function. 133 134 ptr<CompoundStmt> stmts; 134 135 std::vector< ptr<Expr> > withExprs; -
src/AST/Stmt.hpp
r77c01ec rb8ab91a 175 175 class CaseStmt final : public Stmt { 176 176 public: 177 /// Null for the default label. 177 178 ptr<Expr> cond; 178 179 std::vector<ptr<Stmt>> stmts; -
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 -
src/main.cc
r77c01ec rb8ab91a 53 53 #include "ControlStruct/ExceptDecl.h" // for translateExcept 54 54 #include "ControlStruct/ExceptTranslate.h" // for translateEHM 55 #include "ControlStruct/FixLabels.hpp" // for fixLabels 55 56 #include "ControlStruct/Mutate.h" // for mutate 56 57 #include "GenPoly/Box.h" // for box … … 334 335 335 336 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) ); 336 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );337 337 338 338 CodeTools::fillLocations( translationUnit ); … … 347 347 forceFillCodeLocations( transUnit ); 348 348 349 PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) ); 349 350 PASS( "Fix Names", CodeGen::fixNames( transUnit ) ); 350 351 PASS( "Gen Init", InitTweak::genInit( transUnit ) ); … … 383 384 translationUnit = convert( move( transUnit ) ); 384 385 } else { 386 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 385 387 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 386 388 PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
Note: See TracChangeset
for help on using the changeset viewer.