Changeset 4a60488 for src/SynTree/Expression.cc
- Timestamp:
- Sep 27, 2019, 3:35:46 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 90ce35aa
- Parents:
- 8e1467d (diff), 849720f (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
r8e1467d r4a60488 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Feb 19 18:10:55201913 // Update Count : 6 011 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Aug 15 13:43:00 2019 13 // Update Count : 64 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 … … 63 64 } 64 65 66 bool Expression::get_lvalue() const { 67 return false; 68 } 69 65 70 void Expression::print( std::ostream & os, Indenter indent ) const { 66 71 printInferParams( inferParams, os, indent+1, 0 ); … … 134 139 } 135 140 141 bool VariableExpr::get_lvalue() const { 142 // It isn't always an lvalue, but it is never an rvalue. 143 return true; 144 } 145 136 146 VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) { 137 147 VariableExpr * funcExpr = new VariableExpr( func ); … … 252 262 } 253 263 254 AttrExpr::AttrExpr( Expression * attr, Expression * expr_ ) :255 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {256 }257 258 AttrExpr::AttrExpr( Expression * attr, Type * type_ ) :259 Expression(), attr( attr ), expr(0), type(type_), isType(true) {260 }261 262 AttrExpr::AttrExpr( const AttrExpr & other ) :263 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {264 }265 266 AttrExpr::~AttrExpr() {267 delete attr;268 delete expr;269 delete type;270 }271 272 void AttrExpr::print( std::ostream & os, Indenter indent) const {273 os << "Attr ";274 attr->print( os, indent+1);275 if ( isType || expr ) {276 os << "applied to: ";277 if (isType) type->print(os, indent+1);278 else expr->print(os, indent+1);279 } // if280 Expression::print( os, indent );281 }282 283 264 CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) { 284 265 set_result(toType); … … 294 275 CastExpr::~CastExpr() { 295 276 delete arg; 277 } 278 279 bool CastExpr::get_lvalue() const { 280 // This is actually wrong by C, but it works with our current set-up. 281 return arg->get_lvalue(); 296 282 } 297 283 … … 376 362 } 377 363 364 bool UntypedMemberExpr::get_lvalue() const { 365 return aggregate->get_lvalue(); 366 } 367 378 368 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 379 369 os << "Untyped Member Expression, with field: " << std::endl << indent+1; … … 405 395 // don't delete the member declaration, since it points somewhere else in the tree 406 396 delete aggregate; 397 } 398 399 bool MemberExpr::get_lvalue() const { 400 // This is actually wrong by C, but it works with our current set-up. 401 return true; 407 402 } 408 403 … … 457 452 } 458 453 454 bool UntypedExpr::get_lvalue() const { 455 // from src/GenPoly/Lvalue.cc: isIntrinsicReference 456 static std::set<std::string> lvalueFunctions = { "*?", "?[?]" }; 457 std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) ); 458 return lvalueFunctions.count(fname); 459 } 459 460 460 461 void UntypedExpr::print( std::ostream & os, Indenter indent ) const { … … 515 516 delete arg2; 516 517 delete arg3; 518 } 519 520 bool ConditionalExpr::get_lvalue() const { 521 return false; 517 522 } 518 523 … … 573 578 } 574 579 580 bool ConstructorExpr::get_lvalue() const { 581 return false; 582 } 583 575 584 void ConstructorExpr::print( std::ostream & os, Indenter indent ) const { 576 585 os << "Constructor Expression: " << std::endl << indent+1; … … 590 599 CompoundLiteralExpr::~CompoundLiteralExpr() { 591 600 delete initializer; 601 } 602 603 bool CompoundLiteralExpr::get_lvalue() const { 604 return true; 592 605 } 593 606 … … 641 654 result = new VoidType( Type::Qualifiers() ); 642 655 } 656 } 657 bool StmtExpr::get_lvalue() const { 658 return false; 643 659 } 644 660 void StmtExpr::print( std::ostream & os, Indenter indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.