Changeset 5408b59 for src/Validate


Ignore:
Timestamp:
Oct 18, 2022, 9:12:19 PM (19 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master
Children:
c2b3243
Parents:
1e30df7
Message:

Remove var in QualifiedNameExpr?

Location:
src/Validate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/FixQualifiedTypes.cpp

    r1e30df7 r5408b59  
    102102                        }
    103103
    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
     104                auto var = new ast::ObjectDecl( t->location, t->name,
     105                        new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall );
    108106                        var->mangleName = Mangle::mangle( var );
    109107                        return new ast::VariableExpr( t->location, var );
    110                 // return ret;
    111108        }
    112109
  • src/Validate/LinkReferenceToTypes.cpp

    r1e30df7 r5408b59  
    4444        void postvisit( ast::UnionDecl const * decl );
    4545        ast::TraitDecl const * postvisit( ast::TraitDecl const * decl );
    46         ast::QualifiedNameExpr const * previsit( ast::QualifiedNameExpr const * decl);
    4746
    4847private:
     
    316315}
    317316
    318 ast::QualifiedNameExpr const * LinkTypesCore::previsit( ast::QualifiedNameExpr const * decl ) {
    319         // Try to lookup type
    320         if ( auto objDecl = decl->type_decl.as<ast::ObjectDecl>() ) {
    321                 if ( auto inst = objDecl->type.as<ast::TypeInstType>()) {
    322                         if ( auto enumDecl = symtab.lookupEnum ( inst->name ) ) {
    323                                 auto mut = ast::mutate( decl );
    324                                 mut->type_decl = enumDecl;
    325                                 auto enumInst = new ast::EnumInstType( enumDecl );
    326                                 enumInst->name = decl->name;
    327                                 // Adding result; addCandidate() use result
    328                                 mut->result = enumInst;
    329                                 decl = mut;
    330                         }
    331                 }
    332         } else if ( auto enumDecl = decl->type_decl.as<ast::EnumDecl>() ) {
    333                 auto mut = ast::mutate( decl );
    334                 auto enumInst = new ast::EnumInstType( enumDecl );
    335                 enumInst->name = decl->name;
    336                 // Adding result; addCandidate() use result
    337                 mut->result = enumInst;
    338                 decl = mut;
    339         }
    340         // ast::EnumDecl const * decl = symtab.lookupEnum( type->name );
    341         // // It's not a semantic error if the enum is not found, just an implicit forward declaration.
    342         // if ( decl ) {
    343         //      // Just linking in the node.
    344         //      auto mut = ast::mutate( type );
    345         //      mut->base = const_cast<ast::EnumDecl *>( decl );
    346         //      type = mut;
    347         // }
    348         return decl;
    349 }
    350 
    351317} // namespace
    352318
Note: See TracChangeset for help on using the changeset viewer.