- Timestamp:
- Dec 6, 2021, 5:06:14 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 75873cf
- Parents:
- 813dfd86 (diff), a83012bf (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
- Files:
-
- 3 added
- 11 edited
-
AST/Decl.hpp (modified) (1 diff)
-
AST/Expr.cpp (modified) (2 diffs)
-
AST/Print.cpp (modified) (1 diff)
-
AST/Print.hpp (modified) (2 diffs)
-
Concurrency/Keywords.cc (modified) (1 diff)
-
Concurrency/Keywords.h (modified) (3 diffs)
-
Concurrency/KeywordsNew.cpp (added)
-
Concurrency/module.mk (modified) (1 diff)
-
InitTweak/InitTweak.cc (modified) (2 diffs)
-
InitTweak/InitTweak.h (modified) (2 diffs)
-
Validate/CompoundLiteral.cpp (added)
-
Validate/CompoundLiteral.hpp (added)
-
Validate/module.mk (modified) (1 diff)
-
main.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r813dfd86 r295dd61 270 270 : AggregateDecl( loc, name, std::move(attrs), linkage ), kind( kind ) {} 271 271 272 bool is_coroutine() { return kind == Coroutine; }273 bool is_generator() { return kind == Generator; }274 bool is_monitor () { return kind == Monitor ; }275 bool is_thread () { return kind == Thread ; }272 bool is_coroutine() const { return kind == Coroutine; } 273 bool is_generator() const { return kind == Generator; } 274 bool is_monitor () const { return kind == Monitor ; } 275 bool is_thread () const { return kind == Thread ; } 276 276 277 277 const Decl * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Expr.cpp
r813dfd86 r295dd61 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 15 17:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Created On : T hr Jun 13 13:38:00 201913 // Update Count : 611 // Last Modified By : Andrew Beach 12 // Created On : Tue Nov 30 14:23:00 2021 13 // Update Count : 7 14 14 // 15 15 … … 141 141 /// The type of the address of a type. 142 142 /// Caller is responsible for managing returned memory 143 Type * addrType( const Type *type ) {144 if ( const ReferenceType * refType = dynamic_cast< const ReferenceType * >( type) ) {145 return new ReferenceType { addrType( refType->base ), refType->qualifiers };143 Type * addrType( const ptr<Type> & type ) { 144 if ( auto refType = type.as< ReferenceType >() ) { 145 return new ReferenceType( addrType( refType->base ), refType->qualifiers ); 146 146 } else { 147 return new PointerType { type };147 return new PointerType( type ); 148 148 } 149 149 } 150 } 151 152 AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) : Expr( loc ), arg( a ) { 153 if ( arg->result ) { 154 if ( arg->get_lvalue() ) { 155 // lvalue, retains all levels of reference, and gains a pointer inside the references 156 Type * res = addrType( arg->result ); 157 result = res; 150 151 /// The type of the address of an expression. 152 /// Caller is responsible for managing returned memory 153 Type * addrExprType( const CodeLocation & loc, const Expr * arg ) { 154 assert( arg ); 155 // If the expression's type is unknown, the address type is unknown. 156 if ( nullptr == arg->result ) { 157 return nullptr; 158 // An lvalue is transformed directly. 159 } else if ( arg->get_lvalue() ) { 160 return addrType( arg->result ); 161 // Strip a layer of reference to "create" an lvalue expression. 162 } else if ( auto refType = arg->result.as< ReferenceType >() ) { 163 return addrType( refType->base ); 158 164 } else { 159 // taking address of non-lvalue, must be a reference, loses one layer of reference 160 if ( const ReferenceType * refType = 161 dynamic_cast< const ReferenceType * >( arg->result.get() ) ) { 162 Type * res = addrType( refType->base ); 163 result = res; 164 } else { 165 SemanticError( loc, arg->result.get(), 166 "Attempt to take address of non-lvalue expression: " ); 167 } 165 SemanticError( loc, arg->result.get(), 166 "Attempt to take address of non-lvalue expression: " ); 168 167 } 169 168 } 170 169 } 170 171 AddressExpr::AddressExpr( const CodeLocation & loc, const Expr * a ) : 172 Expr( loc, addrExprType( loc, a ) ), arg( a ) 173 {} 171 174 172 175 // --- LabelAddressExpr -
src/AST/Print.cpp
r813dfd86 r295dd61 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Print.cpp -- 7 // Print.cpp -- Print an AST (or sub-tree) to a stream. 8 8 // 9 9 // Author : Thierry Delisle -
src/AST/Print.hpp
r813dfd86 r295dd61 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Print.hpp -- 7 // Print.hpp -- Print an AST (or sub-tree) to a stream. 8 8 // 9 9 // Author : Thierry Delisle … … 35 35 template< typename Coll > 36 36 void printAll( std::ostream & os, const Coll & c, Indenter indent = {} ) { 37 for ( const auto & i : c ) {38 if ( ! i ) continue;39 40 os << indent;41 print( os, i, indent );42 os << std::endl;43 }37 for ( const auto & i : c ) { 38 if ( ! i ) continue; 39 40 os << indent; 41 print( os, i, indent ); 42 os << std::endl; 43 } 44 44 } 45 45 -
src/Concurrency/Keywords.cc
r813dfd86 r295dd61 979 979 // If this is the destructor for a monitor it must be mutex 980 980 if(isDtor) { 981 // This reflects MutexKeyword::validate, except does not produce an error. 981 982 Type* ty = decl->get_functionType()->get_parameters().front()->get_type(); 982 983 -
src/Concurrency/Keywords.h
r813dfd86 r295dd61 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Keywords.h -- 7 // Keywords.h -- Implement concurrency constructs from their keywords. 8 8 // 9 9 // Author : Thierry Delisle … … 19 19 20 20 class Declaration; 21 namespace ast { 22 class TranslationUnit; 23 } 21 24 22 25 namespace Concurrency { … … 24 27 void implementMutexFuncs( std::list< Declaration * > & translationUnit ); 25 28 void implementThreadStarter( std::list< Declaration * > & translationUnit ); 29 30 /// Implement the sue-like keywords and the suspend keyword. 31 void implementKeywords( ast::TranslationUnit & translationUnit ); 32 /// Implement the mutex parameters and mutex statement. 33 void implementMutex( ast::TranslationUnit & translationUnit ); 34 /// Add the thread starter code to constructors. 35 void implementThreadStarter( ast::TranslationUnit & translationUnit ); 26 36 }; 27 37 -
src/Concurrency/module.mk
r813dfd86 r295dd61 15 15 ############################################################################### 16 16 17 SRC += Concurrency/Keywords.cc Concurrency/Keywords.h Concurrency/Waitfor.cc Concurrency/Waitfor.h 18 SRCDEMANGLE += Concurrency/Keywords.cc 17 SRC_CONCURRENCY = \ 18 Concurrency/KeywordsNew.cpp \ 19 Concurrency/Keywords.cc 19 20 21 SRC += $(SRC_CONCURRENCY) \ 22 Concurrency/Keywords.h \ 23 Concurrency/Waitfor.cc \ 24 Concurrency/Waitfor.h 25 26 SRCDEMANGLE += $(SRC_CONCURRENCY) 27 -
src/InitTweak/InitTweak.cc
r813dfd86 r295dd61 9 9 // Author : Rob Schluntz 10 10 // Created On : Fri May 13 11:26:36 2016 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Jun 16 20:57:22202113 // Update Count : 1 811 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Nov 19 19:22:00 2021 13 // Update Count : 19 14 14 // 15 15 … … 540 540 } 541 541 542 const ast::Type * getTypeofThis( const ast::FunctionType * ftype ) { 543 assertf( ftype, "getTypeofThis: nullptr ftype" ); 544 const std::vector<ast::ptr<ast::Type>> & params = ftype->params; 545 assertf( !params.empty(), "getTypeofThis: ftype with 0 parameters: %s", 546 toString( ftype ).c_str() ); 547 const ast::ReferenceType * refType = 548 params.front().strict_as<ast::ReferenceType>(); 549 return refType->base; 550 } 551 542 552 ObjectDecl * getParamThis( FunctionType * ftype ) { 543 553 assertf( ftype, "getParamThis: nullptr ftype" ); -
src/InitTweak/InitTweak.h
r813dfd86 r295dd61 10 10 // Created On : Fri May 13 11:26:36 2016 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 19 14:18:00 201913 // Update Count : 612 // Last Modified On : Fri Nov 19 14:18:00 2021 13 // Update Count : 7 14 14 // 15 15 … … 35 35 /// returns the base type of the first parameter to a constructor/destructor/assignment function 36 36 Type * getTypeofThis( FunctionType * ftype ); 37 const ast::Type * getTypeofThis( const ast::FunctionType * ftype ); 37 38 38 39 /// returns the first parameter of a constructor/destructor/assignment function -
src/Validate/module.mk
r813dfd86 r295dd61 16 16 17 17 SRC_VALIDATE = \ 18 Validate/CompoundLiteral.cpp \ 19 Validate/CompoundLiteral.hpp \ 18 20 Validate/HandleAttributes.cc \ 19 21 Validate/HandleAttributes.h \ -
src/main.cc
r813dfd86 r295dd61 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Nov 12 11:06:00 202113 // Update Count : 65 812 // Last Modified On : Tue Nov 30 10:25:00 2021 13 // Update Count : 659 14 14 // 15 15 … … 50 50 #include "Common/UnimplementedError.h" // for UnimplementedError 51 51 #include "Common/utility.h" // for deleteAll, filter, printAll 52 #include "Concurrency/Keywords.h" // for implementMutex, implement... 52 53 #include "Concurrency/Waitfor.h" // for generateWaitfor 53 54 #include "ControlStruct/ExceptDecl.h" // for translateExcept … … 73 74 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 74 75 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 76 #include "Validate/CompoundLiteral.hpp" // for handleCompoundLiterals 75 77 #include "Validate/InitializerLength.hpp" // for setLengthFromInitializer 76 78 #include "Validate/LabelAddressFixer.hpp" // for fixLabelAddresses … … 325 327 PASS( "Validate-C", SymTab::validate_C( translationUnit ) ); 326 328 PASS( "Validate-D", SymTab::validate_D( translationUnit ) ); 327 PASS( "Validate-E", SymTab::validate_E( translationUnit ) );328 329 329 330 CodeTools::fillLocations( translationUnit ); … … 338 339 forceFillCodeLocations( transUnit ); 339 340 341 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 342 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); 343 PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) ); 340 344 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) ); 341 345 PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) ); … … 402 406 translationUnit = convert( move( transUnit ) ); 403 407 } else { 408 PASS( "Validate-E", SymTab::validate_E( translationUnit ) ); 404 409 PASS( "Validate-F", SymTab::validate_F( translationUnit ) ); 405 410
Note:
See TracChangeset
for help on using the changeset viewer.