Changes in / [51b1202:a3a17ba]
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r51b1202 ra3a17ba 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : T hu Jul 30 14:35:40201513 // Update Count : 5412 // Last Modified On : Tue Aug 11 16:22:35 2015 13 // Update Count : 89 14 14 // 15 15 … … 77 77 Expression *handleIntrinsics( ApplicationExpr *appExpr ); 78 78 ObjectDecl *makeTemporary( Type *type ); 79 79 80 typedef std::map< std::string, FunctionDecl *> AdapterMap; 80 81 std::map< std::string, DeclarationWithType *> assignOps; 81 typedef std::map< std::string, FunctionDecl *> AdapterMap;82 82 std::stack< AdapterMap > adapters; 83 83 DeclarationWithType *retval; … … 168 168 TyVarMap dummyTyVars; 169 169 return isPolyRet( function, name, dummyTyVars ); 170 } 171 172 bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) { 173 std::string dummyString; 174 return isPolyRet( function, dummyString, otherTyVars ); 170 175 } 171 176 … … 526 531 } 527 532 528 void Pass1::passAdapters( ApplicationExpr * appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ) {533 void Pass1::passAdapters( ApplicationExpr * appExpr, FunctionType * functionType, const TyVarMap & exprTyVars ) { 529 534 // collect a list of function types passed as parameters or implicit parameters (assertions) 530 535 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); … … 545 550 546 551 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 552 FunctionType *originalFunction = (*funType)->clone(); 547 553 FunctionType *realFunction = (*funType)->clone(); 548 554 std::string mangleName = SymTab::Mangler::mangle( realFunction ); … … 559 565 env->apply( realFunction ); 560 566 mangleName = SymTab::Mangler::mangle( realFunction ); 561 AdapterMap & adapters = Pass1::adapters.top();562 AdapterMap::iterator adapter = adapters.find( mangleName );563 567 564 568 if ( needsAdapter( realFunction, exprTyVars, true ) ) { … … 567 571 // create a new adapter. 568 572 appExpr->get_args().push_front( new NameExpr( makeAdapterName ( mangleName ) ) ); 569 continue; 570 } else if ( adapter == adapters.end() ) { 571 // adapter has not been created yet in the current scope, so define it 572 FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars ); 573 adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) ); 574 stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) ); 573 } else { 574 if ( isPolyRet( originalFunction, exprTyVars ) ) { 575 // if the return type involved polymorphic types, then 576 // the adapter will need to take those polymorphic types 577 // as pointers. Therefore, there can be two different 578 // functions with the same mangled name, so we need two adapter map 579 // stacks and also we need the mangled names to be different. 580 mangleName += "polyret_"; 581 } 582 583 AdapterMap & adapters = Pass1::adapters.top(); 584 AdapterMap::iterator adapter = adapters.find( mangleName ); 585 if ( adapter == adapters.end() ) { 586 // adapter has not been created yet in the current scope, so define it 587 FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars ); 588 adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) ); 589 stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) ); 590 } // if 591 assert( adapter != adapters.end() ); 592 593 // add the appropriate adapter as a parameter 594 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 575 595 } // if 576 assert( adapter != adapters.end() );577 578 // add the appropriate adapter as a parameter579 appExpr->get_args().push_front( new VariableExpr( adapter->second ) );580 596 } // if 581 597 } // for -
src/SymTab/Indexer.cc
r51b1202 ra3a17ba 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:37:33 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jun 5 08:05:17201513 // Update Count : 511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 05 13:52:42 2015 13 // Update Count : 10 14 14 // 15 15 … … 26 26 27 27 namespace SymTab { 28 template< typename Container, typename VisitorType > 29 inline void acceptAllNewScope( Container &container, VisitorType &visitor ) { 30 visitor.enterScope(); 31 acceptAll( container, visitor ); 32 visitor.leaveScope(); 33 } 34 28 35 Indexer::Indexer( bool useDebug ) : doDebug( useDebug ) {} 29 36 … … 31 38 32 39 void Indexer::visit( ObjectDecl *objectDecl ) { 40 enterScope(); 33 41 maybeAccept( objectDecl->get_type(), *this ); 42 leaveScope(); 34 43 maybeAccept( objectDecl->get_init(), *this ); 35 44 maybeAccept( objectDecl->get_bitfieldWidth(), *this ); … … 149 158 leaveScope(); 150 159 } 160 161 162 void Indexer::visit( ApplicationExpr *applicationExpr ) { 163 acceptAllNewScope( applicationExpr->get_results(), *this ); 164 maybeAccept( applicationExpr->get_function(), *this ); 165 acceptAll( applicationExpr->get_args(), *this ); 166 } 167 168 void Indexer::visit( UntypedExpr *untypedExpr ) { 169 acceptAllNewScope( untypedExpr->get_results(), *this ); 170 acceptAll( untypedExpr->get_args(), *this ); 171 } 172 173 void Indexer::visit( NameExpr *nameExpr ) { 174 acceptAllNewScope( nameExpr->get_results(), *this ); 175 } 176 177 void Indexer::visit( AddressExpr *addressExpr ) { 178 acceptAllNewScope( addressExpr->get_results(), *this ); 179 maybeAccept( addressExpr->get_arg(), *this ); 180 } 181 182 void Indexer::visit( LabelAddressExpr *labAddressExpr ) { 183 acceptAllNewScope( labAddressExpr->get_results(), *this ); 184 maybeAccept( labAddressExpr->get_arg(), *this ); 185 } 186 187 void Indexer::visit( CastExpr *castExpr ) { 188 acceptAllNewScope( castExpr->get_results(), *this ); 189 maybeAccept( castExpr->get_arg(), *this ); 190 } 191 192 void Indexer::visit( UntypedMemberExpr *memberExpr ) { 193 acceptAllNewScope( memberExpr->get_results(), *this ); 194 maybeAccept( memberExpr->get_aggregate(), *this ); 195 } 196 197 void Indexer::visit( MemberExpr *memberExpr ) { 198 acceptAllNewScope( memberExpr->get_results(), *this ); 199 maybeAccept( memberExpr->get_aggregate(), *this ); 200 } 201 202 void Indexer::visit( VariableExpr *variableExpr ) { 203 acceptAllNewScope( variableExpr->get_results(), *this ); 204 } 205 206 void Indexer::visit( ConstantExpr *constantExpr ) { 207 acceptAllNewScope( constantExpr->get_results(), *this ); 208 maybeAccept( constantExpr->get_constant(), *this ); 209 } 210 211 void Indexer::visit( SizeofExpr *sizeofExpr ) { 212 acceptAllNewScope( sizeofExpr->get_results(), *this ); 213 if ( sizeofExpr->get_isType() ) { 214 maybeAccept( sizeofExpr->get_type(), *this ); 215 } else { 216 maybeAccept( sizeofExpr->get_expr(), *this ); 217 } 218 } 219 220 void Indexer::visit( AttrExpr *attrExpr ) { 221 acceptAllNewScope( attrExpr->get_results(), *this ); 222 if ( attrExpr->get_isType() ) { 223 maybeAccept( attrExpr->get_type(), *this ); 224 } else { 225 maybeAccept( attrExpr->get_expr(), *this ); 226 } 227 } 228 229 void Indexer::visit( LogicalExpr *logicalExpr ) { 230 acceptAllNewScope( logicalExpr->get_results(), *this ); 231 maybeAccept( logicalExpr->get_arg1(), *this ); 232 maybeAccept( logicalExpr->get_arg2(), *this ); 233 } 234 235 void Indexer::visit( ConditionalExpr *conditionalExpr ) { 236 acceptAllNewScope( conditionalExpr->get_results(), *this ); 237 maybeAccept( conditionalExpr->get_arg1(), *this ); 238 maybeAccept( conditionalExpr->get_arg2(), *this ); 239 maybeAccept( conditionalExpr->get_arg3(), *this ); 240 } 241 242 void Indexer::visit( CommaExpr *commaExpr ) { 243 acceptAllNewScope( commaExpr->get_results(), *this ); 244 maybeAccept( commaExpr->get_arg1(), *this ); 245 maybeAccept( commaExpr->get_arg2(), *this ); 246 } 247 248 void Indexer::visit( TupleExpr *tupleExpr ) { 249 acceptAllNewScope( tupleExpr->get_results(), *this ); 250 acceptAll( tupleExpr->get_exprs(), *this ); 251 } 252 253 void Indexer::visit( SolvedTupleExpr *tupleExpr ) { 254 acceptAllNewScope( tupleExpr->get_results(), *this ); 255 acceptAll( tupleExpr->get_exprs(), *this ); 256 } 257 258 void Indexer::visit( TypeExpr *typeExpr ) { 259 acceptAllNewScope( typeExpr->get_results(), *this ); 260 maybeAccept( typeExpr->get_type(), *this ); 261 } 262 263 void Indexer::visit( AsmExpr *asmExpr ) { 264 maybeAccept( asmExpr->get_inout(), *this ); 265 maybeAccept( asmExpr->get_constraint(), *this ); 266 maybeAccept( asmExpr->get_operand(), *this ); 267 } 268 269 void Indexer::visit( UntypedValofExpr *valofExpr ) { 270 acceptAllNewScope( valofExpr->get_results(), *this ); 271 maybeAccept( valofExpr->get_body(), *this ); 272 } 273 151 274 152 275 void Indexer::visit( ContextInstType *contextInst ) { -
src/SymTab/Indexer.h
r51b1202 ra3a17ba 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:38:55 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue May 19 16:51:21201513 // Update Count : 311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 05 13:51:39 2015 13 // Update Count : 4 14 14 // 15 15 … … 43 43 44 44 virtual void visit( CompoundStmt *compoundStmt ); 45 46 virtual void visit( ApplicationExpr *applicationExpr ); 47 virtual void visit( UntypedExpr *untypedExpr ); 48 virtual void visit( NameExpr *nameExpr ); 49 virtual void visit( CastExpr *castExpr ); 50 virtual void visit( AddressExpr *addressExpr ); 51 virtual void visit( LabelAddressExpr *labAddressExpr ); 52 virtual void visit( UntypedMemberExpr *memberExpr ); 53 virtual void visit( MemberExpr *memberExpr ); 54 virtual void visit( VariableExpr *variableExpr ); 55 virtual void visit( ConstantExpr *constantExpr ); 56 virtual void visit( SizeofExpr *sizeofExpr ); 57 virtual void visit( AttrExpr *attrExpr ); 58 virtual void visit( LogicalExpr *logicalExpr ); 59 virtual void visit( ConditionalExpr *conditionalExpr ); 60 virtual void visit( CommaExpr *commaExpr ); 61 virtual void visit( TupleExpr *tupleExpr ); 62 virtual void visit( SolvedTupleExpr *tupleExpr ); 63 virtual void visit( TypeExpr *typeExpr ); 64 virtual void visit( AsmExpr *asmExpr ); 65 virtual void visit( UntypedValofExpr *valofExpr ); 45 66 46 67 virtual void visit( ContextInstType *contextInst ); -
src/SymTab/Validate.cc
r51b1202 ra3a17ba 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jul 22 13:16:00201513 // Update Count : 19 412 // Last Modified On : Wed Aug 05 14:00:24 2015 13 // Update Count : 195 14 14 // 15 15 … … 893 893 TypedefMap oldNames = typedefNames; 894 894 DeclarationWithType *ret = Mutator::mutate( objDecl ); 895 typedefNames = oldNames; 895 896 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 896 897 return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() ); … … 898 899 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl ); 899 900 } // if 900 typedefNames = oldNames;901 901 return ret; 902 902 }
Note: See TracChangeset
for help on using the changeset viewer.