Changeset c11e31c for translator/SynTree
- Timestamp:
- May 14, 2015, 1:44:55 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:
- 4bf5298
- Parents:
- d4778a6
- Location:
- translator/SynTree
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/CompoundStmt.cc
rd4778a6 rc11e31c 11 11 #include <functional> 12 12 13 using std::string; 14 using std::endl; 13 15 14 16 CompoundStmt::CompoundStmt( std::list<Label> labels ) … … 31 33 CompoundStmt::print( std::ostream &os, int indent ) 32 34 { 33 printAll( kids, os, indent ); 35 os << "\r" << string(indent, ' ') << "CompoundStmt Statement" << endl ; 36 printAll( kids, os, indent + 4 ); 34 37 } 35 38 -
translator/SynTree/Declaration.h
rd4778a6 rc11e31c 12 12 enum StorageClass { 13 13 NoStorageClass, 14 Extern, 15 Static, 14 16 Auto, 15 Static,16 Extern,17 17 Register, 18 Fortran 18 Inline, 19 Fortran, 19 20 }; 20 21 … … 108 109 CompoundStmt *get_statements() const { return statements; } 109 110 void set_statements( CompoundStmt *newValue ) { statements = newValue; } 110 bool get_isInline() const { return isInline; }111 void set_isInline( bool newValue ) { isInline = newValue; }111 // bool get_isInline() const { return isInline; } 112 // void set_isInline( bool newValue ) { isInline = newValue; } 112 113 std::list< std::string >& get_oldIdents() { return oldIdents; } 113 114 std::list< Declaration* >& get_oldDecls() { return oldDecls; } -
translator/SynTree/FunctionDecl.cc
rd4778a6 rc11e31c 1 /*2 * This file is part of the Cforall project3 *4 * $Id: FunctionDecl.cc,v 1.15 2005/08/29 20:59:25 rcbilson Exp $5 *6 */7 8 1 #include <cassert> 9 2 … … 14 7 15 8 16 FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, 17 CompoundStmt *statements, bool isInline ) 18 : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) 19 { 20 // this is a pretty brazen hack to force the function "main" to have C linkage 21 if( name == "main" ) { 9 FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline ) 10 : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) { 11 // this is a brazen hack to force the function "main" to have C linkage 12 if ( name == "main" ) { 22 13 set_linkage( LinkageSpec::C ); 23 14 } … … 25 16 26 17 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 27 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), 28 isInline( other.isInline ) 29 { 18 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) { 30 19 } 31 20 32 FunctionDecl::~FunctionDecl() 33 { 21 FunctionDecl::~FunctionDecl() { 34 22 delete type; 35 23 delete statements; 36 24 } 37 25 38 Type* 39 FunctionDecl::get_type() const 40 { 26 Type * FunctionDecl::get_type() const { 41 27 return type; 42 28 } 43 29 44 void 45 FunctionDecl::set_type(Type *t) 46 { 30 void FunctionDecl::set_type( Type *t ) { 47 31 type = dynamic_cast< FunctionType* >( t ); 48 32 assert( type ); 49 33 } 50 34 51 void 52 FunctionDecl::print( std::ostream &os, int indent ) const 53 { 35 void FunctionDecl::print( std::ostream &os, int indent ) const { 54 36 using std::endl; 55 37 using std::string; 56 38 57 if ( get_name() != "" ) {39 if ( get_name() != "" ) { 58 40 os << get_name() << ": a "; 59 41 } 60 if ( get_linkage() != LinkageSpec::Cforall ) {42 if ( get_linkage() != LinkageSpec::Cforall ) { 61 43 os << LinkageSpec::toString( get_linkage() ) << " "; 62 44 } 63 if ( isInline ) {45 if ( isInline ) { 64 46 os << "inline "; 65 47 } 66 if ( get_storageClass() != NoStorageClass ) {48 if ( get_storageClass() != NoStorageClass ) { 67 49 os << storageClassName[ get_storageClass() ] << ' '; 68 50 } 69 if ( get_type() ) {51 if ( get_type() ) { 70 52 get_type()->print( os, indent ); 71 53 } else { 72 54 os << "untyped entity "; 73 55 } 74 if ( !oldIdents.empty() ) {56 if ( ! oldIdents.empty() ) { 75 57 os << string( indent+2, ' ' ) << "with parameter names" << endl; 76 58 for( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) { … … 78 60 } 79 61 } 80 if ( !oldDecls.empty() ) {62 if ( ! oldDecls.empty() ) { 81 63 os << string( indent+2, ' ' ) << "with parameter declarations" << endl; 82 64 printAll( oldDecls, os, indent+4 ); 83 65 } 84 if ( statements ) {66 if ( statements ) { 85 67 os << string( indent+2, ' ' ) << "with body " << endl; 86 68 statements->print( os, indent+4 ); … … 88 70 } 89 71 90 void 91 FunctionDecl::printShort( std::ostream &os, int indent ) const 92 { 72 void FunctionDecl::printShort( std::ostream &os, int indent ) const { 93 73 using std::endl; 94 74 using std::string; 95 75 96 if ( get_name() != "" ) {76 if ( get_name() != "" ) { 97 77 os << get_name() << ": a "; 98 78 } 99 if ( isInline ) {79 if ( isInline ) { 100 80 os << "inline "; 101 81 } 102 if ( get_storageClass() != NoStorageClass ) {82 if ( get_storageClass() != NoStorageClass ) { 103 83 os << storageClassName[ get_storageClass() ] << ' '; 104 84 } 105 if ( get_type() ) {85 if ( get_type() ) { 106 86 get_type()->print( os, indent ); 107 87 } else { … … 109 89 } 110 90 } 111 -
translator/SynTree/Statement.cc
rd4778a6 rc11e31c 14 14 15 15 16 // *** Statement17 16 Statement::Statement(std::list<Label> _labels): 18 17 labels(_labels) {} … … 22 21 Statement::~Statement() {} 23 22 24 //*** ExprStmt25 23 ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ): 26 24 Statement(_labels), expr(_expr) {} … … 33 31 } 34 32 35 //*** BranchStmt36 33 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 37 34 … … 57 54 } 58 55 59 //*** ReturnStmt60 56 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : 61 57 Statement( labels ), expr( _expr ), isThrow( throwP ) {} … … 72 68 73 69 74 // *** IfStmt75 70 IfStmt::IfStmt( std::list<Label> _labels, Expression *_condition, Statement *_thenPart, Statement *_elsePart ): 76 71 Statement(_labels), condition(_condition), thenPart(_thenPart), elsePart(_elsePart) {} … … 91 86 } 92 87 93 // *** SwitchStmt94 88 SwitchStmt::SwitchStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches): 95 89 Statement(_labels), condition(_condition), branches(_branches) … … 116 110 } 117 111 118 // *** CaseStmt119 112 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, 120 113 std::list<Statement *> &_statements, bool deflt ) … … 147 140 } 148 141 149 //*** ChooseStmt150 142 //ChooseStmt::ChooseStmt( std::list<Label> labels, Expression *condition, Statement *body ) {} 151 143 ChooseStmt::ChooseStmt(std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches): … … 172 164 } 173 165 174 //*** FallthruStmt175 166 void FallthruStmt::print(std::ostream &os, int indent) { 176 167 os << "\r" << string(indent, ' ') << "Fall-through statement" << endl; 177 168 } 178 169 179 //*** WhileStmt180 170 WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition_, 181 171 Statement *body_, bool isDoWhile_ ): … … 196 186 } 197 187 198 //*** ForStmt199 188 ForStmt::ForStmt( std::list<Label> labels, Statement *initialization_, 200 189 Expression *condition_, Expression *increment_, Statement *body_ ): … … 233 222 } 234 223 235 //*** TryStmt236 224 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &_handlers, FinallyStmt *_finallyBlock ) : 237 225 Statement( labels ), block( tryBlock ), handlers( _handlers ), finallyBlock( _finallyBlock ) … … 266 254 } 267 255 268 //*** CatchStmt269 256 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) : 270 257 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) … … 290 277 291 278 292 //*** FinallyStmt293 279 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *_block ) : 294 280 Statement( labels ), block( _block ) … … 307 293 } 308 294 309 //*** NullStmt310 295 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 311 296 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} -
translator/SynTree/Statement.h
rd4778a6 rc11e31c 1 /*2 * This file is part of the Cforall project3 *4 * $Id: Statement.h,v 1.18 2005/08/29 20:59:26 rcbilson Exp $5 *6 */7 8 1 #ifndef STATEMENT_H 9 2 #define STATEMENT_H -
translator/SynTree/Type.h
rd4778a6 rc11e31c 10 10 public: 11 11 struct Qualifiers { 12 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}13 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic) {}12 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {} 13 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {} 14 14 15 15 Qualifiers &operator+=( const Qualifiers &other ); … … 28 28 bool isLvalue; 29 29 bool isAtomic; 30 bool isAttribute; 30 31 }; 31 32 … … 40 41 bool get_isLvalue() { return tq.isLvalue; } 41 42 bool get_isAtomic() { return tq.isAtomic; } 43 bool get_isAttribute() { return tq.isAttribute; } 42 44 void set_isConst( bool newValue ) { tq.isConst = newValue; } 43 45 void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; } … … 45 47 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 46 48 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 49 void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; } 47 50 std::list<TypeDecl*>& get_forall() { return forall; } 48 51
Note: See TracChangeset
for help on using the changeset viewer.