Changeset 58fe85a for src/GenPoly/Specialize.cc
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
r3c64c668 r58fe85a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 23:40:49 201913 // Update Count : 3 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Jul 2 17:42:00 2020 13 // Update Count : 33 14 14 // 15 15 … … 42 42 43 43 namespace GenPoly { 44 struct Specialize final : public WithConstTypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> { 44 struct Specialize final : public WithConstTypeSubstitution, 45 public WithDeclsToAdd, public WithVisitorRef<Specialize> { 45 46 Expression * postmutate( ApplicationExpr *applicationExpr ); 46 47 Expression * postmutate( CastExpr *castExpr ); … … 217 218 thunkFunc->get_attributes().push_back( new Attribute( "unused" ) ); 218 219 220 // Thunks at the global level must be static to avoid collisions between files. 221 // (Conversly thunks inside a function must be unique and not static.) 222 thunkFunc->storageClasses.is_static = !isInFunction(); 223 219 224 // thread thunk parameters into call to actual function, naming thunk parameters as we go 220 225 UniqueName paramNamer( paramPrefix ); … … 248 253 } // if 249 254 250 // handle any specializations that may still be present 251 std::string oldParamPrefix = paramPrefix; 252 paramPrefix += "p"; 253 // save stmtsToAddBefore in oldStmts 254 std::list< Statement* > oldStmts; 255 oldStmts.splice( oldStmts.end(), stmtsToAddBefore ); 256 appExpr->acceptMutator( *visitor ); 257 paramPrefix = oldParamPrefix; 258 // write any statements added for recursive specializations into the thunk body 259 thunkFunc->statements->kids.splice( thunkFunc->statements->kids.end(), stmtsToAddBefore ); 260 // restore oldStmts into stmtsToAddBefore 261 stmtsToAddBefore.splice( stmtsToAddBefore.end(), oldStmts ); 255 // Handle any specializations that may still be present. 256 { 257 std::string oldParamPrefix = paramPrefix; 258 paramPrefix += "p"; 259 std::list< Declaration * > oldDecls; 260 oldDecls.splice( oldDecls.end(), declsToAddBefore ); 261 262 appExpr->acceptMutator( *visitor ); 263 // Write recursive specializations into the thunk body. 264 for ( Declaration * decl : declsToAddBefore ) { 265 thunkFunc->statements->kids.push_back( new DeclStmt( decl ) ); 266 } 267 268 declsToAddBefore = std::move( oldDecls ); 269 paramPrefix = oldParamPrefix; 270 } 262 271 263 272 // add return (or valueless expression) to the thunk … … 270 279 thunkFunc->statements->kids.push_back( appStmt ); 271 280 272 // add thunk definition to queue of statements to add273 stmtsToAddBefore.push_back( new DeclStmt( thunkFunc ));281 // Add the thunk definition (converted to DeclStmt if appproprate). 282 declsToAddBefore.push_back( thunkFunc ); 274 283 // return address of thunk function as replacement expression 275 284 return new AddressExpr( new VariableExpr( thunkFunc ) );
Note:
See TracChangeset
for help on using the changeset viewer.