Changes in / [c2bfb31:1c2c253]
- Files:
-
- 40 deleted
- 3 edited
-
doc/rob_thesis/cfa-format.tex (deleted)
-
doc/rob_thesis/conclusions.tex (deleted)
-
doc/rob_thesis/ctordtor.tex (deleted)
-
doc/rob_thesis/examples/ctor/array_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/copy_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/cv_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/enum_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/expr_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/global_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/hide_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/placement_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/return_dtor.c (deleted)
-
doc/rob_thesis/examples/ctor/static_ctor.c (deleted)
-
doc/rob_thesis/examples/ctor/union_ctor.c (deleted)
-
doc/rob_thesis/examples/intro/FileOutputStream.java (deleted)
-
doc/rob_thesis/examples/intro/compound_lit.c (deleted)
-
doc/rob_thesis/examples/intro/designation.c (deleted)
-
doc/rob_thesis/examples/intro/ignore.c (deleted)
-
doc/rob_thesis/examples/intro/ires.java (deleted)
-
doc/rob_thesis/examples/intro/res.java (deleted)
-
doc/rob_thesis/examples/intro/res1.java (deleted)
-
doc/rob_thesis/examples/intro/res2.java (deleted)
-
doc/rob_thesis/examples/intro/res3.java (deleted)
-
doc/rob_thesis/examples/intro/tuple.cc (deleted)
-
doc/rob_thesis/examples/intro/variadic.java (deleted)
-
doc/rob_thesis/examples/scope_guard.h (deleted)
-
doc/rob_thesis/examples/test_scoped_guard.c (deleted)
-
doc/rob_thesis/examples/tuples/assign.c (deleted)
-
doc/rob_thesis/examples/tuples/cast.c (deleted)
-
doc/rob_thesis/examples/tuples/ctor.c (deleted)
-
doc/rob_thesis/examples/tuples/mrv.c (deleted)
-
doc/rob_thesis/examples/tuples/mrv_1.c (deleted)
-
doc/rob_thesis/examples/tuples/mrv_2.c (deleted)
-
doc/rob_thesis/examples/tuples/mrv_3.c (deleted)
-
doc/rob_thesis/examples/variadic/new.c (deleted)
-
doc/rob_thesis/examples/variadic/print.c (deleted)
-
doc/rob_thesis/intro.tex (deleted)
-
doc/rob_thesis/thesis-frontpgs.tex (deleted)
-
doc/rob_thesis/thesis.tex (deleted)
-
doc/rob_thesis/tuples.tex (deleted)
-
src/GenPoly/Box.cc (modified) (1 diff)
-
src/GenPoly/Specialize.cc (modified) (2 diffs)
-
src/InitTweak/FixInit.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rc2bfb31 r1c2c253 1298 1298 FunctionType * ftype = functionDecl->get_functionType(); 1299 1299 if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) { 1300 if ( functionDecl->get_name() != "?=?" && ! isPrefix( functionDecl->get_name(), "_thunk" ) && ! isPrefix( functionDecl->get_name(), "_adapter" )) { // xxx - remove check for ?=? once reference types are in; remove check for prefix once thunks properly use ctor/dtors1300 if ( functionDecl->get_name() != "?=?" && ! isPrefix( functionDecl->get_name(), "_thunk" ) ) { // xxx - remove check for ?=? once reference types are in; remove check for prefix once thunks properly use ctor/dtors 1301 1301 assert( ftype->get_returnVals().size() == 1 ); 1302 1302 DeclarationWithType * retval = ftype->get_returnVals().front(); -
src/GenPoly/Specialize.cc
rc2bfb31 r1c2c253 168 168 } 169 169 170 struct EnvTrimmer : public Visitor {171 TypeSubstitution * env, * newEnv;172 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){}173 virtual void visit( TypeDecl * tyDecl ) {174 // transfer known bindings for seen type variables175 if ( Type * t = env->lookup( tyDecl->get_name() ) ) {176 newEnv->add( tyDecl->get_name(), t );177 }178 }179 };180 181 /// reduce environment to just the parts that are referenced in a given expression182 TypeSubstitution * trimEnv( ApplicationExpr * expr, TypeSubstitution * env ) {183 if ( env ) {184 TypeSubstitution * newEnv = new TypeSubstitution();185 EnvTrimmer trimmer( env, newEnv );186 expr->accept( trimmer );187 return newEnv;188 }189 return nullptr;190 }191 192 170 /// Generates a thunk that calls `actual` with type `funType` and returns its address 193 171 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 233 211 } 234 212 235 appExpr->set_env( trimEnv( appExpr,env ) );213 appExpr->set_env( maybeClone( env ) ); 236 214 if ( inferParams ) { 237 215 appExpr->get_inferParams() = *inferParams; -
src/InitTweak/FixInit.cc
rc2bfb31 r1c2c253 52 52 namespace { 53 53 typedef std::unordered_map< Expression *, TypeSubstitution * > EnvMap; 54 typedef std::unordered_map< int, int > UnqCount;55 54 56 55 class InsertImplicitCalls final : public GenPoly::PolyMutator { … … 75 74 /// generate/resolve copy construction expressions for each, and generate/resolve destructors for both 76 75 /// arguments and return value temporaries 77 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap , UnqCount & unqCount);76 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap ); 78 77 79 78 typedef SymTab::Indexer Parent; 80 79 using Parent::visit; 81 80 82 ResolveCopyCtors( const EnvMap & envMap , UnqCount & unqCount ) : envMap( envMap ), unqCount( unqCount) {}81 ResolveCopyCtors( const EnvMap & envMap ) : envMap( envMap ) {} 83 82 84 83 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override; … … 95 94 TypeSubstitution * env; 96 95 const EnvMap & envMap; 97 UnqCount & unqCount; // count the number of times each unique expr ID appears98 96 }; 99 97 … … 204 202 class FixCopyCtors final : public GenPoly::PolyMutator { 205 203 public: 206 FixCopyCtors( UnqCount & unqCount ) : unqCount( unqCount ){}207 204 /// expand ImplicitCopyCtorExpr nodes into the temporary declarations, copy constructors, call expression, 208 205 /// and destructors 209 static void fixCopyCtors( std::list< Declaration * > &translationUnit , UnqCount & unqCount);206 static void fixCopyCtors( std::list< Declaration * > &translationUnit ); 210 207 211 208 typedef GenPoly::PolyMutator Parent; … … 214 211 virtual Expression * mutate( UniqueExpr * unqExpr ) override; 215 212 virtual Expression * mutate( StmtExpr * stmtExpr ) override; 216 217 UnqCount & unqCount;218 213 }; 219 214 … … 277 272 278 273 EnvMap envMap; 279 UnqCount unqCount;280 274 281 275 InsertImplicitCalls::insert( translationUnit, envMap ); 282 ResolveCopyCtors::resolveImplicitCalls( translationUnit, envMap , unqCount);276 ResolveCopyCtors::resolveImplicitCalls( translationUnit, envMap ); 283 277 InsertDtors::insert( translationUnit ); 284 278 FixInit::fixInitializers( translationUnit ); 285 279 286 280 // FixCopyCtors must happen after FixInit, so that destructors are placed correctly 287 FixCopyCtors::fixCopyCtors( translationUnit , unqCount);281 FixCopyCtors::fixCopyCtors( translationUnit ); 288 282 289 283 GenStructMemberCalls::generate( translationUnit ); … … 304 298 } 305 299 306 void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap , UnqCount & unqCount) {307 ResolveCopyCtors resolver( envMap , unqCount);300 void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap ) { 301 ResolveCopyCtors resolver( envMap ); 308 302 acceptAll( translationUnit, resolver ); 309 303 } … … 335 329 } 336 330 337 void FixCopyCtors::fixCopyCtors( std::list< Declaration * > & translationUnit , UnqCount & unqCount) {338 FixCopyCtors fixer ( unqCount );331 void FixCopyCtors::fixCopyCtors( std::list< Declaration * > & translationUnit ) { 332 FixCopyCtors fixer; 339 333 mutateAll( translationUnit, fixer ); 340 334 } … … 526 520 void ResolveCopyCtors::visit( UniqueExpr * unqExpr ) { 527 521 static std::unordered_set< int > vars; 528 unqCount[ unqExpr->get_id() ]++; // count the number of unique expressions for each ID529 522 if ( vars.count( unqExpr->get_id() ) ) { 530 523 // xxx - hack to prevent double-handling of unique exprs, otherwise too many temporary variables and destructors are generated … … 643 636 644 637 Expression * FixCopyCtors::mutate( UniqueExpr * unqExpr ) { 645 unqCount[ unqExpr->get_id() ]--;646 static std::unordered_map< int, std::list< Statement * > > dtors;647 638 static std::unordered_map< int, UniqueExpr * > unqMap; 648 639 static std::unordered_set< int > addDeref; … … 654 645 delete unqExpr->get_result(); 655 646 unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) ); 656 if ( unqCount[ unqExpr->get_id() ] == 0 ) { // insert destructor after the last use of the unique expression657 stmtsToAdd.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );658 }659 647 if ( addDeref.count( unqExpr->get_id() ) ) { 660 648 // other UniqueExpr was dereferenced because it was an lvalue return, so this one should be too … … 663 651 return unqExpr; 664 652 } 665 FixCopyCtors fixer( unqCount ); 666 unqExpr->set_expr( unqExpr->get_expr()->acceptMutator( fixer ) ); // stmtexprs contained should not be separately fixed, so this must occur after the lookup 667 stmtsToAdd.splice( stmtsToAdd.end(), fixer.stmtsToAdd ); 653 unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) ); // stmtexprs contained should not be separately fixed, so this must occur after the lookup 668 654 unqMap[unqExpr->get_id()] = unqExpr; 669 655 if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) { … … 675 661 getCallArg( deref, 0 ) = unqExpr; 676 662 addDeref.insert( unqExpr->get_id() ); 677 if ( unqCount[ unqExpr->get_id() ] == 0 ) { // insert destructor after the last use of the unique expression678 stmtsToAdd.splice( stmtsToAddAfter.end(), dtors[ unqExpr->get_id() ] );679 } else { // remember dtors for last instance of unique expr680 dtors[ unqExpr->get_id() ] = fixer.stmtsToAddAfter;681 }682 663 return deref; 683 664 }
Note:
See TracChangeset
for help on using the changeset viewer.