Changes in src/Tuples/TupleExpansion.cc [b4f8808:aee472e]
- File:
-
- 1 edited
-
src/Tuples/TupleExpansion.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansion.cc
rb4f8808 raee472e 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Fri Jul 19 14:39:00 201913 // Update Count : 2211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 21 17:35:04 2017 13 // Update Count : 19 14 14 // 15 15 … … 17 17 #include <cassert> // for assert 18 18 #include <list> // for list 19 #include <vector> 20 21 #include "AST/CVQualifiers.hpp" 22 #include "AST/Expr.hpp" 23 #include "AST/Node.hpp" 24 #include "AST/Type.hpp" 19 25 20 #include "Common/PassVisitor.h" // for PassVisitor, WithDeclsToAdd, WithGu... 26 21 #include "Common/ScopedMap.h" // for ScopedMap … … 63 58 }; 64 59 65 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public With ConstTypeSubstitution {60 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public WithTypeSubstitution { 66 61 Type * postmutate( TupleType * tupleType ); 67 62 … … 304 299 // produce the TupleType which aggregates the types of the exprs 305 300 std::list< Type * > types; 306 Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type:: Atomic | Type::Mutex );301 Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ); 307 302 for ( Expression * expr : exprs ) { 308 303 assert( expr->get_result() ); … … 319 314 return new TupleType( qualifiers, types ); 320 315 } 321 const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) {322 // produce the TupleType which aggregates the types of the exprs323 std::vector<ast::ptr<ast::Type>> types;324 ast::CV::Qualifiers quals{325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue |326 ast::CV::Atomic | ast::CV::Mutex };327 328 for ( const ast::Expr * expr : exprs ) {329 assert( expr->result );330 // if the type of any expr is void, the type of the entire tuple is void331 if ( expr->result->isVoid() ) return new ast::VoidType{};332 333 // qualifiers on the tuple type are the qualifiers that exist on all components334 quals &= expr->result->qualifiers;335 336 types.emplace_back( expr->result );337 }338 339 if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; }340 return new ast::TupleType{ std::move(types), quals };341 }342 316 343 317 TypeInstType * isTtype( Type * type ) { … … 350 324 } 351 325 352 const TypeInstType * isTtype( const Type * type ) {353 if ( const TypeInstType * inst = dynamic_cast< const TypeInstType * >( type ) ) {354 if ( inst->baseType && inst->baseType->kind == TypeDecl::Ttype ) {355 return inst;356 }357 }358 return nullptr;359 }360 361 const ast::TypeInstType * isTtype( const ast::Type * type ) {362 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) {363 if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) {364 return inst;365 }366 }367 return nullptr;368 }369 370 326 namespace { 371 327 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure … … 373 329 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {} 374 330 375 void previsit( constApplicationExpr * appExpr ) {331 void previsit( ApplicationExpr * appExpr ) { 376 332 visit_children = false; 377 if ( constDeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {378 if ( function-> linkage== LinkageSpec::Intrinsic ) {379 if ( function-> name == "*?" || function->name== "?[?]" ) {333 if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) { 334 if ( function->get_linkage() == LinkageSpec::Intrinsic ) { 335 if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) { 380 336 // intrinsic dereference, subscript are pure, but need to recursively look for impurity 381 337 visit_children = true; … … 386 342 maybeImpure = true; 387 343 } 388 void previsit( constUntypedExpr * ) { maybeImpure = true; visit_children = false; }389 void previsit( constUniqueExpr * ) {344 void previsit( UntypedExpr * ) { maybeImpure = true; visit_children = false; } 345 void previsit( UniqueExpr * ) { 390 346 if ( ignoreUnique ) { 391 347 // bottom out at unique expression. … … 402 358 } // namespace 403 359 404 bool maybeImpure( constExpression * expr ) {360 bool maybeImpure( Expression * expr ) { 405 361 PassVisitor<ImpurityDetector> detector( false ); 406 362 expr->accept( detector ); … … 408 364 } 409 365 410 bool maybeImpureIgnoreUnique( constExpression * expr ) {366 bool maybeImpureIgnoreUnique( Expression * expr ) { 411 367 PassVisitor<ImpurityDetector> detector( true ); 412 368 expr->accept( detector );
Note:
See TracChangeset
for help on using the changeset viewer.