Changeset 29702ad for src/AST


Ignore:
Timestamp:
Nov 22, 2022, 10:18:04 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, stuck-waitfor-destruct
Children:
20cf96d
Parents:
1553a55 (diff), d41735a (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/AST
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1553a55 r29702ad  
    236236        }
    237237
    238         // InlineValueDecl vanish after EnumAndPointerDecay pass so no necessary to implement NewToOld
    239         const ast::DeclWithType * visit( const ast::InlineValueDecl * node ) override final {   
     238        // InlineMemberDecl vanish after EnumAndPointerDecay pass so no necessary to implement NewToOld
     239        const ast::DeclWithType * visit( const ast::InlineMemberDecl * node ) override final { 
    240240                assert( false );
    241241                (void) node;
     
    17641764                        { old->linkage.val },
    17651765                        GET_ACCEPT_1(base, Type),
     1766                        old->hide == EnumDecl::EnumHiding::Hide ? ast::EnumDecl::EnumHiding::Hide : ast::EnumDecl::EnumHiding::Visible,
    17661767                        old->enumValues
    17671768                );
     
    18691870        }
    18701871
    1871         virtual void visit( const InlineValueDecl * old ) override final {
     1872        virtual void visit( const InlineMemberDecl * old ) override final {
    18721873                if ( inCache( old ) ) {
    18731874                        return;
     
    18751876                auto&& type = GET_ACCEPT_1(type, Type);
    18761877                auto&& attr = GET_ACCEPT_V(attributes, Attribute);
    1877  
    1878                 auto decl = new ast::InlineValueDecl(
     1878
     1879                auto decl = new ast::InlineMemberDecl(
    18791880                        old->location,
    18801881                        old->name,
  • src/AST/Decl.hpp

    r1553a55 r29702ad  
    315315        // enum (type_optional) Name {...}
    316316        ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum
    317 
    318         EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false,
     317        enum class EnumHiding { Visible, Hide } hide;
     318
     319        EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false,
    319320                std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall,
    320                 Type const * base = nullptr,
     321                Type const * base = nullptr, EnumHiding hide = EnumHiding::Hide,
    321322                std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() )
    322         : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), enumValues(enumValues) {}
     323        : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), hide(hide), enumValues(enumValues) {}
    323324
    324325        /// gets the integer value for this enumerator, returning true iff value found
     
    397398};
    398399
     400/// Static Assertion `_Static_assert( ... , ... );`
    399401class StaticAssertDecl : public Decl {
    400402public:
     
    411413};
    412414
    413 class InlineValueDecl final : public DeclWithType {
     415/// Inline Member Declaration `inline TypeName;`
     416class InlineMemberDecl final : public DeclWithType {
    414417public:
    415418        ptr<Type> type;
    416419
    417         InlineValueDecl( const CodeLocation & loc, const std::string & name, const Type * type,
     420        InlineMemberDecl( const CodeLocation & loc, const std::string & name, const Type * type,
    418421                Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall,
    419422                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} )
     
    425428        const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); }
    426429private:
    427         InlineValueDecl * clone() const override { return new InlineValueDecl{ *this }; }
    428         MUTATE_FRIEND
    429 };
     430        InlineMemberDecl * clone() const override { return new InlineMemberDecl{ *this }; }
     431        MUTATE_FRIEND
     432};
     433
    430434}
    431435
  • src/AST/Fwd.hpp

    r1553a55 r29702ad  
    3737class DirectiveDecl;
    3838class StaticAssertDecl;
    39 class InlineValueDecl;
     39class InlineMemberDecl;
    4040
    4141class Stmt;
  • src/AST/Pass.hpp

    r1553a55 r29702ad  
    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::InlineValueDecl      * ) 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

    r1553a55 r29702ad  
    686686
    687687        if ( __visit_children() ) {
    688                 // unlike structs, traits, and unions, enums inject their members into the global scope
    689                 maybe_accept( node, &EnumDecl::base );
    690                 maybe_accept( node, &EnumDecl::params     );
    691                 maybe_accept( node, &EnumDecl::members    );
    692                 maybe_accept( node, &EnumDecl::attributes );
     688                if ( node->hide == ast::EnumDecl::EnumHiding::Hide ) {
     689                        guard_symtab guard { *this };
     690                        maybe_accept( node, &EnumDecl::base );
     691                        maybe_accept( node, &EnumDecl::params     );
     692                        maybe_accept( node, &EnumDecl::members    );
     693                        maybe_accept( node, &EnumDecl::attributes );
     694                } else {
     695                        maybe_accept( node, &EnumDecl::base );
     696                        maybe_accept( node, &EnumDecl::params     );
     697                        maybe_accept( node, &EnumDecl::members    );
     698                        maybe_accept( node, &EnumDecl::attributes );
     699                }
    693700        }
    694701
     
    803810
    804811//--------------------------------------------------------------------------
    805 // DeclWithType
    806 template< typename core_t >
    807 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::InlineValueDecl * node ) {
    808         VISIT_START( node );
    809 
    810         if ( __visit_children() ) {
    811                 {
    812                         guard_symtab guard { *this };
    813                         maybe_accept( node, &InlineValueDecl::type );
     812// InlineMemberDecl
     813template< typename core_t >
     814const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::InlineMemberDecl * node ) {
     815        VISIT_START( node );
     816
     817        if ( __visit_children() ) {
     818                {
     819                        guard_symtab guard { *this };
     820                        maybe_accept( node, &InlineMemberDecl::type );
    814821                }
    815822        }
  • src/AST/Print.cpp

    r1553a55 r29702ad  
    401401        }
    402402
    403         virtual const ast::DeclWithType * visit( const ast::InlineValueDecl * node ) override final {
     403        virtual const ast::DeclWithType * visit( const ast::InlineMemberDecl * node ) override final {
    404404                os << "inline ";
    405405                if ( ! node->name.empty() ) os << node->name;
  • src/AST/Visitor.hpp

    r1553a55 r29702ad  
    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::InlineValueDecl      * ) = 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;
Note: See TracChangeset for help on using the changeset viewer.