Changeset 19858f6 for src/SynTree/Expression.cc
- Timestamp:
- Oct 4, 2019, 9:59:01 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 65e10b2
- Parents:
- 970141d (diff), 73fad25 (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/SynTree/Expression.cc
r970141d r19858f6 19 19 #include <iostream> // for ostream, operator<<, basic_ostream 20 20 #include <list> // for list, _List_iterator, list<>::co... 21 #include <set> // for set 21 22 22 23 #include "Common/utility.h" // for maybeClone, cloneAll, deleteAll … … 64 65 65 66 bool Expression::get_lvalue() const { 66 assert( !result->get_lvalue() );67 67 return false; 68 68 } … … 115 115 assert( var->get_type() ); 116 116 Type * type = var->get_type()->clone(); 117 type->set_lvalue( true );118 117 119 118 // xxx - doesn't quite work yet - get different alternatives with the same cost … … 125 124 // long long int value; 126 125 // if ( decl->valueOf( var, value ) ) { 127 // type->set_lvalue( false ); 126 // type->set_lvalue( false ); // Would have to move to get_lvalue. 128 127 // } 129 128 // } … … 140 139 141 140 bool VariableExpr::get_lvalue() const { 142 return result->get_lvalue(); 141 // It isn't always an lvalue, but it is never an rvalue. 142 return true; 143 143 } 144 144 … … 277 277 278 278 bool CastExpr::get_lvalue() const { 279 return result->get_lvalue(); 279 // This is actually wrong by C, but it works with our current set-up. 280 return arg->get_lvalue(); 280 281 } 281 282 … … 360 361 } 361 362 363 bool UntypedMemberExpr::get_lvalue() const { 364 return aggregate->get_lvalue(); 365 } 366 362 367 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 363 368 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 378 383 sub.apply( res ); 379 384 result = res; 380 result->set_lvalue( true );381 385 result->get_qualifiers() |= aggregate->result->get_qualifiers(); 382 386 } … … 392 396 393 397 bool MemberExpr::get_lvalue() const { 394 assert( result->get_lvalue() );398 // This is actually wrong by C, but it works with our current set-up. 395 399 return true; 396 400 } … … 427 431 // if references are still allowed in the AST, dereference returns a reference 428 432 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) ); 429 } else {430 // references have been removed, in which case dereference returns an lvalue of the base type.431 ret->result->set_lvalue( true );432 433 } 433 434 } … … 447 448 448 449 bool UntypedExpr::get_lvalue() const { 449 return result->get_lvalue(); 450 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 451 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 452 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 453 return lvalueFunctions.count(fname); 450 454 } 451 455 … … 510 514 511 515 bool ConditionalExpr::get_lvalue() const { 512 return result->get_lvalue();516 return false; 513 517 } 514 518 … … 570 574 571 575 bool ConstructorExpr::get_lvalue() const { 572 return result->get_lvalue();576 return false; 573 577 } 574 578 … … 582 586 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 583 587 assert( type && initializer ); 584 type->set_lvalue( true );585 588 set_result( type ); 586 589 } … … 593 596 594 597 bool CompoundLiteralExpr::get_lvalue() const { 595 assert( result->get_lvalue() );596 598 return true; 597 599 } … … 648 650 } 649 651 bool StmtExpr::get_lvalue() const { 650 return result->get_lvalue();652 return false; 651 653 } 652 654 void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset
for help on using the changeset viewer.