Changeset fa2c005 for src/Validate
- Timestamp:
- Jun 8, 2023, 3:19:43 PM (3 years ago)
- Branches:
- ADT
- Parents:
- 044ae62
- Location:
- src/Validate
- Files:
-
- 7 edited
-
EliminateTypedef.cpp (modified) (2 diffs)
-
FixQualifiedTypes.cpp (modified) (1 diff)
-
HoistStruct.cpp (modified) (4 diffs)
-
HoistStruct.hpp (modified) (1 diff)
-
LinkReferenceToTypes.cpp (modified) (3 diffs)
-
NoIdSymbolTable.hpp (modified) (2 diffs)
-
ReplaceTypedef.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/EliminateTypedef.cpp
r044ae62 rfa2c005 31 31 ast::StructDecl const * previsit( ast::StructDecl const * decl ); 32 32 ast::UnionDecl const * previsit( ast::UnionDecl const * decl ); 33 ast::AdtDecl const * previsit( ast::AdtDecl const * decl ); 33 34 // Remove typedefs from statement lists. 34 35 ast::CompoundStmt const * previsit( ast::CompoundStmt const * stmt ); … … 65 66 } 66 67 68 ast::AdtDecl const * EliminateTypedefCore::previsit( ast::AdtDecl const * decl ) { 69 return field_erase_if( decl, &ast::AdtDecl::members, isTypedef ); 70 } 71 67 72 ast::CompoundStmt const * EliminateTypedefCore::previsit( ast::CompoundStmt const * stmt ) { 68 73 return field_erase_if( stmt, &ast::CompoundStmt::kids, isTypedefStmt ); -
src/Validate/FixQualifiedTypes.cpp
r044ae62 rfa2c005 59 59 instp = inst; 60 60 } else if ( auto inst = parent.as<ast::UnionInstType>() ) { 61 aggr = inst->base; 62 instp = inst; 63 } else if ( auto inst = parent.as<ast::AdtInstType>() ) { 61 64 aggr = inst->base; 62 65 instp = inst; -
src/Validate/HoistStruct.cpp
r044ae62 rfa2c005 28 28 return dynamic_cast< ast::StructDecl const * >( decl ) 29 29 || dynamic_cast< ast::UnionDecl const * >( decl ) 30 || dynamic_cast< ast::StaticAssertDecl const * >( decl ); 30 || dynamic_cast< ast::StaticAssertDecl const * >( decl ) 31 || dynamic_cast< ast::AdtDecl const * >( decl ); 31 32 } 32 33 … … 45 46 ast::UnionInstType const * previsit( ast::UnionInstType const * type ); 46 47 ast::EnumInstType const * previsit( ast::EnumInstType const * type ); 48 ast::AdtDecl const * previsit( ast::AdtDecl const * decl ); 49 ast::AdtDecl const * postvisit( ast::AdtDecl const * decl ); 47 50 48 51 private: … … 100 103 } 101 104 105 ast::AdtDecl const * HoistStructCore::previsit( ast::AdtDecl const * decl ) { 106 return preAggregate( decl ); 107 } 108 109 ast::AdtDecl const * HoistStructCore::postvisit( ast::AdtDecl const * decl ) { 110 return postAggregate( decl ); 111 } 112 102 113 ast::StructDecl const * HoistStructCore::postvisit( ast::StructDecl const * decl ) { 103 114 return postAggregate( decl ); … … 138 149 } 139 150 140 void hoistAdt( [[maybe_unused]] ast::TranslationUnit & trnaslationUnit ) {141 142 }143 144 151 } // namespace Validate 145 152 -
src/Validate/HoistStruct.hpp
r044ae62 rfa2c005 24 24 /// Flattens nested type declarations. (Run right after Fix Qualified Types.) 25 25 void hoistStruct( ast::TranslationUnit & translationUnit ); 26 void hoistAdt( ast::TranslationUnit & trnaslationUnit );27 26 28 27 } -
src/Validate/LinkReferenceToTypes.cpp
r044ae62 rfa2c005 20 20 #include "Validate/ForallPointerDecay.hpp" 21 21 #include "Validate/NoIdSymbolTable.hpp" 22 #include <assert.h> 22 23 23 24 namespace Validate { … … 35 36 ast::UnionInstType const * postvisit( ast::UnionInstType const * type ); 36 37 ast::TraitInstType const * postvisit( ast::TraitInstType const * type ); 38 ast::AdtInstType const * postvisit( ast::AdtInstType const * type ); 37 39 void previsit( ast::QualifiedType const * type ); 38 40 void postvisit( ast::QualifiedType const * type ); … … 107 109 auto mut = ast::mutate( type ); 108 110 forwardStructs[ mut->name ].push_back( mut ); 111 type = mut; 112 } 113 return type; 114 } 115 116 ast::AdtInstType const * LinkTypesCore::postvisit( ast::AdtInstType const * type ) { 117 ast::AdtDecl const * decl = symtab.lookupAdt( type->name ); 118 assert( decl != nullptr ); 119 if ( decl ) { 120 auto mut = ast::mutate( type ); 121 mut->base = const_cast<ast::AdtDecl *>( decl ); 109 122 type = mut; 110 123 } -
src/Validate/NoIdSymbolTable.hpp
r044ae62 rfa2c005 41 41 FORWARD_1( lookupUnion , const std::string & ) 42 42 FORWARD_1( lookupTrait , const std::string & ) 43 FORWARD_1( lookupAdt , const std::string & ) 43 44 FORWARD_1( addType , const ast::NamedTypeDecl * ) 44 45 FORWARD_1( addStruct, const ast::StructDecl * ) … … 49 50 FORWARD_1( addStruct, const std::string & ) 50 51 FORWARD_1( addUnion , const std::string & ) 52 FORWARD_1( addAdt , const std::string & ) 51 53 FORWARD_2( addWith , const std::vector< ast::ptr<ast::Expr> > &, const ast::Decl * ) 52 54 -
src/Validate/ReplaceTypedef.cpp
r044ae62 rfa2c005 60 60 ast::StructDecl const * previsit( ast::StructDecl const * ); 61 61 ast::UnionDecl const * previsit( ast::UnionDecl const * ); 62 ast::AdtDecl const * previsit( ast::AdtDecl const * ); 62 63 void previsit( ast::EnumDecl const * ); 63 64 void previsit( ast::TraitDecl const * ); … … 90 91 } 91 92 93 // Here, 5/30 92 94 ast::Type const * ReplaceTypedefCore::postvisit( 93 95 ast::TypeInstType const * type ) { 94 96 // Instances of typedef types will come here. If it is an instance 95 97 // of a typedef type, link the instance to its actual type. 96 TypedefMap::const_iterator def = typedefNames.find( type->name ); 98 TypedefMap::const_iterator def = typedefNames.find( type->name ); // because of this 97 99 if ( def != typedefNames.end() ) { 98 100 ast::Type * ret = ast::deepCopy( def->second.first->base ); … … 260 262 } 261 263 264 ast::AdtDecl const * ReplaceTypedefCore::previsit( ast::AdtDecl const * decl ) { 265 visit_children = false; 266 addImplicitTypedef( decl ); 267 return handleAggregate( decl ); 268 } 269 262 270 ast::UnionDecl const * ReplaceTypedefCore::previsit( ast::UnionDecl const * decl ) { 263 271 visit_children = false; … … 287 295 } else if ( auto enumDecl = dynamic_cast<const ast::EnumDecl *>( aggrDecl ) ) { 288 296 type = new ast::EnumInstType( enumDecl->name ); 297 } else if ( auto adtDecl = dynamic_cast<const ast::AdtDecl *>( aggrDecl )) { 298 type = new ast::AdtInstType( adtDecl->name ); 289 299 } 290 300 assert( type );
Note:
See TracChangeset
for help on using the changeset viewer.