Ignore:
Timestamp:
Sep 1, 2022, 1:27:52 PM (2 years 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/FixQualifiedTypes.cpp

    rdef751f rb0d9ff7  
    1919#include "AST/TranslationUnit.hpp"
    2020#include "Validate/NoIdSymbolTable.hpp"
     21#include "SymTab/Mangler.h"            // for Mangler
     22#include "AST/LinkageSpec.hpp"                     // for Linkage
    2123
    2224namespace Validate {
     
    8991                }
    9092        }
     93
     94        ast::Expr const * postvisit( ast::QualifiedNameExpr const * t) {
     95                assert( location );
     96                if ( t->type_decl ) {
     97                auto enumName = t->type_decl->name;
     98                const ast::EnumDecl * enumDecl = symtab.lookupEnum( enumName );
     99                        for ( ast::ptr<ast::Decl> const & member : enumDecl->members ) {
     100                                if ( auto memberAsObj = member.as<ast::ObjectDecl>() ) {
     101                                        if ( memberAsObj->name == t->name ) {
     102                                                return new ast::VariableExpr( t->location, memberAsObj );
     103                                        }
     104                                } else {
     105                                        assertf( false, "unhandled qualified child type");
     106                                }
     107                        }
     108
     109
     110                auto var = new ast::ObjectDecl( t->var->location, t->name,
     111                         new ast::EnumInstType(enumDecl, ast::CV::Const), nullptr, {}, ast::Linkage::Cforall );
     112                        var->scopeLevel = 1; // 1 for now; should copy the scopeLevel of the enumValue
     113                        var->mangleName = Mangle::mangle( var );
     114                        return new ast::VariableExpr( t->location, var );
     115                // return ret;
     116        }
     117
     118                return t;
     119        }
     120
    91121};
    92122
Note: See TracChangeset for help on using the changeset viewer.