Changeset 0a60c04
- Timestamp:
- Dec 4, 2017, 3:37:28 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 866f560
- Parents:
- ac57659
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
rac57659 r0a60c04 26 26 #include "Common/utility.h" // for ValueGuard, group_iterate 27 27 #include "CurrentObject.h" // for CurrentObject 28 #include "InitTweak/GenInit.h" 28 29 #include "InitTweak/InitTweak.h" // for isIntrinsicSingleArgCallStmt 29 30 #include "RenameVars.h" // for RenameVars, global_renamer … … 40 41 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 41 42 #include "SynTree/Visitor.h" // for acceptAll, maybeAccept 43 #include "Tuples/Tuples.h" 42 44 #include "typeops.h" // for extractResultType 43 45 #include "Unify.h" // for unify … … 46 48 47 49 namespace ResolvExpr { 48 struct Resolver final : public WithIndexer, public WithGuards, public WithVisitorRef<Resolver>, public WithShortCircuiting {50 struct Resolver final : public WithIndexer, public WithGuards, public WithVisitorRef<Resolver>, public WithShortCircuiting, public WithStmtsToAdd { 49 51 Resolver() {} 50 52 Resolver( const SymTab::Indexer & other ) { … … 611 613 expr = alt.expr; 612 614 alt.expr = nullptr; 615 616 // if with expression might be impure, create a temporary so that it is evaluated once 617 if ( Tuples::maybeImpure( expr ) ) { 618 static UniqueName tmpNamer( "_with_tmp_" ); 619 ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) ); 620 expr = new VariableExpr( tmp ); 621 stmtsToAddBefore.push_back( new DeclStmt( tmp ) ); 622 if ( InitTweak::isConstructable( tmp->type ) ) { 623 // generate ctor/dtor and resolve them 624 tmp->init = InitTweak::genCtorInit( tmp ); 625 tmp->accept( *visitor ); 626 } 627 } 613 628 } 614 629 }
Note: See TracChangeset
for help on using the changeset viewer.