Changeset e149f77


Ignore:
Timestamp:
Sep 15, 2017, 10:50:13 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
695e00d
Parents:
310e5b7
Message:
  • moved print routine to base syntax node and implementated in code gen.
  • added virtual and override where needed in the syntree.
Location:
src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r310e5b7 re149f77  
    10021002} // namespace CodeGen
    10031003
     1004std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
     1005        if ( node ) {
     1006                node->print( out );
     1007        } else {
     1008                out << "nullptr";
     1009        }
     1010        return out;
     1011}
     1012
    10041013// Local Variables: //
    10051014// tab-width: 4 //
  • src/SynTree/BaseSyntaxNode.h

    r310e5b7 re149f77  
    2626
    2727        virtual void accept( Visitor & v ) = 0;
     28
     29        virtual void print( std::ostream &os, int indent = 0 ) const = 0;
    2830};
     31
     32std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node );
    2933
    3034// Local Variables: //
  • src/SynTree/Declaration.cc

    r310e5b7 re149f77  
    5959}
    6060
    61 std::ostream & operator<<( std::ostream & out, const Declaration * decl ) {
    62         if ( decl ){
    63                 decl->print( out );
    64         } else {
    65                 out << "nullptr";
    66         }
    67         return out;
    68 }
    69 
    7061
    7162AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
  • src/SynTree/Declaration.h

    r310e5b7 re149f77  
    6262        void fixUniqueId( void );
    6363        virtual Declaration *clone() const = 0;
    64         virtual void accept( Visitor &v ) = 0;
     64        virtual void accept( Visitor &v ) override = 0;
    6565        virtual Declaration *acceptMutator( Mutator &m ) = 0;
    66         virtual void print( std::ostream &os, int indent = 0 ) const = 0;
     66        virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
    6767        virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
    6868
     
    106106        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    107107
    108         virtual DeclarationWithType *clone() const = 0;
    109         virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     108        virtual DeclarationWithType *clone() const override = 0;
     109        virtual DeclarationWithType *acceptMutator( Mutator &m )  override = 0;
    110110
    111111        virtual Type * get_type() const = 0;
     
    128128        virtual ~ObjectDecl();
    129129
    130         virtual Type * get_type() const { return type; }
    131         virtual void set_type(Type *newType) { type = newType; }
     130        virtual Type * get_type() const override { return type; }
     131        virtual void set_type(Type *newType) override { type = newType; }
    132132
    133133        Initializer *get_init() const { return init; }
     
    139139        static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
    140140
    141         virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); }
    142         virtual void accept( Visitor &v ) { v.visit( this ); }
    143         virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    144         virtual void print( std::ostream &os, int indent = 0 ) const;
    145         virtual void printShort( std::ostream &os, int indent = 0 ) const;
     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, int indent = 0 ) const override;
     145        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    146146};
    147147
     
    157157        virtual ~FunctionDecl();
    158158
    159         Type * get_type() const { return type; }
    160         virtual void set_type(Type * t) { type = strict_dynamic_cast< FunctionType* >( t ); }
     159        virtual Type * get_type() const override { return type; }
     160        virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); }
    161161
    162162        FunctionType * get_functionType() const { return type; }
     
    165165        void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    166166
    167         virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); }
    168         virtual void accept( Visitor &v ) { v.visit( this ); }
    169         virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    170         virtual void print( std::ostream &os, int indent = 0 ) const;
    171         virtual void printShort( std::ostream &os, int indent = 0 ) const;
     167        virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
     168        virtual void accept( Visitor &v ) override { v.visit( this ); }
     169        virtual DeclarationWithType *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     170        virtual void print( std::ostream &os, int indent = 0 ) const override;
     171        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    172172};
    173173
     
    190190        virtual std::string typeString() const = 0;
    191191
    192         virtual NamedTypeDecl *clone() const = 0;
    193         virtual void print( std::ostream &os, int indent = 0 ) const;
    194         virtual void printShort( std::ostream &os, int indent = 0 ) const;
     192        virtual NamedTypeDecl *clone() const override = 0;
     193        virtual void print( std::ostream &os, int indent = 0 ) const override;
     194        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    195195};
    196196
     
    227227        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    228228
    229         virtual std::string typeString() const;
     229        virtual std::string typeString() const override;
    230230        virtual std::string genTypeString() const;
    231231
    232         virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
    233         virtual void accept( Visitor &v ) { v.visit( this ); }
    234         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    235         virtual void print( std::ostream &os, int indent = 0 ) const;
     232        virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
     233        virtual void accept( Visitor &v ) override { v.visit( this ); }
     234        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     235        virtual void print( std::ostream &os, int indent = 0 ) const override;
    236236
    237237  private:
     
    245245        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    246246
    247         virtual std::string typeString() const;
    248 
    249         virtual TypedefDecl *clone() const { return new TypedefDecl( *this ); }
    250         virtual void accept( Visitor &v ) { v.visit( this ); }
    251         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     247        virtual std::string typeString() const override;
     248
     249        virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
     250        virtual void accept( Visitor &v ) override { v.visit( this ); }
     251        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    252252  private:
    253253};
     
    274274        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    275275
    276         virtual void print( std::ostream &os, int indent = 0 ) const;
    277         virtual void printShort( std::ostream &os, int indent = 0 ) const;
     276        virtual void print( std::ostream &os, int indent = 0 ) const override;
     277        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
    278278  protected:
    279279        virtual std::string typeString() const = 0;
     
    290290        bool is_thread() { return kind == DeclarationNode::Thread; }
    291291
    292         virtual StructDecl *clone() const { return new StructDecl( *this ); }
    293         virtual void accept( Visitor &v ) { v.visit( this ); }
    294         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     292        virtual StructDecl *clone() const override { return new StructDecl( *this ); }
     293        virtual void accept( Visitor &v ) override { v.visit( this ); }
     294        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    295295  private:
    296296        DeclarationNode::Aggregate kind;
    297         virtual std::string typeString() const;
     297        virtual std::string typeString() const override;
    298298};
    299299
     
    304304        UnionDecl( const UnionDecl &other ) : Parent( other ) {}
    305305
    306         virtual UnionDecl *clone() const { return new UnionDecl( *this ); }
    307         virtual void accept( Visitor &v ) { v.visit( this ); }
    308         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    309   private:
    310         virtual std::string typeString() const;
     306        virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
     307        virtual void accept( Visitor &v ) override { v.visit( this ); }
     308        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     309  private:
     310        virtual std::string typeString() const override;
    311311};
    312312
     
    317317        EnumDecl( const EnumDecl &other ) : Parent( other ) {}
    318318
    319         virtual EnumDecl *clone() const { return new EnumDecl( *this ); }
    320         virtual void accept( Visitor &v ) { v.visit( this ); }
    321         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    322   private:
    323         virtual std::string typeString() const;
     319        virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
     320        virtual void accept( Visitor &v ) override { v.visit( this ); }
     321        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     322  private:
     323        virtual std::string typeString() const override;
    324324};
    325325
     
    332332        TraitDecl( const TraitDecl &other ) : Parent( other ) {}
    333333
    334         virtual TraitDecl *clone() const { return new TraitDecl( *this ); }
    335         virtual void accept( Visitor &v ) { v.visit( this ); }
    336         virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    337   private:
    338         virtual std::string typeString() const;
     334        virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
     335        virtual void accept( Visitor &v ) override { v.visit( this ); }
     336        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     337  private:
     338        virtual std::string typeString() const override;
    339339};
    340340
     
    350350        void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
    351351
    352         virtual AsmDecl *clone() const { return new AsmDecl( *this ); }
    353         virtual void accept( Visitor &v ) { v.visit( this ); }
    354         virtual AsmDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    355         virtual void print( std::ostream &os, int indent = 0 ) const;
    356         virtual void printShort( std::ostream &os, int indent = 0 ) const;
    357 };
    358 
    359 std::ostream & operator<<( std::ostream & out, const Declaration * decl );
     352        virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
     353        virtual void accept( Visitor &v ) override { v.visit( this ); }
     354        virtual AsmDecl *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     355        virtual void print( std::ostream &os, int indent = 0 ) const override;
     356        virtual void printShort( std::ostream &os, int indent = 0 ) const override;
     357};
     358
    360359std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    361360
  • src/SynTree/Expression.cc

    r310e5b7 re149f77  
    741741}
    742742
    743 
    744 std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    745         if ( expr ) {
    746                 expr->print( out );
    747         } else {
    748                 out << "nullptr";
    749         }
    750         return out;
    751 }
    752 
    753743// Local Variables: //
    754744// tab-width: 4 //
  • src/SynTree/Expression.h

    r310e5b7 re149f77  
    821821};
    822822
    823 
    824 std::ostream & operator<<( std::ostream & out, const Expression * expr );
    825 
    826823// Local Variables: //
    827824// tab-width: 4 //
  • src/SynTree/Initializer.cc

    r310e5b7 re149f77  
    137137}
    138138
    139 std::ostream & operator<<( std::ostream & out, const Initializer * init ) {
    140         if ( init ) {
    141                 init->print( out );
    142         } else {
    143                 out << "nullptr";
    144         }
    145         return out;
    146 }
    147 
    148 std::ostream & operator<<( std::ostream & out, const Designation * des ) {
    149         if ( des ) {
    150                 des->print( out );
    151         } else {
    152                 out << "nullptr";
    153         }
    154         return out;
    155 }
    156 
    157139// Local Variables: //
    158140// tab-width: 4 //
  • src/SynTree/Initializer.h

    r310e5b7 re149f77  
    3838
    3939        virtual Designation * clone() const { return new Designation( *this ); };
    40         virtual void accept( Visitor &v ) { v.visit( this ); }
     40        virtual void accept( Visitor &v ) override { v.visit( this ); }
    4141        virtual Designation * acceptMutator( Mutator &m ) { return m.mutate( this ); }
    42         virtual void print( std::ostream &os, int indent = 0 ) const;
     42        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4343};
    4444
     
    5555
    5656        virtual Initializer *clone() const = 0;
    57         virtual void accept( Visitor &v ) = 0;
     57        virtual void accept( Visitor &v ) override = 0;
    5858        virtual Initializer *acceptMutator( Mutator &m ) = 0;
    59         virtual void print( std::ostream &os, int indent = 0 ) const = 0;
     59        virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
    6060  private:
    6161        bool maybeConstructed;
     
    7575        void set_value( Expression *newValue ) { value = newValue; }
    7676
    77         virtual SingleInit *clone() const { return new SingleInit( *this); }
    78         virtual void accept( Visitor &v ) { v.visit( this ); }
    79         virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    80         virtual void print( std::ostream &os, int indent = 0 ) const;
     77        virtual SingleInit *clone() const override { return new SingleInit( *this); }
     78        virtual void accept( Visitor &v ) override { v.visit( this ); }
     79        virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     80        virtual void print( std::ostream &os, int indent = 0 ) const override;
    8181};
    8282
     
    103103        const_iterator end() const { return initializers.end(); }
    104104
    105         virtual ListInit *clone() const { return new ListInit( *this ); }
    106         virtual void accept( Visitor &v ) { v.visit( this ); }
    107         virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    108         virtual void print( std::ostream &os, int indent = 0 ) const;
     105        virtual ListInit *clone() const override { return new ListInit( *this ); }
     106        virtual void accept( Visitor &v ) override { v.visit( this ); }
     107        virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     108        virtual void print( std::ostream &os, int indent = 0 ) const override;
    109109};
    110110
     
    129129        Initializer * get_init() const { return init; }
    130130
    131         ConstructorInit *clone() const { return new ConstructorInit( *this ); }
    132         virtual void accept( Visitor &v ) { v.visit( this ); }
    133         virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    134         virtual void print( std::ostream &os, int indent = 0 ) const;
     131        ConstructorInit *clone() const override { return new ConstructorInit( *this ); }
     132        virtual void accept( Visitor &v ) override { v.visit( this ); }
     133        virtual Initializer *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     134        virtual void print( std::ostream &os, int indent = 0 ) const override;
    135135
    136136  private:
     
    140140};
    141141
    142 std::ostream & operator<<( std::ostream & out, const Initializer * init );
    143 std::ostream & operator<<( std::ostream & out, const Designation * des );
    144 
    145142// Local Variables: //
    146143// tab-width: 4 //
  • src/SynTree/Statement.cc

    r310e5b7 re149f77  
    497497}
    498498
    499 std::ostream & operator<<( std::ostream & out, const Statement * statement ) {
    500         if ( statement ) {
    501                 statement->print( out );
    502         } else {
    503                 out << "nullptr";
    504         }
    505         return out;
    506 }
    507 
    508499// Local Variables: //
    509500// tab-width: 4 //
  • src/SynTree/Statement.h

    r310e5b7 re149f77  
    4444
    4545        virtual Statement *clone() const = 0;
    46         virtual void accept( Visitor &v ) = 0;
     46        virtual void accept( Visitor &v ) override = 0;
    4747        virtual Statement *acceptMutator( Mutator &m ) = 0;
    48         virtual void print( std::ostream &os, int indent = 0 ) const;
     48        virtual void print( std::ostream &os, int indent = 0 ) const override;
    4949};
    5050
     
    6161        void push_front( Statement * stmt ) { kids.push_front( stmt ); }
    6262
    63         virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
    64         virtual void accept( Visitor &v ) { v.visit( this ); }
    65         virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    66         virtual void print( std::ostream &os, int indent = 0 ) const;
     63        virtual CompoundStmt *clone() const override { return new CompoundStmt( *this ); }
     64        virtual void accept( Visitor &v ) override { v.visit( this ); }
     65        virtual CompoundStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     66        virtual void print( std::ostream &os, int indent = 0 ) const override;
    6767};
    6868
     
    7272        NullStmt( std::list<Label> labels );
    7373
    74         virtual NullStmt *clone() const { return new NullStmt( *this ); }
    75         virtual void accept( Visitor &v ) { v.visit( this ); }
    76         virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    77         virtual void print( std::ostream &os, int indent = 0 ) const;
     74        virtual NullStmt *clone() const override { return new NullStmt( *this ); }
     75        virtual void accept( Visitor &v ) override { v.visit( this ); }
     76        virtual NullStmt *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     77        virtual void print( std::ostream &os, int indent = 0 ) const override;
    7878};
    7979
     
    8989        void set_expr( Expression *newValue ) { expr = newValue; }
    9090
    91         virtual ExprStmt *clone() const { return new ExprStmt( *this ); }
    92         virtual void accept( Visitor &v ) { v.visit( this ); }
    93         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    94         virtual void print( std::ostream &os, int indent = 0 ) const;
     91        virtual ExprStmt *clone() const override { return new ExprStmt( *this ); }
     92        virtual void accept( Visitor &v ) override { v.visit( this ); }
     93        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     94        virtual void print( std::ostream &os, int indent = 0 ) const override;
    9595};
    9696
     
    146146        void set_elsePart( Statement *newValue ) { elsePart = newValue; }
    147147
    148         virtual IfStmt *clone() const { return new IfStmt( *this ); }
    149         virtual void accept( Visitor &v ) { v.visit( this ); }
    150         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    151         virtual void print( std::ostream &os, int indent = 0 ) const;
     148        virtual IfStmt *clone() const override { return new IfStmt( *this ); }
     149        virtual void accept( Visitor &v ) override { v.visit( this ); }
     150        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     151        virtual void print( std::ostream &os, int indent = 0 ) const override;
    152152};
    153153
     
    166166        std::list<Statement *> & get_statements() { return statements; }
    167167
    168         virtual void accept( Visitor &v ) { v.visit( this ); }
    169         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    170 
    171         virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
    172         virtual void print( std::ostream &os, int indent = 0 ) const;
     168        virtual void accept( Visitor &v ) override { v.visit( this ); }
     169        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     170
     171        virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); }
     172        virtual void print( std::ostream &os, int indent = 0 ) const override;
    173173
    174174};
     
    194194        void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; }
    195195
    196         virtual void accept( Visitor &v ) { v.visit( this ); }
    197         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    198 
    199         virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
    200         virtual void print( std::ostream &os, int indent = 0 ) const;
     196        virtual void accept( Visitor &v ) override { v.visit( this ); }
     197        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     198
     199        virtual CaseStmt *clone() const override { return new CaseStmt( *this ); }
     200        virtual void print( std::ostream &os, int indent = 0 ) const override;
    201201  private:
    202202        bool _isDefault;
     
    221221        void set_isDoWhile( bool newValue ) { isDoWhile = newValue; }
    222222
    223         virtual WhileStmt *clone() const { return new WhileStmt( *this ); }
    224         virtual void accept( Visitor &v ) { v.visit( this ); }
    225         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    226         virtual void print( std::ostream &os, int indent = 0 ) const;
     223        virtual WhileStmt *clone() const override { return new WhileStmt( *this ); }
     224        virtual void accept( Visitor &v ) override { v.visit( this ); }
     225        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     226        virtual void print( std::ostream &os, int indent = 0 ) const override;
    227227};
    228228
     
    247247        void set_body( Statement *newValue ) { body = newValue; }
    248248
    249         virtual ForStmt *clone() const { return new ForStmt( *this ); }
    250         virtual void accept( Visitor &v ) { v.visit( this ); }
    251         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    252         virtual void print( std::ostream &os, int indent = 0 ) const;
     249        virtual ForStmt *clone() const override { return new ForStmt( *this ); }
     250        virtual void accept( Visitor &v ) override { v.visit( this ); }
     251        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     252        virtual void print( std::ostream &os, int indent = 0 ) const override;
    253253};
    254254
     
    276276        const char *get_typename() { return brType[ type ]; }
    277277
    278         virtual BranchStmt *clone() const { return new BranchStmt( *this ); }
    279         virtual void accept( Visitor &v ) { v.visit( this ); }
    280         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    281         virtual void print( std::ostream &os, int indent = 0 ) const;
     278        virtual BranchStmt *clone() const override { return new BranchStmt( *this ); }
     279        virtual void accept( Visitor &v ) override { v.visit( this ); }
     280        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     281        virtual void print( std::ostream &os, int indent = 0 ) const override;
    282282  private:
    283283        static const char *brType[];
     
    295295        void set_expr( Expression *newValue ) { expr = newValue; }
    296296
    297         virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); }
    298         virtual void accept( Visitor &v ) { v.visit( this ); }
    299         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    300         virtual void print( std::ostream &os, int indent = 0 ) const;
     297        virtual ReturnStmt *clone() const override { return new ReturnStmt( *this ); }
     298        virtual void accept( Visitor &v ) override { v.visit( this ); }
     299        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     300        virtual void print( std::ostream &os, int indent = 0 ) const override;
    301301};
    302302
     
    319319        void set_target( Expression * newTarget ) { target = newTarget; }
    320320
    321         virtual ThrowStmt *clone() const { return new ThrowStmt( *this ); }
    322         virtual void accept( Visitor &v ) { v.visit( this ); }
    323         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    324         virtual void print( std::ostream &os, int indent = 0 ) const;
     321        virtual ThrowStmt *clone() const override { return new ThrowStmt( *this ); }
     322        virtual void accept( Visitor &v ) override { v.visit( this ); }
     323        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     324        virtual void print( std::ostream &os, int indent = 0 ) const override;
    325325};
    326326
     
    342342        void set_finally( FinallyStmt *newValue ) { finallyBlock = newValue; }
    343343
    344         virtual TryStmt *clone() const { return new TryStmt( *this ); }
    345         virtual void accept( Visitor &v ) { v.visit( this ); }
    346         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    347         virtual void print( std::ostream &os, int indent = 0 ) const;
     344        virtual TryStmt *clone() const override { return new TryStmt( *this ); }
     345        virtual void accept( Visitor &v ) override { v.visit( this ); }
     346        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     347        virtual void print( std::ostream &os, int indent = 0 ) const override;
    348348};
    349349
     
    370370        void set_body( Statement *newValue ) { body = newValue; }
    371371
    372         virtual CatchStmt *clone() const { return new CatchStmt( *this ); }
    373         virtual void accept( Visitor &v ) { v.visit( this ); }
    374         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    375         virtual void print( std::ostream &os, int indent = 0 ) const;
     372        virtual CatchStmt *clone() const override { return new CatchStmt( *this ); }
     373        virtual void accept( Visitor &v ) override { v.visit( this ); }
     374        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     375        virtual void print( std::ostream &os, int indent = 0 ) const override;
    376376};
    377377
     
    387387        void set_block( CompoundStmt *newValue ) { block = newValue; }
    388388
    389         virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); }
    390         virtual void accept( Visitor &v ) { v.visit( this ); }
    391         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    392         virtual void print( std::ostream &os, int indent = 0 ) const;
     389        virtual FinallyStmt *clone() const override { return new FinallyStmt( *this ); }
     390        virtual void accept( Visitor &v ) override { v.visit( this ); }
     391        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     392        virtual void print( std::ostream &os, int indent = 0 ) const override;
    393393};
    394394
     
    424424        } orelse;
    425425
    426         virtual WaitForStmt *clone() const { return new WaitForStmt( *this ); }
    427         virtual void accept( Visitor &v ) { v.visit( this ); }
    428         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    429         virtual void print( std::ostream &os, int indent = 0 ) const;
     426        virtual WaitForStmt *clone() const override { return new WaitForStmt( *this ); }
     427        virtual void accept( Visitor &v ) override { v.visit( this ); }
     428        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     429        virtual void print( std::ostream &os, int indent = 0 ) const override;
    430430
    431431};
     
    444444        void set_decl( Declaration *newValue ) { decl = newValue; }
    445445
    446         virtual DeclStmt *clone() const { return new DeclStmt( *this ); }
    447         virtual void accept( Visitor &v ) { v.visit( this ); }
    448         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    449         virtual void print( std::ostream &os, int indent = 0 ) const;
     446        virtual DeclStmt *clone() const override { return new DeclStmt( *this ); }
     447        virtual void accept( Visitor &v ) override { v.visit( this ); }
     448        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     449        virtual void print( std::ostream &os, int indent = 0 ) const override;
    450450};
    451451
     
    466466        void set_callStmt( Statement * newValue ) { callStmt = newValue; }
    467467
    468         virtual ImplicitCtorDtorStmt *clone() const { return new ImplicitCtorDtorStmt( *this ); }
    469         virtual void accept( Visitor &v ) { v.visit( this ); }
    470         virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    471         virtual void print( std::ostream &os, int indent = 0 ) const;
    472 };
    473 
    474 
    475 std::ostream & operator<<( std::ostream & out, const Statement * statement );
     468        virtual ImplicitCtorDtorStmt *clone() const override { return new ImplicitCtorDtorStmt( *this ); }
     469        virtual void accept( Visitor &v ) override { v.visit( this ); }
     470        virtual Statement *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
     471        virtual void print( std::ostream &os, int indent = 0 ) const override;
     472};
    476473
    477474// Local Variables: //
  • src/SynTree/Type.cc

    r310e5b7 re149f77  
    9999const Type::Qualifiers noQualifiers;
    100100
    101 std::ostream & operator<<( std::ostream & out, const Type * type ) {
    102         if ( type ) {
    103                 type->print( out );
    104         } else {
    105                 out << "nullptr";
    106         } // if
    107         return out;
    108 }
    109 
    110101// Local Variables: //
    111102// tab-width: 4 //
  • src/SynTree/Type.h

    r310e5b7 re149f77  
    192192        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    193193
    194         virtual unsigned size() const { return 0; };
    195         virtual bool isComplete() const { return false; }
    196 
    197         virtual VoidType *clone() const { return new VoidType( *this ); }
    198         virtual void accept( Visitor & v ) { v.visit( this ); }
    199         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    200         virtual void print( std::ostream & os, int indent = 0 ) const;
     194        virtual unsigned size() const override { return 0; };
     195        virtual bool isComplete() const override { return false; }
     196
     197        virtual VoidType *clone() const override { return new VoidType( *this ); }
     198        virtual void accept( Visitor & v ) override { v.visit( this ); }
     199        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     200        virtual void print( std::ostream & os, int indent = 0 ) const override;
    201201};
    202202
     
    235235        void set_kind( Kind newValue ) { kind = newValue; }
    236236
    237         virtual BasicType *clone() const { return new BasicType( *this ); }
    238         virtual void accept( Visitor & v ) { v.visit( this ); }
    239         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    240         virtual void print( std::ostream & os, int indent = 0 ) const;
     237        virtual BasicType *clone() const override { return new BasicType( *this ); }
     238        virtual void accept( Visitor & v ) override { v.visit( this ); }
     239        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     240        virtual void print( std::ostream & os, int indent = 0 ) const override;
    241241
    242242        bool isInteger() const;
     
    268268        bool is_array() const { return isStatic || isVarLen || dimension; }
    269269
    270         virtual bool isComplete() const { return ! isVarLen; }
    271 
    272         virtual PointerType *clone() const { return new PointerType( *this ); }
    273         virtual void accept( Visitor & v ) { v.visit( this ); }
    274         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    275         virtual void print( std::ostream & os, int indent = 0 ) const;
     270        virtual bool isComplete() const override { return ! isVarLen; }
     271
     272        virtual PointerType *clone() const override { return new PointerType( *this ); }
     273        virtual void accept( Visitor & v ) override { v.visit( this ); }
     274        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     275        virtual void print( std::ostream & os, int indent = 0 ) const override;
    276276};
    277277
     
    296296        void set_isStatic( bool newValue ) { isStatic = newValue; }
    297297
    298         virtual bool isComplete() const { return ! isVarLen; }
    299 
    300         virtual ArrayType *clone() const { return new ArrayType( *this ); }
    301         virtual void accept( Visitor & v ) { v.visit( this ); }
    302         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    303         virtual void print( std::ostream & os, int indent = 0 ) const;
     298        virtual bool isComplete() const override { return ! isVarLen; }
     299
     300        virtual ArrayType *clone() const override { return new ArrayType( *this ); }
     301        virtual void accept( Visitor & v ) override { v.visit( this ); }
     302        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     303        virtual void print( std::ostream & os, int indent = 0 ) const override;
    304304};
    305305
     
    315315        void set_base( Type *newValue ) { base = newValue; }
    316316
    317         virtual int referenceDepth() const;
     317        virtual int referenceDepth() const override;
    318318
    319319        // Since reference types act like value types, their size is the size of the base.
    320320        // This makes it simple to cast the empty tuple to a reference type, since casts that increase
    321321        // the number of values are disallowed.
    322         virtual unsigned size() const { return base->size(); }
    323 
    324         virtual ReferenceType *clone() const { return new ReferenceType( *this ); }
    325         virtual void accept( Visitor & v ) { v.visit( this ); }
    326         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    327         virtual void print( std::ostream & os, int indent = 0 ) const;
     322        virtual unsigned size() const override { return base->size(); }
     323
     324        virtual ReferenceType *clone() const override { return new ReferenceType( *this ); }
     325        virtual void accept( Visitor & v ) override { v.visit( this ); }
     326        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     327        virtual void print( std::ostream & os, int indent = 0 ) const override;
    328328};
    329329
     
    349349        bool isTtype() const;
    350350
    351         virtual FunctionType *clone() const { return new FunctionType( *this ); }
    352         virtual void accept( Visitor & v ) { v.visit( this ); }
    353         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    354         virtual void print( std::ostream & os, int indent = 0 ) const;
     351        virtual FunctionType *clone() const override { return new FunctionType( *this ); }
     352        virtual void accept( Visitor & v ) override { v.visit( this ); }
     353        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     354        virtual void print( std::ostream & os, int indent = 0 ) const override;
    355355};
    356356
     
    371371        void set_hoistType( bool newValue ) { hoistType = newValue; }
    372372
    373         virtual ReferenceToType *clone() const = 0;
    374         virtual void accept( Visitor & v ) = 0;
    375         virtual Type *acceptMutator( Mutator & m ) = 0;
    376         virtual void print( std::ostream & os, int indent = 0 ) const;
     373        virtual ReferenceToType *clone() const override = 0;
     374        virtual void accept( Visitor & v ) override = 0;
     375        virtual Type *acceptMutator( Mutator & m ) override = 0;
     376        virtual void print( std::ostream & os, int indent = 0 ) const override;
    377377
    378378        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
     
    398398        std::list<TypeDecl*> * get_baseParameters();
    399399
    400         virtual bool isComplete() const;
     400        virtual bool isComplete() const override;
    401401
    402402        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    403403        /// Clones declarations into "foundDecls", caller responsible for freeing
    404         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    405 
    406         virtual StructInstType *clone() const { return new StructInstType( *this ); }
    407         virtual void accept( Visitor & v ) { v.visit( this ); }
    408         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    409 
    410         virtual void print( std::ostream & os, int indent = 0 ) const;
     404        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override;
     405
     406        virtual StructInstType *clone() const override { return new StructInstType( *this ); }
     407        virtual void accept( Visitor & v ) override { v.visit( this ); }
     408        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     409
     410        virtual void print( std::ostream & os, int indent = 0 ) const override;
    411411  private:
    412         virtual std::string typeString() const;
     412        virtual std::string typeString() const override;
    413413};
    414414
     
    430430        std::list< TypeDecl * > * get_baseParameters();
    431431
    432         virtual bool isComplete() const;
     432        virtual bool isComplete() const override;
    433433
    434434        /// looks up the members of this union named "name" and places them into "foundDecls"
    435435        /// Clones declarations into "foundDecls", caller responsible for freeing
    436         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    437 
    438         virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
    439         virtual void accept( Visitor & v ) { v.visit( this ); }
    440         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    441 
    442         virtual void print( std::ostream & os, int indent = 0 ) const;
     436        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override;
     437
     438        virtual UnionInstType *clone() const override { return new UnionInstType( *this ); }
     439        virtual void accept( Visitor & v ) override { v.visit( this ); }
     440        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     441
     442        virtual void print( std::ostream & os, int indent = 0 ) const override;
    443443  private:
    444         virtual std::string typeString() const;
     444        virtual std::string typeString() const override;
    445445};
    446446
     
    459459        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
    460460
    461         virtual bool isComplete() const;
    462 
    463         virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
    464         virtual void accept( Visitor & v ) { v.visit( this ); }
    465         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     461        virtual bool isComplete() const override;
     462
     463        virtual EnumInstType *clone() const override { return new EnumInstType( *this ); }
     464        virtual void accept( Visitor & v ) override { v.visit( this ); }
     465        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    466466  private:
    467         virtual std::string typeString() const;
     467        virtual std::string typeString() const override;
    468468};
    469469
     
    480480        ~TraitInstType();
    481481
    482         virtual bool isComplete() const;
    483 
    484         virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
    485         virtual void accept( Visitor & v ) { v.visit( this ); }
    486         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     482        virtual bool isComplete() const override;
     483
     484        virtual TraitInstType *clone() const override { return new TraitInstType( *this ); }
     485        virtual void accept( Visitor & v ) override { v.visit( this ); }
     486        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    487487  private:
    488         virtual std::string typeString() const;
     488        virtual std::string typeString() const override;
    489489};
    490490
     
    507507        void set_isFtype( bool newValue ) { isFtype = newValue; }
    508508
    509         virtual bool isComplete() const;
    510 
    511         virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
    512         virtual void accept( Visitor & v ) { v.visit( this ); }
    513         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    514         virtual void print( std::ostream & os, int indent = 0 ) const;
     509        virtual bool isComplete() const override;
     510
     511        virtual TypeInstType *clone() const override { return new TypeInstType( *this ); }
     512        virtual void accept( Visitor & v ) override { v.visit( this ); }
     513        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     514        virtual void print( std::ostream & os, int indent = 0 ) const override;
    515515  private:
    516         virtual std::string typeString() const;
     516        virtual std::string typeString() const override;
    517517};
    518518
     
    530530
    531531        std::list<Type *> & get_types() { return types; }
    532         virtual unsigned size() const { return types.size(); };
     532        virtual unsigned size() const override { return types.size(); };
    533533
    534534        // For now, this is entirely synthetic -- tuple types always have unnamed members.
     
    539539        iterator end() { return types.end(); }
    540540
    541         virtual Type * getComponent( unsigned i ) {
     541        virtual Type * getComponent( unsigned i ) override {
    542542                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
    543543                return *(begin()+i);
    544544        }
    545545
    546         // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
    547 
    548         virtual TupleType *clone() const { return new TupleType( *this ); }
    549         virtual void accept( Visitor & v ) { v.visit( this ); }
    550         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    551         virtual void print( std::ostream & os, int indent = 0 ) const;
     546        // virtual bool isComplete() const override { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
     547
     548        virtual TupleType *clone() const override { return new TupleType( *this ); }
     549        virtual void accept( Visitor & v ) override { v.visit( this ); }
     550        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     551        virtual void print( std::ostream & os, int indent = 0 ) const override;
    552552};
    553553
     
    563563        void set_expr( Expression *newValue ) { expr = newValue; }
    564564
    565         virtual bool isComplete() const { assert( false ); return false; }
    566 
    567         virtual TypeofType *clone() const { return new TypeofType( *this ); }
    568         virtual void accept( Visitor & v ) { v.visit( this ); }
    569         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    570         virtual void print( std::ostream & os, int indent = 0 ) const;
     565        virtual bool isComplete() const override { assert( false ); return false; }
     566
     567        virtual TypeofType *clone() const override { return new TypeofType( *this ); }
     568        virtual void accept( Visitor & v ) override { v.visit( this ); }
     569        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     570        virtual void print( std::ostream & os, int indent = 0 ) const override;
    571571};
    572572
     
    592592        void set_isType( bool newValue ) { isType = newValue; }
    593593
    594         virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
    595 
    596         virtual AttrType *clone() const { return new AttrType( *this ); }
    597         virtual void accept( Visitor & v ) { v.visit( this ); }
    598         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    599         virtual void print( std::ostream & os, int indent = 0 ) const;
     594        virtual bool isComplete() const override { assert( false ); } // xxx - not sure what to do here
     595
     596        virtual AttrType *clone() const override { return new AttrType( *this ); }
     597        virtual void accept( Visitor & v ) override { v.visit( this ); }
     598        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     599        virtual void print( std::ostream & os, int indent = 0 ) const override;
    600600};
    601601
     
    606606        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    607607
    608         virtual bool isComplete() const{ return true; } // xxx - is this right?
    609 
    610         virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
    611         virtual void accept( Visitor & v ) { v.visit( this ); }
    612         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    613         virtual void print( std::ostream & os, int indent = 0 ) const;
     608        virtual bool isComplete() const override{ return true; } // xxx - is this right?
     609
     610        virtual VarArgsType *clone() const override { return new VarArgsType( *this ); }
     611        virtual void accept( Visitor & v ) override { v.visit( this ); }
     612        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     613        virtual void print( std::ostream & os, int indent = 0 ) const override;
    614614};
    615615
     
    620620        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    621621
    622         virtual ZeroType *clone() const { return new ZeroType( *this ); }
    623         virtual void accept( Visitor & v ) { v.visit( this ); }
    624         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    625         virtual void print( std::ostream & os, int indent = 0 ) const;
     622        virtual ZeroType *clone() const override { return new ZeroType( *this ); }
     623        virtual void accept( Visitor & v ) override { v.visit( this ); }
     624        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     625        virtual void print( std::ostream & os, int indent = 0 ) const override;
    626626};
    627627
     
    632632        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    633633
    634         virtual OneType *clone() const { return new OneType( *this ); }
    635         virtual void accept( Visitor & v ) { v.visit( this ); }
    636         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    637         virtual void print( std::ostream & os, int indent = 0 ) const;
    638 };
    639 
    640 std::ostream & operator<<( std::ostream & out, const Type * type );
     634        virtual OneType *clone() const override { return new OneType( *this ); }
     635        virtual void accept( Visitor & v ) override { v.visit( this ); }
     636        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     637        virtual void print( std::ostream & os, int indent = 0 ) const override;
     638};
    641639
    642640// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.