Changeset 4520b77e for src/SynTree


Ignore:
Timestamp:
Sep 20, 2022, 8:37:05 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
a065f1f
Parents:
d489da8 (diff), 12df6fe (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 to Master Sept 19

Location:
src/SynTree
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    rd489da8 r4520b77e  
    145145        virtual void printShort( std::ostream & os, Indenter indent = {} ) const override;
    146146
    147         // TODO: Move to the right place
    148147        void checkAssignedValue() const;
    149148};
     
    338337        typedef AggregateDecl Parent;
    339338  public:
     339        bool isTyped;
     340        Type * base;
     341
    340342        EnumDecl( const std::string & name,
    341343         const std::list< Attribute * > & attributes = std::list< class Attribute * >(),
    342           LinkageSpec::Spec linkage = LinkageSpec::Cforall,
    343           Type * baseType = nullptr ) : Parent( name, attributes, linkage ) , base( baseType ){}
    344         EnumDecl( const EnumDecl & other ) : Parent( other ), base( other.base ) {}
    345 
     344          bool isTyped = false, LinkageSpec::Spec linkage = LinkageSpec::Cforall,
     345          Type * baseType = nullptr )
     346          : Parent( name, attributes, linkage ),isTyped(isTyped), base( baseType ) {}
     347        EnumDecl( const EnumDecl & other )
     348          : Parent( other ), isTyped( other.isTyped), base( other.base ) {}
    346349        bool valueOf( Declaration * enumerator, long long int & value );
    347 
    348350        virtual EnumDecl * clone() const override { return new EnumDecl( *this ); }
    349351        virtual void accept( Visitor & v ) override { v.visit( this ); }
    350352        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    351353        virtual Declaration * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
    352         Type * base;
    353         std::unordered_map< std::string, long long int > enumValues;
     354
     355        std::unordered_map< std::string, long long int > enumValues; // This attribute is unused
    354356        virtual void print( std::ostream & os, Indenter indent = {} ) const override final;
    355357  private:
  • src/SynTree/Expression.h

    rd489da8 r4520b77e  
    163163};
    164164
     165// [Qualifier].name; Qualifier is the type_name from the parser
     166class QualifiedNameExpr : public Expression {
     167  public:
     168        Declaration * type_decl;
     169        std::string name;
     170        DeclarationWithType * var;
     171
     172        QualifiedNameExpr( Declaration * decl, std::string name): Expression(), type_decl(decl), name(name) {}
     173        QualifiedNameExpr( const QualifiedNameExpr & other): Expression(other), type_decl(other.type_decl), name(other.name), var(other.var) {}
     174        DeclarationWithType * get_var() const { return var; }
     175        void set_var( DeclarationWithType * newValue ) { var = newValue; }
     176
     177        virtual ~QualifiedNameExpr() {
     178                delete var;
     179                delete type_decl;
     180        }
     181
     182        virtual QualifiedNameExpr * clone() const override {
     183                return new QualifiedNameExpr( * this );
     184        }
     185        virtual void accept( Visitor & v ) override { v.visit(this); }
     186        virtual void accept( Visitor & v ) const override { v.visit(this); }
     187        virtual Expression * acceptMutator( Mutator & m ) override {
     188                return m.mutate( this );
     189        }
     190       
     191        virtual void print( std::ostream & os, Indenter indent = {} ) const override {
     192                type_decl->print( os, indent );
     193                os << name << std::endl;
     194        }
     195};
     196
    165197/// VariableExpr represents an expression that simply refers to the value of a named variable.
    166198/// Does not take ownership of var.
  • src/SynTree/Mutator.h

    rd489da8 r4520b77e  
    9898        virtual Expression * mutate( DefaultArgExpr * argExpr ) = 0;
    9999        virtual Expression * mutate( GenericExpr * genExpr ) = 0;
     100        virtual Expression * mutate( QualifiedNameExpr * qualifiedNameExpr ) = 0;
    100101
    101102        virtual Type * mutate( VoidType * basicType ) = 0;
  • src/SynTree/SynTree.h

    rd489da8 r4520b77e  
    103103class DefaultArgExpr;
    104104class GenericExpr;
     105class QualifiedNameExpr;
    105106
    106107class Type;
  • src/SynTree/Type.h

    rd489da8 r4520b77e  
    345345        Type * parent;
    346346        Type * child;
    347 
    348347        QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child );
    349348        QualifiedType( const QualifiedType & tq );
  • src/SynTree/Visitor.h

    rd489da8 r4520b77e  
    101101        virtual void visit( NameExpr * node ) { visit( const_cast<const NameExpr *>(node) ); }
    102102        virtual void visit( const NameExpr * nameExpr ) = 0;
     103        virtual void visit( QualifiedNameExpr * node ) { visit( const_cast<const QualifiedNameExpr*>(node) );}
     104        virtual void visit( const QualifiedNameExpr* qualifiednameExpr ) = 0;
    103105        virtual void visit( CastExpr * node ) { visit( const_cast<const CastExpr *>(node) ); }
    104106        virtual void visit( const CastExpr * castExpr ) = 0;
Note: See TracChangeset for help on using the changeset viewer.