Ignore:
Timestamp:
Sep 1, 2022, 1:27:52 PM (23 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
12df6fe
Parents:
def751f
Message:

Fix up the QualifiedNameExpr?. It should now work on both old AST and new AST. There are some known bugs to fix so make all-tests will fail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/LinkReferenceToTypes.cpp

    rdef751f rb0d9ff7  
    4646        void postvisit( ast::UnionDecl const * decl );
    4747        ast::TraitDecl const * postvisit( ast::TraitDecl const * decl );
     48        ast::QualifiedNameExpr const * previsit( ast::QualifiedNameExpr const * decl);
    4849
    4950private:
     
    292293}
    293294
     295ast::QualifiedNameExpr const * LinkTypesCore::previsit( ast::QualifiedNameExpr const * decl ) {
     296        // Try to lookup type
     297        if ( auto objDecl = decl->type_decl.as<ast::ObjectDecl>() ) {
     298                if ( auto inst = objDecl->type.as<ast::TypeInstType>()) {
     299                        if ( auto enumDecl = symtab.lookupEnum ( inst->name ) ) {
     300                                auto mut = ast::mutate( decl );
     301                                mut->type_decl = enumDecl;
     302                                auto enumInst = new ast::EnumInstType( enumDecl );
     303                                enumInst->name = decl->name;
     304                                // Adding result; addCandidate() use result
     305                                mut->result = enumInst;
     306                                decl = mut;
     307                        }
     308                }
     309        } else if ( auto enumDecl = decl->type_decl.as<ast::EnumDecl>() ) {
     310                auto mut = ast::mutate( decl );
     311                auto enumInst = new ast::EnumInstType( enumDecl );
     312                enumInst->name = decl->name;
     313                // Adding result; addCandidate() use result
     314                mut->result = enumInst;
     315                decl = mut;
     316        }
     317        // ast::EnumDecl const * decl = symtab.lookupEnum( type->name );
     318        // // It's not a semantic error if the enum is not found, just an implicit forward declaration.
     319        // if ( decl ) {
     320        //      // Just linking in the node.
     321        //      auto mut = ast::mutate( type );
     322        //      mut->base = const_cast<ast::EnumDecl *>( decl );
     323        //      type = mut;
     324        // }
     325        return decl;
     326}
     327
    294328} // namespace
    295329
Note: See TracChangeset for help on using the changeset viewer.