Changeset b0440b7
- Timestamp:
- Aug 8, 2017, 8:01:10 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:
- 9a4e996
- Parents:
- 4618319
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Lvalue.cc
r4618319 rb0440b7 94 94 } // namespace 95 95 96 static bool referencesEliminated = false; 97 // used by UntypedExpr::createDeref to determine whether result type of dereference should be ReferenceType or value type. 98 bool referencesPermissable() { 99 return ! referencesEliminated; 100 } 101 96 102 void convertLvalue( std::list< Declaration* >& translationUnit ) { 97 103 std::cerr << "convertLvalue" << std::endl; … … 106 112 mutateAll( translationUnit, collapser ); 107 113 mutateAll( translationUnit, elim ); // last because other passes need reference types to work 114 115 // from this point forward, no other pass should create reference types. 116 referencesEliminated = true; 108 117 } 109 118 … … 134 143 // can be of differing lengths only when function is variadic 135 144 assertf( ftype->get_parameters().size() == appExpr->get_args().size() || ftype->get_isVarArgs(), "ApplicationExpr args do not match formal parameter type." ); 145 146 if ( isIntrinsicReference( appExpr ) ) { 147 // eliminate reference types from intrinsic applications - now they return lvalues 148 appExpr->set_result( appExpr->get_result()->stripReferences() ); 149 appExpr->get_result()->set_lvalue( true ); 150 } 151 136 152 unsigned int i = 0; 137 153 const unsigned int end = ftype->get_parameters().size(); … … 252 268 } 253 269 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( castExpr->get_result(), castExpr->get_arg()->get_result()->stripReferences(), SymTab::Indexer() ) ) { 254 // can remove cast if types are compatible 270 // can remove cast if types are compatible, changing expression type to value type 271 ret->set_result( castExpr->get_result()->clone() ); 255 272 castExpr->set_arg( nullptr ); 256 273 delete castExpr; -
src/GenPoly/Lvalue.h
r4618319 rb0440b7 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Lvalue.h -- 7 // Lvalue.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 24 24 /// replaces return type of `lvalue T` with `T*`, along with appropriate address-of and dereference operators 25 25 void convertLvalue( std::list< Declaration* >& translationUnit ); 26 27 /// true after reference types have been eliminated from the source code. After this point, reference types should not be added to the AST. 28 bool referencesPermissable(); 26 29 } // namespace GenPoly 27 30 -
src/SynTree/Expression.cc
r4618319 rb0440b7 34 34 #include "InitTweak/InitTweak.h" 35 35 36 #include "GenPoly/Lvalue.h" 36 37 37 38 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} … … 409 410 Type * base = InitTweak::getPointerBase( type ); 410 411 assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() ); 411 ret->set_result( new ReferenceType( Type::Qualifiers(), base->clone() ) ); 412 ret->set_result( base->clone() ); 413 if ( GenPoly::referencesPermissable() ) { 414 // if references are still allowed in the AST, dereference returns a reference 415 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) ); 416 } else { 417 // references have been removed, in which case dereference returns an lvalue of the base type. 418 ret->get_result()->set_lvalue( true ); 419 } 412 420 } 413 421 return ret;
Note: See TracChangeset
for help on using the changeset viewer.