Changeset f135b50 for src/SynTree


Ignore:
Timestamp:
Feb 28, 2022, 3:41:44 AM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
786c438
Parents:
a8ef59e
Message:

The compiler is now trying to pass the value of enum const to code gen; but it won't work cause we must be able to evaluate the const_expr in compiler time. It is not currently passed as a Expression but won't be able to evaluate at compile time

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    ra8ef59e rf135b50  
    119119  public:
    120120        Type * type;
    121         Initializer * init;
     121        Initializer * init; // For Enum, the init is a pointer that contain the enum value; see Parser::TypeData::buildEnum
    122122        Expression * bitfieldWidth;
    123123
     
    335335        typedef AggregateDecl Parent;
    336336  public:
    337         EnumDecl( const std::string & name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
     337        EnumDecl( const std::string & name,
     338         const std::list< Attribute * > & attributes = std::list< class Attribute * >(),
     339          LinkageSpec::Spec linkage = LinkageSpec::Cforall,
     340          Type * baseType = nullptr ) : Parent( name, attributes, linkage ) , base( baseType ){}
    338341        EnumDecl( const EnumDecl & other ) : Parent( other ) {}
    339342
     
    344347        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    345348        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    346   private:
     349        Type * base;
    347350        std::unordered_map< std::string, long long int > enumValues;
     351  private:
     352        // std::unordered_map< std::string, long long int > enumValues;
    348353        virtual const char * typeString() const override;
    349354};
  • src/SynTree/Visitor.h

    ra8ef59e rf135b50  
    3535        virtual void visit( UnionDecl * node ) { visit( const_cast<const UnionDecl *>(node) ); }
    3636        virtual void visit( const UnionDecl * aggregateDecl ) = 0;
    37         virtual void visit( EnumDecl * node ) { visit( const_cast<const EnumDecl *>(node) ); }
     37        virtual void visit( EnumDecl * node ) { visit( const_cast<const EnumDecl *>(node) ); } // Marker 1
    3838        virtual void visit( const EnumDecl * aggregateDecl ) = 0;
    3939        virtual void visit( TraitDecl * node ) { visit( const_cast<const TraitDecl *>(node) ); }
     
    190190        virtual void visit( UnionInstType * node ) { visit( const_cast<const UnionInstType *>(node) ); }
    191191        virtual void visit( const UnionInstType * aggregateUseType ) = 0;
    192         virtual void visit( EnumInstType * node ) { visit( const_cast<const EnumInstType *>(node) ); }
     192        virtual void visit( EnumInstType * node ) { visit( const_cast<const EnumInstType *>(node) ); } // Marker 2
    193193        virtual void visit( const EnumInstType * aggregateUseType ) = 0;
    194194        virtual void visit( TraitInstType * node ) { visit( const_cast<const TraitInstType *>(node) ); }
Note: See TracChangeset for help on using the changeset viewer.