Changeset 94e0864d for src/SynTree


Ignore:
Timestamp:
Jun 24, 2015, 4:12:31 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
1869adf
Parents:
94b4364 (diff), de62360d (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 branch 'master' into resolver

Conflicts:

src/CodeGen/CodeGenerator.cc
src/Parser/ExpressionNode.cc
src/ResolvExpr/Resolver.cc

Location:
src/SynTree
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/CompoundStmt.cc

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  5 07:46:03 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jun 23 11:37:49 2015
     13// Update Count     : 3
    1414//
    1515
     
    3333}
    3434
    35 void CompoundStmt::print( std::ostream &os, int indent ) {
     35void CompoundStmt::print( std::ostream &os, int indent ) const {
    3636        os << string( indent, ' ' ) << "CompoundStmt" << endl ;
    3737        printAll( kids, os, indent + 2 );
  • src/SynTree/DeclStmt.cc

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 17:24:38 2015
    13 // Update Count     : 3
     12// Last Modified On : Tue Jun 23 11:38:15 2015
     13// Update Count     : 4
    1414//
    1515
     
    2828}
    2929
    30 void DeclStmt::print( std::ostream &os, int indent ) {
     30void DeclStmt::print( std::ostream &os, int indent ) const {
    3131        assert( decl != 0 );
    3232        os << "Declaration of ";
  • src/SynTree/Declaration.h

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 12 23:55:26 2015
    13 // Update Count     : 24
     12// Last Modified On : Sat Jun 13 09:10:31 2015
     13// Update Count     : 25
    1414//
    1515
     
    101101        typedef DeclarationWithType Parent;
    102102  public:
    103         FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline );
     103        FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn );
    104104        FunctionDecl( const FunctionDecl &other );
    105105        virtual ~FunctionDecl();
     
    113113        void set_statements( CompoundStmt *newValue ) { statements = newValue; }
    114114        bool get_isInline() const { return isInline; }
    115 //      void set_isInline( bool newValue ) { isInline = newValue; }
     115        bool get_isNoreturn() const { return isNoreturn; }
    116116        std::list< std::string >& get_oldIdents() { return oldIdents; }
    117117        std::list< Declaration* >& get_oldDecls() { return oldDecls; }
     
    125125        FunctionType *type;
    126126        CompoundStmt *statements;
    127         bool isInline;
     127        bool isInline, isNoreturn;
    128128        std::list< std::string > oldIdents;
    129129        std::list< Declaration* > oldDecls;
  • src/SynTree/FunctionDecl.cc

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun 13 08:12:20 2015
    13 // Update Count     : 14
     12// Last Modified On : Sat Jun 13 09:10:32 2015
     13// Update Count     : 16
    1414//
    1515
     
    2121#include "utility.h"
    2222
    23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline )
    24                 : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) {
     23FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
     24                : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ), isNoreturn( isNoreturn ) {
    2525        // this is a brazen hack to force the function "main" to have C linkage
    2626        if ( name == "main" ) {
     
    3030
    3131FunctionDecl::FunctionDecl( const FunctionDecl &other )
    32                 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
     32        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ), isNoreturn( other.isNoreturn ) {
    3333}
    3434
     
    6060                os << "inline ";
    6161        } // if
     62        if ( isNoreturn ) {
     63                os << "_Noreturn ";
     64        } // if
    6265        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
    6366                os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
     
    7073
    7174        if ( ! oldIdents.empty() ) {
    72                 os << string( indent+2, ' ' ) << "with parameter names" << endl;
     75                os << string( indent + 2, ' ' ) << "with parameter names" << endl;
    7376                for ( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
    74                         os << string( indent+4, ' ' ) << *i << endl;
     77                        os << string( indent + 4, ' ' ) << *i << endl;
    7578                } // for
    7679        } // if
    7780
    7881        if ( ! oldDecls.empty() ) {
    79                 os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
    80                 printAll( oldDecls, os, indent+4 );
     82                os << string( indent + 2, ' ' ) << "with parameter declarations" << endl;
     83                printAll( oldDecls, os, indent + 4 );
    8184        } // if
    8285        if ( statements ) {
    83                 os << string( indent+2, ' ' ) << "with body " << endl;
    84                 statements->print( os, indent+4 );
     86                os << string( indent + 2, ' ' ) << "with body " << endl;
     87                statements->print( os, indent + 4 );
    8588        } // if
    8689}
     
    9598        if ( isInline ) {
    9699                os << "inline ";
     100        } // if
     101        if ( isNoreturn ) {
     102                os << "_Noreturn ";
    97103        } // if
    98104        if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
  • src/SynTree/Statement.cc

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  5 07:51:04 2015
    13 // Update Count     : 15
     12// Last Modified On : Tue Jun 23 11:42:09 2015
     13// Update Count     : 21
    1414//
    1515
     
    3030Statement::Statement( std::list<Label> _labels ) : labels(_labels ) {}
    3131
    32 void Statement::print( std::ostream &, int indent ) {}
     32void Statement::print( std::ostream &, int indent ) const {}
    3333
    3434Statement::~Statement() {}
     
    3838ExprStmt::~ExprStmt() {}
    3939
    40 void ExprStmt::print( std::ostream &os, int indent ) {
     40void ExprStmt::print( std::ostream &os, int indent ) const {
    4141        os << string( indent, ' ' ) << "Expression Statement:" << endl;
    4242        expr->print( os, indent + 2 );
     
    5858}
    5959
    60 void BranchStmt::print( std::ostream &os, int indent ) {
     60void BranchStmt::print( std::ostream &os, int indent ) const {
    6161        os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ;
    6262}
     
    6868}
    6969
    70 void ReturnStmt::print( std::ostream &os, int indent ) {
     70void ReturnStmt::print( std::ostream &os, int indent ) const {
    7171        os << std::string( indent, ' ' ) << string ( isThrow? "Throw":"Return" ) << " Statement, returning: ";
    7272        if ( expr != 0 ) expr->print( os );
     
    7979IfStmt::~IfStmt() {}
    8080
    81 void IfStmt::print( std::ostream &os, int indent ) {
     81void IfStmt::print( std::ostream &os, int indent ) const {
    8282        os << string( indent, ' ' ) << "If on condition: " << endl ;
    8383        condition->print( os, indent + 4 );
     
    103103void SwitchStmt::add_case( CaseStmt *c ) {}
    104104
    105 void SwitchStmt::print( std::ostream &os, int indent ) {
     105void SwitchStmt::print( std::ostream &os, int indent ) const {
    106106        os << string( indent, ' ' ) << "Switch on condition: ";
    107107        condition->print( os );
     
    109109
    110110        // branches
    111         std::list<Statement *>::iterator i;
     111        std::list<Statement *>::const_iterator i;
    112112        for ( i = branches.begin(); i != branches.end(); i++)
    113                 (*i )->print( os, indent + 4 );
     113                (*i)->print( os, indent + 4 );
    114114
    115115        //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));
     
    130130}
    131131
    132 void CaseStmt::print( std::ostream &os, int indent ) {
     132void CaseStmt::print( std::ostream &os, int indent ) const {
    133133        os << string( indent, ' ' );
    134134
    135         if ( isDefault())
     135        if ( isDefault() )
    136136                os << "Default ";
    137137        else {
     
    142142        os << endl;
    143143
    144         std::list<Statement *>::iterator i;
     144        std::list<Statement *>::const_iterator i;
    145145        for ( i = stmts.begin(); i != stmts.end(); i++)
    146146                (*i )->print( os, indent + 4 );
     
    158158void ChooseStmt::add_case( CaseStmt *c ) {}
    159159
    160 void ChooseStmt::print( std::ostream &os, int indent ) {
     160void ChooseStmt::print( std::ostream &os, int indent ) const {
    161161        os << string( indent, ' ' ) << "Choose on condition: ";
    162162        condition->print( os );
     
    164164
    165165        // branches
    166         std::list<Statement *>::iterator i;
     166        std::list<Statement *>::const_iterator i;
    167167        for ( i = branches.begin(); i != branches.end(); i++)
    168168                (*i )->print( os, indent + 4 );
     
    171171}
    172172
    173 void FallthruStmt::print( std::ostream &os, int indent ) {
     173void FallthruStmt::print( std::ostream &os, int indent ) const {
    174174        os << string( indent, ' ' ) << "Fall-through statement" << endl;
    175175}
     
    183183}
    184184
    185 void WhileStmt::print( std::ostream &os, int indent ) {
     185void WhileStmt::print( std::ostream &os, int indent ) const {
    186186        os << string( indent, ' ' ) << "While on condition: " << endl ;
    187187        condition->print( os, indent + 4 );
     
    203203}
    204204
    205 void ForStmt::print( std::ostream &os, int indent ) {
     205void ForStmt::print( std::ostream &os, int indent ) const {
    206206        os << string( indent, ' ' ) << "Labels: {";
    207         for (std::list<Label>::iterator it = get_labels().begin(); it != get_labels().end(); ++it) {
     207        for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) {
    208208                os << *it << ",";
    209209        }
     
    245245}
    246246
    247 void TryStmt::print( std::ostream &os, int indent ) {
     247void TryStmt::print( std::ostream &os, int indent ) const {
    248248        os << string( indent, ' ' ) << "Try Statement" << endl;
    249249        os << string( indent + 2, ' ' ) << "with block: " << endl;
     
    252252        // handlers
    253253        os << string( indent + 2, ' ' ) << "and handlers: " << endl;
    254         std::list<Statement *>::iterator i;
    255         for ( i = handlers.begin(); i != handlers.end(); i++)
     254        for ( std::list<Statement *>::const_iterator i = handlers.begin(); i != handlers.end(); i++)
    256255                (*i )->print( os, indent + 4 );
    257256
     
    272271}
    273272
    274 void CatchStmt::print( std::ostream &os, int indent ) {
     273void CatchStmt::print( std::ostream &os, int indent ) const {
    275274        os << string( indent, ' ' ) << "Catch Statement" << endl;
    276275
     
    294293}
    295294
    296 void FinallyStmt::print( std::ostream &os, int indent ) {
     295void FinallyStmt::print( std::ostream &os, int indent ) const {
    297296        os << string( indent, ' ' ) << "Finally Statement" << endl;
    298297        os << string( indent + 2, ' ' ) << "with block: " << endl;
     
    304303NullStmt::~NullStmt() {}
    305304
    306 void NullStmt::print( std::ostream &os, int indent ) {
     305void NullStmt::print( std::ostream &os, int indent ) const {
    307306        os << string( indent, ' ' ) << "Null Statement" << endl ;
    308307}
  • src/SynTree/Statement.h

    r94b4364 r94e0864d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  4 14:03:31 2015
    13 // Update Count     : 14
     12// Last Modified On : Tue Jun 23 11:44:27 2015
     13// Update Count     : 20
    1414//
    1515
     
    2828
    2929        std::list<Label> & get_labels() { return labels; }
     30        const std::list<Label> & get_labels() const { return labels; }
    3031
    3132        virtual Statement *clone() const = 0;
    3233        virtual void accept( Visitor &v ) = 0;
    3334        virtual Statement *acceptMutator( Mutator &m ) = 0;
    34         virtual void print( std::ostream &os, int indent = 0 );
     35        virtual void print( std::ostream &os, int indent = 0 ) const;
    3536  protected:
    3637        std::list<Label> labels;
     
    4849        virtual void accept( Visitor &v ) { v.visit( this ); }
    4950        virtual CompoundStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    50         virtual void print( std::ostream &os, int indent = 0 );
     51        virtual void print( std::ostream &os, int indent = 0 ) const;
    5152  private:
    5253        std::list<Statement*> kids;
     
    6465        virtual void accept( Visitor &v ) { v.visit( this ); }
    6566        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    66         virtual void print( std::ostream &os, int indent = 0 );
     67        virtual void print( std::ostream &os, int indent = 0 ) const;
    6768  private:
    6869        Expression *expr;
     
    8485        virtual void accept( Visitor &v ) { v.visit( this ); }
    8586        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    86         virtual void print( std::ostream &os, int indent = 0 );
     87        virtual void print( std::ostream &os, int indent = 0 ) const;
    8788  private:
    8889        Expression *condition;
     
    106107
    107108        virtual SwitchStmt *clone() const { return new SwitchStmt( *this ); }
    108         virtual void print( std::ostream &os, int indent = 0 );
     109        virtual void print( std::ostream &os, int indent = 0 ) const;
    109110  private:
    110111        Expression * condition;
     
    127128
    128129        virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }
    129         virtual void print( std::ostream &os, int indent = 0 );
     130        virtual void print( std::ostream &os, int indent = 0 ) const;
    130131  private:
    131132        Expression *condition;
     
    141142
    142143        virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }
    143         virtual void print( std::ostream &os, int indent = 0 );
     144        virtual void print( std::ostream &os, int indent = 0 ) const;
    144145};
    145146
     
    153154                std::list<Statement *> stmts = std::list<Statement *>() );
    154155
    155         bool isDefault() { return _isDefault; }
     156        bool isDefault() const { return _isDefault; }
    156157        void set_default(bool b) { _isDefault = b; }
    157158
     
    166167
    167168        virtual CaseStmt *clone() const { return new CaseStmt( *this ); }
    168         virtual void print( std::ostream &os, int indent = 0 );
     169        virtual void print( std::ostream &os, int indent = 0 ) const;
    169170  private:
    170171        Expression * condition;
     
    189190        virtual void accept( Visitor &v ) { v.visit( this ); }
    190191        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    191         virtual void print( std::ostream &os, int indent = 0 );
     192        virtual void print( std::ostream &os, int indent = 0 ) const;
    192193  private:
    193194        Expression *condition;
     
    214215        virtual void accept( Visitor &v ) { v.visit( this ); }
    215216        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    216         virtual void print( std::ostream &os, int indent = 0 );
     217        virtual void print( std::ostream &os, int indent = 0 ) const;
    217218  private:
    218219        Statement *initialization;
     
    224225class BranchStmt : public Statement {
    225226  public:
    226         enum Type { Goto = 0 , Break, Continue };
     227        enum Type { Goto = 0, Break, Continue };
    227228
    228229        BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError);
     
    243244        virtual void accept( Visitor &v ) { v.visit( this ); }
    244245        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    245         virtual void print( std::ostream &os, int indent = 0 );
     246        virtual void print( std::ostream &os, int indent = 0 ) const;
    246247  private:
    247248        static const char *brType[];
     
    263264        virtual void accept( Visitor &v ) { v.visit( this ); }
    264265        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    265         virtual void print( std::ostream &os, int indent = 0 );
     266        virtual void print( std::ostream &os, int indent = 0 ) const;
    266267  private:
    267268        Expression *expr;
     
    279280        virtual void accept( Visitor &v ) { v.visit( this ); }
    280281        virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    281         virtual void print( std::ostream &os, int indent = 0 );
     282        virtual void print( std::ostream &os, int indent = 0 ) const;
    282283       
    283284  private:
     
    300301        virtual void accept( Visitor &v ) { v.visit( this ); }
    301302        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    302         virtual void print( std::ostream &os, int indent = 0 );
     303        virtual void print( std::ostream &os, int indent = 0 ) const;
    303304       
    304305  private:
     
    322323        virtual void accept( Visitor &v ) { v.visit( this ); }
    323324        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    324         virtual void print( std::ostream &os, int indent = 0 );
     325        virtual void print( std::ostream &os, int indent = 0 ) const;
    325326       
    326327  private:
     
    341342        virtual void accept( Visitor &v ) { v.visit( this ); }
    342343        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    343         virtual void print( std::ostream &os, int indent = 0 );
     344        virtual void print( std::ostream &os, int indent = 0 ) const;
    344345  private:
    345346        CompoundStmt *block;
     
    360361        virtual void accept( Visitor &v ) { v.visit( this ); }
    361362        virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    362         virtual void print( std::ostream &os, int indent = 0 );
     363        virtual void print( std::ostream &os, int indent = 0 ) const;
    363364  private:
    364365        Declaration *decl;
Note: See TracChangeset for help on using the changeset viewer.