Ignore:
Timestamp:
Sep 21, 2022, 11:02:15 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' into pthread-emulation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/FixQualifiedTypes.cpp

    r428adbc r7f6a7c9  
    1010// Created On       : Thr Apr 21 11:13:00 2022
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Apr 22 11:36:00 2022
    13 // Update Count     : 0
     12// Last Modified On : Tue Sep 20 16:15:00 2022
     13// Update Count     : 1
    1414//
    1515
     
    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 {
     
    2527
    2628struct 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 {
    3431        ast::Type const * postvisit( ast::QualifiedType const * type ) {
    3532                assert( location );
     
    8986                }
    9087        }
     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
    91116};
    92117
Note: See TracChangeset for help on using the changeset viewer.