Changeset 3d5701e for src/SynTree/Expression.cc
- Timestamp:
- Feb 25, 2020, 1:17:33 PM (6 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:
- 7dc2e015
- Parents:
- 9fb8f01 (diff), dd9e1ca (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
-
src/SynTree/Expression.cc (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r9fb8f01 r3d5701e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Aug 15 13:43:00201913 // Update Count : 6411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:55:15 2019 13 // Update Count : 70 14 14 // 15 15 … … 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 23 #include "Declaration.h" // for ObjectDecl, DeclarationWithType24 24 #include "Expression.h" // for Expression, ImplicitCopyCtorExpr 25 25 #include "InitTweak/InitTweak.h" // for getCallArg, getPointerBase … … 64 64 65 65 bool Expression::get_lvalue() const { 66 assert( !result->get_lvalue() );67 66 return false; 68 67 } … … 115 114 assert( var->get_type() ); 116 115 Type * type = var->get_type()->clone(); 117 type->set_lvalue( true );118 116 119 117 // xxx - doesn't quite work yet - get different alternatives with the same cost … … 125 123 // long long int value; 126 124 // if ( decl->valueOf( var, value ) ) { 127 // type->set_lvalue( false ); 125 // type->set_lvalue( false ); // Would have to move to get_lvalue. 128 126 // } 129 127 // } … … 140 138 141 139 bool VariableExpr::get_lvalue() const { 142 return result->get_lvalue(); 140 // It isn't always an lvalue, but it is never an rvalue. 141 return true; 143 142 } 144 143 … … 277 276 278 277 bool CastExpr::get_lvalue() const { 279 return result->get_lvalue(); 278 // This is actually wrong by C, but it works with our current set-up. 279 return arg->get_lvalue(); 280 280 } 281 281 … … 293 293 } 294 294 295 KeywordCastExpr::KeywordCastExpr( Expression * arg, Targettarget ) : Expression(), arg(arg), target( target ) {295 KeywordCastExpr::KeywordCastExpr( Expression * arg, AggregateDecl::Aggregate target ) : Expression(), arg(arg), target( target ) { 296 296 } 297 297 … … 303 303 } 304 304 305 const std::string & KeywordCastExpr::targetString() const { 306 static const std::string targetStrs[] = { 307 "coroutine", "thread", "monitor" 308 }; 309 static_assert( 310 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS), 311 "Each KeywordCastExpr::Target should have a corresponding string representation" 312 ); 313 return targetStrs[(unsigned long)target]; 305 const char * KeywordCastExpr::targetString() const { 306 return AggregateDecl::aggrString( target ); 314 307 } 315 308 … … 360 353 } 361 354 355 bool UntypedMemberExpr::get_lvalue() const { 356 return aggregate->get_lvalue(); 357 } 358 362 359 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 363 360 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 378 375 sub.apply( res ); 379 376 result = res; 380 result->set_lvalue( true );381 377 result->get_qualifiers() |= aggregate->result->get_qualifiers(); 382 378 } … … 392 388 393 389 bool MemberExpr::get_lvalue() const { 394 assert( result->get_lvalue() );390 // This is actually wrong by C, but it works with our current set-up. 395 391 return true; 396 392 } … … 427 423 // if references are still allowed in the AST, dereference returns a reference 428 424 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 425 } 433 426 } … … 447 440 448 441 bool UntypedExpr::get_lvalue() const { 449 return result->get_lvalue(); 442 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 443 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 444 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 445 return lvalueFunctions.count(fname); 450 446 } 451 447 … … 510 506 511 507 bool ConditionalExpr::get_lvalue() const { 512 return result->get_lvalue();508 return false; 513 509 } 514 510 … … 523 519 } 524 520 525 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout )), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}521 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 526 522 527 523 528 524 void AsmExpr::print( std::ostream & os, Indenter indent ) const { 529 525 os << "Asm Expression: " << std::endl; 530 if ( inout ) inout->print( os, indent+1 );526 if ( !inout.empty() ) os << "[" << inout << "] "; 531 527 if ( constraint ) constraint->print( os, indent+1 ); 532 528 if ( operand ) operand->print( os, indent+1 ); … … 570 566 571 567 bool ConstructorExpr::get_lvalue() const { 572 return result->get_lvalue();568 return false; 573 569 } 574 570 … … 582 578 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 583 579 assert( type && initializer ); 584 type->set_lvalue( true );585 580 set_result( type ); 586 581 } … … 593 588 594 589 bool CompoundLiteralExpr::get_lvalue() const { 595 assert( result->get_lvalue() );596 590 return true; 597 591 } … … 648 642 } 649 643 bool StmtExpr::get_lvalue() const { 650 return result->get_lvalue();644 return false; 651 645 } 652 646 void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.