Changeset fa2c005 for src/SynTree


Ignore:
Timestamp:
Jun 8, 2023, 3:19:43 PM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT
Parents:
044ae62
Message:

Finish Adt POC

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    r044ae62 rfa2c005  
    365365        typedef AggregateDecl Parent;
    366366  public:
    367         std::list<StructDecl*> data_constructors;
    368367        UnionDecl * data_union;
    369368        EnumDecl * tag;
     
    373372         const std::list< Attribute * > & attributes = std::list< class Attribute * >(),
    374373         LinkageSpec::Spec linkage = LinkageSpec::Cforall,
    375          const std::list< StructDecl* > data_constructors = std::list< StructDecl * >(),
    376374         UnionDecl * data_union = nullptr, EnumDecl * tag = nullptr, StructDecl * tag_union = nullptr )
    377          : Parent( name, attributes, linkage ), data_constructors(data_constructors),
     375         : Parent( name, attributes, linkage ),
    378376         data_union( data_union ), tag( tag ), tag_union( tag_union ) {}
    379377
  • src/SynTree/Mutator.h

    r044ae62 rfa2c005  
    110110        virtual Type * mutate( FunctionType * functionType ) = 0;
    111111        virtual Type * mutate( StructInstType * aggregateUseType ) = 0;
     112        virtual Type * mutate( AdtInstType * aggregateUseType ) = 0;
    112113        virtual Type * mutate( UnionInstType * aggregateUseType ) = 0;
    113114        virtual Type * mutate( EnumInstType * aggregateUseType ) = 0;
  • src/SynTree/SynTree.h

    r044ae62 rfa2c005  
    119119class UnionInstType;
    120120class EnumInstType;
     121class AdtInstType;
    121122class TraitInstType;
    122123class TypeInstType;
  • src/SynTree/Type.h

    r044ae62 rfa2c005  
    476476};
    477477
     478class AdtInstType : public ReferenceToType {
     479        typedef ReferenceToType  Parent;
     480  public:
     481        AdtDecl * baseAdt;
     482
     483        AdtInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseAdt( 0 ) {}
     484        AdtInstType( const Type::Qualifiers & tq, AdtDecl * baseAdt, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     485        AdtInstType( const AdtInstType & other ) : Parent( other ), baseAdt( other.baseAdt ) {}
     486
     487        AdtDecl * get_baseAdt() const { return baseAdt; }
     488        void set_baseAdt( AdtDecl * newValue ) { baseAdt = newValue; }
     489       
     490        std::list<TypeDecl*> * get_baseParameters();
     491        const std::list<TypeDecl*> * get_baseParameters() const;
     492
     493        virtual bool isComplete() const override;
     494
     495        virtual AggregateDecl * getAggr() const override;
     496       
     497        virtual TypeSubstitution genericSubstitution() const override;
     498
     499        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override;
     500
     501        virtual AdtInstType * clone() const override { return new AdtInstType( * this ); }
     502        virtual void accept( Visitor & v ) override { v.visit( this ); }
     503        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     504        virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     505
     506        virtual void print( std::ostream & os, Indenter indenter = {} ) const override;
     507  private:
     508        virtual std::string typeString() const override;
     509};
     510
    478511class UnionInstType : public ReferenceToType {
    479512        typedef ReferenceToType Parent;
  • src/SynTree/Visitor.h

    r044ae62 rfa2c005  
    196196        virtual void visit( UnionInstType * node ) { visit( const_cast<const UnionInstType *>(node) ); }
    197197        virtual void visit( const UnionInstType * aggregateUseType ) = 0;
     198        virtual void visit( AdtInstType * node ) { visit( const_cast<const AdtInstType *>(node) ); }
     199        virtual void visit( const AdtInstType * node ) = 0;
    198200        virtual void visit( EnumInstType * node ) { visit( const_cast<const EnumInstType *>(node) ); }
    199201        virtual void visit( const EnumInstType * aggregateUseType ) = 0;
Note: See TracChangeset for help on using the changeset viewer.