Changeset 7f6a7c9 for src/Validate/FixQualifiedTypes.cpp
- Timestamp:
- Sep 21, 2022, 11:02:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 95dab9e
- Parents:
- 428adbc (diff), 0bd46fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/FixQualifiedTypes.cpp
r428adbc r7f6a7c9 10 10 // Created On : Thr Apr 21 11:13:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Apr 22 11:36:00 202213 // Update Count : 012 // Last Modified On : Tue Sep 20 16:15:00 2022 13 // Update Count : 1 14 14 // 15 15 … … 19 19 #include "AST/TranslationUnit.hpp" 20 20 #include "Validate/NoIdSymbolTable.hpp" 21 #include "SymTab/Mangler.h" // for Mangler 22 #include "AST/LinkageSpec.hpp" // for Linkage 21 23 22 24 namespace Validate { … … 25 27 26 28 struct FixQualifiedTypesCore : 27 public WithNoIdSymbolTable, public ast::WithGuards { 28 CodeLocation const * location = nullptr; 29 30 void previsit( ast::ParseNode const * node ) { 31 GuardValue( location ) = &node->location; 32 } 33 29 public WithNoIdSymbolTable, 30 public ast::WithCodeLocation { 34 31 ast::Type const * postvisit( ast::QualifiedType const * type ) { 35 32 assert( location ); … … 89 86 } 90 87 } 88 89 ast::Expr const * postvisit( ast::QualifiedNameExpr const * t) { 90 assert( location ); 91 if ( t->type_decl ) { 92 auto enumName = t->type_decl->name; 93 const ast::EnumDecl * enumDecl = symtab.lookupEnum( enumName ); 94 for ( ast::ptr<ast::Decl> const & member : enumDecl->members ) { 95 if ( auto memberAsObj = member.as<ast::ObjectDecl>() ) { 96 if ( memberAsObj->name == t->name ) { 97 return new ast::VariableExpr( t->location, memberAsObj ); 98 } 99 } else { 100 assertf( false, "unhandled qualified child type"); 101 } 102 } 103 104 105 auto var = new ast::ObjectDecl( t->var->location, t->name, 106 new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall ); 107 var->scopeLevel = 1; // 1 for now; should copy the scopeLevel of the enumValue 108 var->mangleName = Mangle::mangle( var ); 109 return new ast::VariableExpr( t->location, var ); 110 // return ret; 111 } 112 113 return t; 114 } 115 91 116 }; 92 117
Note:
See TracChangeset
for help on using the changeset viewer.