Changeset 0522ebe for src/AST


Ignore:
Timestamp:
Feb 26, 2024, 3:49:23 AM (11 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
a4da45e
Parents:
c17dc80
Message:

Add EnumPosType? to type system

Location:
src/AST
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Fwd.hpp

    rc17dc80 r0522ebe  
    133133class OneType;
    134134class GlobalScopeType;
     135class EnumPosType;
    135136
    136137class Designation;
  • src/AST/Pass.hpp

    rc17dc80 r0522ebe  
    222222        const ast::Type *             visit( const ast::UnionInstType        * ) override final;
    223223        const ast::Type *             visit( const ast::EnumInstType         * ) override final;
     224        const ast::Type *             visit( const ast::EnumPosType          * ) override final;
    224225        const ast::Type *             visit( const ast::TraitInstType        * ) override final;
    225226        const ast::Type *             visit( const ast::TypeInstType         * ) override final;
  • src/AST/Pass.impl.hpp

    rc17dc80 r0522ebe  
    19861986
    19871987//--------------------------------------------------------------------------
     1988// EnumPosType
     1989template< typename core_t >
     1990const ast::Type * ast::Pass< core_t >::visit( const ast::EnumPosType * node ) {
     1991        VISIT_START( node );
     1992
     1993        VISIT_END( Type, node );
     1994}
     1995
     1996//--------------------------------------------------------------------------
    19881997// TraitInstType
    19891998template< typename core_t >
  • src/AST/Print.cpp

    rc17dc80 r0522ebe  
    15761576        }
    15771577
     1578        virtual const ast::Type * visit( const ast::EnumPosType * node ) override final {
     1579                preprint( node );
     1580                os << "enum pos with ";
     1581                (*(node->instance)).accept( *this );
     1582                return node;
     1583        }
     1584
    15781585        virtual const ast::Type * visit( const ast::TraitInstType * node ) override final {
    15791586                preprint( node );
  • src/AST/Type.hpp

    rc17dc80 r0522ebe  
    362362using EnumInstType = SueInstType<EnumDecl>;
    363363
     364class EnumPosType final : public Type {
     365public:
     366        readonly<EnumInstType> instance;
     367        const Type * accept( Visitor & v ) const override { return v.visit( this ); }
     368        EnumPosType( const EnumInstType * instance ): instance(instance) {}
     369       
     370private:
     371        EnumPosType * clone() const override { return new EnumPosType{ *this }; }
     372        MUTATE_FRIEND
     373};
     374
    364375/// An instance of a trait type.
    365376class TraitInstType final : public BaseInstType {
  • src/AST/Visitor.hpp

    rc17dc80 r0522ebe  
    119119    virtual const ast::Type *             visit( const ast::OneType              * ) = 0;
    120120    virtual const ast::Type *             visit( const ast::GlobalScopeType      * ) = 0;
     121    virtual const ast::Type *             visit( const ast::EnumPosType          * ) = 0;
    121122    virtual const ast::Designation *      visit( const ast::Designation          * ) = 0;
    122123    virtual const ast::Init *             visit( const ast::SingleInit           * ) = 0;
Note: See TracChangeset for help on using the changeset viewer.