Changeset 19a8c40 for src


Ignore:
Timestamp:
Nov 14, 2022, 11:47:23 AM (18 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
63be3387, c1fb3903
Parents:
7491f97
Message:

Some clean-up I had stashed from before I knew the InlineMemberDecl? clean-up was underway.

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r7491f97 r19a8c40  
    18751875                auto&& type = GET_ACCEPT_1(type, Type);
    18761876                auto&& attr = GET_ACCEPT_V(attributes, Attribute);
    1877  
     1877
    18781878                auto decl = new ast::InlineMemberDecl(
    18791879                        old->location,
  • src/AST/Decl.hpp

    r7491f97 r19a8c40  
    397397};
    398398
     399/// Static Assertion `_Static_assert( ... , ... );`
    399400class StaticAssertDecl : public Decl {
    400401public:
     
    411412};
    412413
     414/// Inline Member Declaration `inline TypeName;`
    413415class InlineMemberDecl final : public DeclWithType {
    414416public:
     
    428430        MUTATE_FRIEND
    429431};
     432
    430433}
    431434
  • src/AST/Pass.hpp

    r7491f97 r19a8c40  
    141141        const ast::DirectiveDecl *    visit( const ast::DirectiveDecl        * ) override final;
    142142        const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl     * ) override final;
    143         const ast::DeclWithType *     visit( const ast::InlineMemberDecl      * ) override final;
     143        const ast::DeclWithType *     visit( const ast::InlineMemberDecl     * ) override final;
    144144        const ast::CompoundStmt *     visit( const ast::CompoundStmt         * ) override final;
    145145        const ast::Stmt *             visit( const ast::ExprStmt             * ) override final;
  • src/AST/Pass.impl.hpp

    r7491f97 r19a8c40  
    803803
    804804//--------------------------------------------------------------------------
    805 // DeclWithType
     805// InlineMemberDecl
    806806template< typename core_t >
    807807const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::InlineMemberDecl * node ) {
  • src/AST/Visitor.hpp

    r7491f97 r19a8c40  
    3333    virtual const ast::DirectiveDecl *    visit( const ast::DirectiveDecl        * ) = 0;
    3434    virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl     * ) = 0;
    35     virtual const ast::DeclWithType *     visit( const ast::InlineMemberDecl      * ) = 0;
     35    virtual const ast::DeclWithType *     visit( const ast::InlineMemberDecl     * ) = 0;
    3636    virtual const ast::CompoundStmt *     visit( const ast::CompoundStmt         * ) = 0;
    3737    virtual const ast::Stmt *             visit( const ast::ExprStmt             * ) = 0;
  • src/Validate/EnumAndPointerDecay.cpp

    r7491f97 r19a8c40  
    4141        auto mut = ast::mutate( decl );
    4242        std::vector<ast::ptr<ast::Decl>> buffer;
    43         for ( auto it = decl->members.begin(); it != decl->members.end(); ++it ) {
    44                 if ( ast::ObjectDecl const * object = (*it).as<ast::ObjectDecl>() ) {
    45                         buffer.push_back( ast::mutate_field( object, &ast::ObjectDecl::type, new ast::EnumInstType( decl, ast::CV::Const ) ) );
    46                 } else if ( ast::InlineMemberDecl const * value = (*it).as<ast::InlineMemberDecl>() ) {
     43        for ( auto member : decl->members ) {
     44                if ( ast::ObjectDecl const * object = member.as<ast::ObjectDecl>() ) {
     45                        buffer.push_back( ast::mutate_field( object,
     46                                &ast::ObjectDecl::type,
     47                                new ast::EnumInstType( decl, ast::CV::Const ) ) );
     48                } else if ( auto value = member.as<ast::InlineMemberDecl>() ) {
    4749                        if ( auto targetEnum = symtab.lookupEnum( value->name ) ) {
    48                                 for ( auto singleMember : targetEnum->members ) {
    49                                         auto copyingMember = singleMember.as<ast::ObjectDecl>();
     50                                for ( auto enumMember : targetEnum->members ) {
     51                                        auto enumObject = enumMember.strict_as<ast::ObjectDecl>();
    5052                                        buffer.push_back( new ast::ObjectDecl(
    51                                                 value->location, // use the "inline" location
    52                                                 copyingMember->name,
     53                                                // Get the location from the "inline" declaration.
     54                                                value->location,
     55                                                enumObject->name,
     56                                                // Construct a new EnumInstType as the type.
    5357                                                new ast::EnumInstType( decl, ast::CV::Const ),
    54                                                 // Construct a new EnumInstType as the type
    55                                                 copyingMember->init,
    56                                                 copyingMember->storage,
    57                                                 copyingMember->linkage,
    58                                                 copyingMember->bitfieldWidth,
     58                                                enumObject->init,
     59                                                enumObject->storage,
     60                                                enumObject->linkage,
     61                                                enumObject->bitfieldWidth,
    5962                                                {},
    60                                                 copyingMember->funcSpec
     63                                                enumObject->funcSpec
    6164                                        ) );
    6265                                }
Note: See TracChangeset for help on using the changeset viewer.