Changeset acb33f15 for src/AST


Ignore:
Timestamp:
May 13, 2024, 10:26:52 AM (17 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
31f4837
Parents:
41c8312
Message:

Change enum conversion steps

Location:
src/AST
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Fwd.hpp

    r41c8312 racb33f15  
    133133class OneType;
    134134class GlobalScopeType;
    135 class EnumAttrType;
    136135
    137136class Designation;
  • src/AST/Pass.hpp

    r41c8312 racb33f15  
    207207        const ast::Type *             visit( const ast::UnionInstType        * ) override final;
    208208        const ast::Type *             visit( const ast::EnumInstType         * ) override final;
    209         const ast::Type *             visit( const ast::EnumAttrType         * ) override final;
    210209        const ast::Type *             visit( const ast::TraitInstType        * ) override final;
    211210        const ast::Type *             visit( const ast::TypeInstType         * ) override final;
  • src/AST/Pass.impl.hpp

    r41c8312 racb33f15  
    19401940
    19411941//--------------------------------------------------------------------------
    1942 // EnumAttrType
    1943 template< typename core_t >
    1944 const ast::Type * ast::Pass< core_t >::visit( const ast::EnumAttrType * node ) {
    1945         VISIT_START( node );
    1946         VISIT_END( Type, node );
    1947 }
    1948 
    1949 //--------------------------------------------------------------------------
    19501942// TraitInstType
    19511943template< typename core_t >
  • src/AST/Print.cpp

    r41c8312 racb33f15  
    15761576        }
    15771577
    1578         virtual const ast::Type * visit( const ast::EnumAttrType * node ) override final {
    1579                 preprint( node );
    1580                 os << "enum attr ";
    1581                 if ( node->attr == ast::EnumAttribute::Label ) {
    1582                         os << "Label ";
    1583                 } else if ( node->attr == ast::EnumAttribute::Value ) {
    1584                         os << "Value ";
    1585                 } else {
    1586                         os << "Posn ";
    1587                 }
    1588                 (*(node->instance)).accept( *this );
    1589                 return node;
    1590         }
    1591 
    15921578        virtual const ast::Type * visit( const ast::TraitInstType * node ) override final {
    15931579                preprint( node );
  • src/AST/Type.hpp

    r41c8312 racb33f15  
    319319using EnumInstType = SueInstType<EnumDecl>;
    320320
    321 class EnumAttrType final : public Type {
    322 public:
    323         readonly<EnumInstType> instance;
    324         EnumAttribute attr;
    325         const Type * accept( Visitor & v ) const override { return v.visit( this ); }
    326         EnumAttrType( const EnumInstType * instance, EnumAttribute attr = EnumAttribute::Posn )
    327                 : instance(instance), attr(attr) {}
    328 
    329         bool match( const ast::EnumAttrType * other) const {
    330                 return instance->base->name == other->instance->base->name && attr == other->attr;
    331         }
    332 private:
    333         EnumAttrType * clone() const override { return new EnumAttrType{ *this }; }
    334         MUTATE_FRIEND
    335 };
    336 
    337321/// An instance of a trait type.
    338322class TraitInstType final : public BaseInstType {
  • src/AST/Visitor.hpp

    r41c8312 racb33f15  
    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::EnumAttrType         * ) = 0;
    122121    virtual const ast::Designation *      visit( const ast::Designation          * ) = 0;
    123122    virtual const ast::Init *             visit( const ast::SingleInit           * ) = 0;
Note: See TracChangeset for help on using the changeset viewer.