Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    rf0ecf9b re3e16bc  
    6161
    6262        void fixUniqueId( void );
    63         virtual Declaration *clone() const override = 0;
    64         virtual void accept( Visitor &v ) override = 0;
    65         virtual Declaration *acceptMutator( Mutator &m ) override = 0;
    66         virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0;
    67         virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0;
     63        virtual Declaration *clone() const = 0;
     64        virtual void accept( Visitor &v ) = 0;
     65        virtual Declaration *acceptMutator( Mutator &m ) = 0;
     66        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
     67        virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
    6868
    6969        static void dumpIds( std::ostream &os );
     
    106106        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    107107
    108         virtual DeclarationWithType *clone() const override = 0;
    109         virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
     108        virtual DeclarationWithType *clone() const = 0;
     109        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    110110
    111111        virtual Type * get_type() const = 0;
     
    128128        virtual ~ObjectDecl();
    129129
    130         virtual Type * get_type() const override { return type; }
    131         virtual void set_type(Type *newType) override { type = newType; }
     130        virtual Type * get_type() const { return type; }
     131        virtual void set_type(Type *newType) { type = newType; }
    132132
    133133        Initializer *get_init() const { return init; }
     
    137137        void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
    138138
    139         static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
    140 
    141         virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); }
    142         virtual void accept( Visitor &v ) override { v.visit( this ); }
    143         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    144         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    145         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     139        virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }
     140        virtual void accept( Visitor &v ) { v.visit( this ); }
     141        virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     142        virtual void print( std::ostream &os, int indent = 0 ) const;
     143        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    146144};
    147145
     
    157155        virtual ~FunctionDecl();
    158156
    159         virtual Type * get_type() const override { return type; }
    160         virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); }
     157        Type * get_type() const { return type; }
     158        virtual void set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); }
    161159
    162160        FunctionType * get_functionType() const { return type; }
     
    165163        void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    166164
    167         static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements );
    168 
    169         virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
    170         virtual void accept( Visitor &v ) override { v.visit( this ); }
    171         virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    172         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    173         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     165        virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
     166        virtual void accept( Visitor &v ) { v.visit( this ); }
     167        virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     168        virtual void print( std::ostream &os, int indent = 0 ) const;
     169        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    174170};
    175171
     
    192188        virtual std::string typeString() const = 0;
    193189
    194         virtual NamedTypeDecl *clone() const override = 0;
    195         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    196         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     190        virtual NamedTypeDecl *clone() const = 0;
     191        virtual void print( std::ostream &os, int indent = 0 ) const;
     192        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    197193};
    198194
     
    200196        typedef NamedTypeDecl Parent;
    201197  public:
    202         enum Kind { Dtype, Ftype, Ttype };
     198        enum Kind { Any, Dtype, Ftype, Ttype };
    203199
    204200        Type * init;
     
    216212        };
    217213
    218         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
     214        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
    219215        TypeDecl( const TypeDecl &other );
    220216        virtual ~TypeDecl();
     
    225221        TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
    226222
    227         bool isComplete() const { return sized; }
     223        bool isComplete() const { return kind == Any || sized; }
    228224        bool get_sized() const { return sized; }
    229225        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    230226
    231         virtual std::string typeString() const override;
     227        virtual std::string typeString() const;
    232228        virtual std::string genTypeString() const;
    233229
    234         virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
    235         virtual void accept( Visitor &v ) override { v.visit( this ); }
    236         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    237         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
     230        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
     231        virtual void accept( Visitor &v ) { v.visit( this ); }
     232        virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     233        virtual void print( std::ostream &os, int indent = 0 ) const;
    238234
    239235  private:
     
    247243        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    248244
    249         virtual std::string typeString() const override;
    250 
    251         virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
    252         virtual void accept( Visitor &v ) override { v.visit( this ); }
    253         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     245        virtual std::string typeString() const;
     246
     247        virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
     248        virtual void accept( Visitor &v ) { v.visit( this ); }
     249        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    254250  private:
    255251};
     
    276272        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    277273
    278         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    279         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
     274        virtual void print( std::ostream &os, int indent = 0 ) const;
     275        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    280276  protected:
    281277        virtual std::string typeString() const = 0;
     
    292288        bool is_thread() { return kind == DeclarationNode::Thread; }
    293289
    294         virtual StructDecl *clone() const override { return new StructDecl( *this ); }
    295         virtual void accept( Visitor &v ) override { v.visit( this ); }
    296         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     290        virtual StructDecl *clone() const { return new StructDecl( *this ); }
     291        virtual void accept( Visitor &v ) { v.visit( this ); }
     292        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    297293  private:
    298294        DeclarationNode::Aggregate kind;
    299         virtual std::string typeString() const override;
     295        virtual std::string typeString() const;
    300296};
    301297
     
    306302        UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    307303
    308         virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
    309         virtual void accept( Visitor &v ) override { v.visit( this ); }
    310         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    311   private:
    312         virtual std::string typeString() const override;
     304        virtual UnionDecl *clone() const { return new UnionDecl( *this ); }
     305        virtual void accept( Visitor &v ) { v.visit( this ); }
     306        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     307  private:
     308        virtual std::string typeString() const;
    313309};
    314310
     
    319315        EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    320316
    321         virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
    322         virtual void accept( Visitor &v ) override { v.visit( this ); }
    323         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    324   private:
    325         virtual std::string typeString() const override;
     317        virtual EnumDecl *clone() const { return new EnumDecl( *this ); }
     318        virtual void accept( Visitor &v ) { v.visit( this ); }
     319        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     320  private:
     321        virtual std::string typeString() const;
    326322};
    327323
     
    334330        TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    335331
    336         virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
    337         virtual void accept( Visitor &v ) override { v.visit( this ); }
    338         virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    339   private:
    340         virtual std::string typeString() const override;
     332        virtual TraitDecl *clone() const { return new TraitDecl( *this ); }
     333        virtual void accept( Visitor &v ) { v.visit( this ); }
     334        virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     335  private:
     336        virtual std::string typeString() const;
    341337};
    342338
     
    352348        void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    353349
    354         virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
    355         virtual void accept( Visitor &v ) override { v.visit( this ); }
    356         virtual AsmDecl *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    357         virtual void print( std::ostream &os, Indenter indent = {} ) const override;
    358         virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
    359 };
    360 
     350        virtual AsmDecl *clone() const { return new AsmDecl( *this ); }
     351        virtual void accept( Visitor &v ) { v.visit( this ); }
     352        virtual AsmDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     353        virtual void print( std::ostream &os, int indent = 0 ) const;
     354        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     355};
     356
     357std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    361358std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    362359
Note: See TracChangeset for help on using the changeset viewer.