Changeset 94e0864d for src/SynTree
- Timestamp:
- Jun 24, 2015, 4:12:31 PM (9 years ago)
- 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. - Location:
- src/SynTree
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/CompoundStmt.cc
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 5 07:46:03201513 // Update Count : 212 // Last Modified On : Tue Jun 23 11:37:49 2015 13 // Update Count : 3 14 14 // 15 15 … … 33 33 } 34 34 35 void CompoundStmt::print( std::ostream &os, int indent ) {35 void CompoundStmt::print( std::ostream &os, int indent ) const { 36 36 os << string( indent, ' ' ) << "CompoundStmt" << endl ; 37 37 printAll( kids, os, indent + 2 ); -
src/SynTree/DeclStmt.cc
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 8 17:24:38201513 // Update Count : 312 // Last Modified On : Tue Jun 23 11:38:15 2015 13 // Update Count : 4 14 14 // 15 15 … … 28 28 } 29 29 30 void DeclStmt::print( std::ostream &os, int indent ) {30 void DeclStmt::print( std::ostream &os, int indent ) const { 31 31 assert( decl != 0 ); 32 32 os << "Declaration of "; -
src/SynTree/Declaration.h
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 12 23:55:26201513 // Update Count : 2 412 // Last Modified On : Sat Jun 13 09:10:31 2015 13 // Update Count : 25 14 14 // 15 15 … … 101 101 typedef DeclarationWithType Parent; 102 102 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 ); 104 104 FunctionDecl( const FunctionDecl &other ); 105 105 virtual ~FunctionDecl(); … … 113 113 void set_statements( CompoundStmt *newValue ) { statements = newValue; } 114 114 bool get_isInline() const { return isInline; } 115 // void set_isInline( bool newValue ) { isInline = newValue; }115 bool get_isNoreturn() const { return isNoreturn; } 116 116 std::list< std::string >& get_oldIdents() { return oldIdents; } 117 117 std::list< Declaration* >& get_oldDecls() { return oldDecls; } … … 125 125 FunctionType *type; 126 126 CompoundStmt *statements; 127 bool isInline ;127 bool isInline, isNoreturn; 128 128 std::list< std::string > oldIdents; 129 129 std::list< Declaration* > oldDecls; -
src/SynTree/FunctionDecl.cc
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 0 8:12:20201513 // Update Count : 1 412 // Last Modified On : Sat Jun 13 09:10:32 2015 13 // Update Count : 16 14 14 // 15 15 … … 21 21 #include "utility.h" 22 22 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 ) {23 FunctionDecl::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 ) { 25 25 // this is a brazen hack to force the function "main" to have C linkage 26 26 if ( name == "main" ) { … … 30 30 31 31 FunctionDecl::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 ) { 33 33 } 34 34 … … 60 60 os << "inline "; 61 61 } // if 62 if ( isNoreturn ) { 63 os << "_Noreturn "; 64 } // if 62 65 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 63 66 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; … … 70 73 71 74 if ( ! oldIdents.empty() ) { 72 os << string( indent +2, ' ' ) << "with parameter names" << endl;75 os << string( indent + 2, ' ' ) << "with parameter names" << endl; 73 76 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; 75 78 } // for 76 79 } // if 77 80 78 81 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 ); 81 84 } // if 82 85 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 ); 85 88 } // if 86 89 } … … 95 98 if ( isInline ) { 96 99 os << "inline "; 100 } // if 101 if ( isNoreturn ) { 102 os << "_Noreturn "; 97 103 } // if 98 104 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { -
src/SynTree/Statement.cc
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 5 07:51:04201513 // Update Count : 1512 // Last Modified On : Tue Jun 23 11:42:09 2015 13 // Update Count : 21 14 14 // 15 15 … … 30 30 Statement::Statement( std::list<Label> _labels ) : labels(_labels ) {} 31 31 32 void Statement::print( std::ostream &, int indent ) {}32 void Statement::print( std::ostream &, int indent ) const {} 33 33 34 34 Statement::~Statement() {} … … 38 38 ExprStmt::~ExprStmt() {} 39 39 40 void ExprStmt::print( std::ostream &os, int indent ) {40 void ExprStmt::print( std::ostream &os, int indent ) const { 41 41 os << string( indent, ' ' ) << "Expression Statement:" << endl; 42 42 expr->print( os, indent + 2 ); … … 58 58 } 59 59 60 void BranchStmt::print( std::ostream &os, int indent ) {60 void BranchStmt::print( std::ostream &os, int indent ) const { 61 61 os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ; 62 62 } … … 68 68 } 69 69 70 void ReturnStmt::print( std::ostream &os, int indent ) {70 void ReturnStmt::print( std::ostream &os, int indent ) const { 71 71 os << std::string( indent, ' ' ) << string ( isThrow? "Throw":"Return" ) << " Statement, returning: "; 72 72 if ( expr != 0 ) expr->print( os ); … … 79 79 IfStmt::~IfStmt() {} 80 80 81 void IfStmt::print( std::ostream &os, int indent ) {81 void IfStmt::print( std::ostream &os, int indent ) const { 82 82 os << string( indent, ' ' ) << "If on condition: " << endl ; 83 83 condition->print( os, indent + 4 ); … … 103 103 void SwitchStmt::add_case( CaseStmt *c ) {} 104 104 105 void SwitchStmt::print( std::ostream &os, int indent ) {105 void SwitchStmt::print( std::ostream &os, int indent ) const { 106 106 os << string( indent, ' ' ) << "Switch on condition: "; 107 107 condition->print( os ); … … 109 109 110 110 // branches 111 std::list<Statement *>:: iterator i;111 std::list<Statement *>::const_iterator i; 112 112 for ( i = branches.begin(); i != branches.end(); i++) 113 (*i 113 (*i)->print( os, indent + 4 ); 114 114 115 115 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os )); … … 130 130 } 131 131 132 void CaseStmt::print( std::ostream &os, int indent ) {132 void CaseStmt::print( std::ostream &os, int indent ) const { 133 133 os << string( indent, ' ' ); 134 134 135 if ( isDefault() )135 if ( isDefault() ) 136 136 os << "Default "; 137 137 else { … … 142 142 os << endl; 143 143 144 std::list<Statement *>:: iterator i;144 std::list<Statement *>::const_iterator i; 145 145 for ( i = stmts.begin(); i != stmts.end(); i++) 146 146 (*i )->print( os, indent + 4 ); … … 158 158 void ChooseStmt::add_case( CaseStmt *c ) {} 159 159 160 void ChooseStmt::print( std::ostream &os, int indent ) {160 void ChooseStmt::print( std::ostream &os, int indent ) const { 161 161 os << string( indent, ' ' ) << "Choose on condition: "; 162 162 condition->print( os ); … … 164 164 165 165 // branches 166 std::list<Statement *>:: iterator i;166 std::list<Statement *>::const_iterator i; 167 167 for ( i = branches.begin(); i != branches.end(); i++) 168 168 (*i )->print( os, indent + 4 ); … … 171 171 } 172 172 173 void FallthruStmt::print( std::ostream &os, int indent ) {173 void FallthruStmt::print( std::ostream &os, int indent ) const { 174 174 os << string( indent, ' ' ) << "Fall-through statement" << endl; 175 175 } … … 183 183 } 184 184 185 void WhileStmt::print( std::ostream &os, int indent ) {185 void WhileStmt::print( std::ostream &os, int indent ) const { 186 186 os << string( indent, ' ' ) << "While on condition: " << endl ; 187 187 condition->print( os, indent + 4 ); … … 203 203 } 204 204 205 void ForStmt::print( std::ostream &os, int indent ) {205 void ForStmt::print( std::ostream &os, int indent ) const { 206 206 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) { 208 208 os << *it << ","; 209 209 } … … 245 245 } 246 246 247 void TryStmt::print( std::ostream &os, int indent ) {247 void TryStmt::print( std::ostream &os, int indent ) const { 248 248 os << string( indent, ' ' ) << "Try Statement" << endl; 249 249 os << string( indent + 2, ' ' ) << "with block: " << endl; … … 252 252 // handlers 253 253 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++) 256 255 (*i )->print( os, indent + 4 ); 257 256 … … 272 271 } 273 272 274 void CatchStmt::print( std::ostream &os, int indent ) {273 void CatchStmt::print( std::ostream &os, int indent ) const { 275 274 os << string( indent, ' ' ) << "Catch Statement" << endl; 276 275 … … 294 293 } 295 294 296 void FinallyStmt::print( std::ostream &os, int indent ) {295 void FinallyStmt::print( std::ostream &os, int indent ) const { 297 296 os << string( indent, ' ' ) << "Finally Statement" << endl; 298 297 os << string( indent + 2, ' ' ) << "with block: " << endl; … … 304 303 NullStmt::~NullStmt() {} 305 304 306 void NullStmt::print( std::ostream &os, int indent ) {305 void NullStmt::print( std::ostream &os, int indent ) const { 307 306 os << string( indent, ' ' ) << "Null Statement" << endl ; 308 307 } -
src/SynTree/Statement.h
r94b4364 r94e0864d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jun 4 14:03:31201513 // Update Count : 1412 // Last Modified On : Tue Jun 23 11:44:27 2015 13 // Update Count : 20 14 14 // 15 15 … … 28 28 29 29 std::list<Label> & get_labels() { return labels; } 30 const std::list<Label> & get_labels() const { return labels; } 30 31 31 32 virtual Statement *clone() const = 0; 32 33 virtual void accept( Visitor &v ) = 0; 33 34 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; 35 36 protected: 36 37 std::list<Label> labels; … … 48 49 virtual void accept( Visitor &v ) { v.visit( this ); } 49 50 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; 51 52 private: 52 53 std::list<Statement*> kids; … … 64 65 virtual void accept( Visitor &v ) { v.visit( this ); } 65 66 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; 67 68 private: 68 69 Expression *expr; … … 84 85 virtual void accept( Visitor &v ) { v.visit( this ); } 85 86 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; 87 88 private: 88 89 Expression *condition; … … 106 107 107 108 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; 109 110 private: 110 111 Expression * condition; … … 127 128 128 129 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; 130 131 private: 131 132 Expression *condition; … … 141 142 142 143 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; 144 145 }; 145 146 … … 153 154 std::list<Statement *> stmts = std::list<Statement *>() ); 154 155 155 bool isDefault() { return _isDefault; }156 bool isDefault() const { return _isDefault; } 156 157 void set_default(bool b) { _isDefault = b; } 157 158 … … 166 167 167 168 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; 169 170 private: 170 171 Expression * condition; … … 189 190 virtual void accept( Visitor &v ) { v.visit( this ); } 190 191 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; 192 193 private: 193 194 Expression *condition; … … 214 215 virtual void accept( Visitor &v ) { v.visit( this ); } 215 216 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; 217 218 private: 218 219 Statement *initialization; … … 224 225 class BranchStmt : public Statement { 225 226 public: 226 enum Type { Goto = 0 227 enum Type { Goto = 0, Break, Continue }; 227 228 228 229 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); … … 243 244 virtual void accept( Visitor &v ) { v.visit( this ); } 244 245 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; 246 247 private: 247 248 static const char *brType[]; … … 263 264 virtual void accept( Visitor &v ) { v.visit( this ); } 264 265 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; 266 267 private: 267 268 Expression *expr; … … 279 280 virtual void accept( Visitor &v ) { v.visit( this ); } 280 281 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; 282 283 283 284 private: … … 300 301 virtual void accept( Visitor &v ) { v.visit( this ); } 301 302 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; 303 304 304 305 private: … … 322 323 virtual void accept( Visitor &v ) { v.visit( this ); } 323 324 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; 325 326 326 327 private: … … 341 342 virtual void accept( Visitor &v ) { v.visit( this ); } 342 343 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; 344 345 private: 345 346 CompoundStmt *block; … … 360 361 virtual void accept( Visitor &v ) { v.visit( this ); } 361 362 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; 363 364 private: 364 365 Declaration *decl;
Note: See TracChangeset
for help on using the changeset viewer.