Changes in src/SynTree/Expression.cc [d807ca28:b4f8808]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (52 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
rd807ca28 rb4f8808 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 Jul 25 14:15:47 201713 // Update Count : 5411 // 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 … … 33 34 #include "GenPoly/Lvalue.h" 34 35 35 void printInferParams( const InferredParams & inferParams, std::ostream & os, Indenter indent, int level ) {36 void printInferParams( const InferredParams & inferParams, std::ostream & os, Indenter indent, int level ) { 36 37 if ( ! inferParams.empty() ) { 37 38 os << indent << "with inferred parameters " << level << ":" << std::endl; 38 39 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 39 40 os << indent+1; 40 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 ); 41 assert(i->second.declptr); 42 i->second.declptr->printShort( os, indent+1 ); 41 43 os << std::endl; 42 printInferParams( *i->second.inferParams, os, indent+1, level+1 );44 printInferParams( i->second.expr->inferParams, os, indent+1, level+1 ); 43 45 } // for 44 46 } // if … … 47 49 Expression::Expression() : result( 0 ), env( 0 ) {} 48 50 49 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) { 50 } 51 Expression::Expression( const Expression & other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ), resnSlots( other.resnSlots ) {} 51 52 52 53 void Expression::spliceInferParams( Expression * other ) { … … 55 56 inferParams[p.first] = std::move( p.second ); 56 57 } 58 resnSlots.insert( resnSlots.end(), other->resnSlots.begin(), other->resnSlots.end() ); 57 59 } 58 60 … … 62 64 } 63 65 64 void Expression::print( std::ostream &os, Indenter indent ) const { 66 bool Expression::get_lvalue() const { 67 return false; 68 } 69 70 void Expression::print( std::ostream & os, Indenter indent ) const { 65 71 printInferParams( inferParams, os, indent+1, 0 ); 66 72 … … 79 85 } 80 86 81 ConstantExpr::ConstantExpr( const ConstantExpr & other) : Expression( other ), constant( other.constant ) {87 ConstantExpr::ConstantExpr( const ConstantExpr & other) : Expression( other ), constant( other.constant ) { 82 88 } 83 89 84 90 ConstantExpr::~ConstantExpr() {} 85 91 86 void ConstantExpr::print( std::ostream & os, Indenter indent ) const {92 void ConstantExpr::print( std::ostream & os, Indenter indent ) const { 87 93 os << "constant expression " ; 88 94 constant.print( os ); … … 103 109 } 104 110 111 VariableExpr::VariableExpr() : Expression(), var( nullptr ) {} 112 105 113 VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) { 106 114 assert( var ); 107 115 assert( var->get_type() ); 108 116 Type * type = var->get_type()->clone(); 109 type->set_lvalue( true );110 117 111 118 // xxx - doesn't quite work yet - get different alternatives with the same cost … … 117 124 // long long int value; 118 125 // if ( decl->valueOf( var, value ) ) { 119 // type->set_lvalue( false ); 126 // type->set_lvalue( false ); // Would have to move to get_lvalue. 120 127 // } 121 128 // } … … 124 131 } 125 132 126 VariableExpr::VariableExpr( const VariableExpr & other ) : Expression( other ), var( other.var ) {133 VariableExpr::VariableExpr( const VariableExpr & other ) : Expression( other ), var( other.var ) { 127 134 } 128 135 129 136 VariableExpr::~VariableExpr() { 130 137 // don't delete the declaration, since it points somewhere else in the tree 138 } 139 140 bool VariableExpr::get_lvalue() const { 141 // It isn't always an lvalue, but it is never an rvalue. 142 return true; 131 143 } 132 144 … … 137 149 } 138 150 139 void VariableExpr::print( std::ostream & os, Indenter indent ) const {151 void VariableExpr::print( std::ostream & os, Indenter indent ) const { 140 152 os << "Variable Expression: "; 141 153 var->printShort(os, indent); … … 143 155 } 144 156 145 SizeofExpr::SizeofExpr( Expression * expr_ ) :157 SizeofExpr::SizeofExpr( Expression * expr_ ) : 146 158 Expression(), expr(expr_), type(0), isType(false) { 147 159 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 148 160 } 149 161 150 SizeofExpr::SizeofExpr( Type * type_ ) :162 SizeofExpr::SizeofExpr( Type * type_ ) : 151 163 Expression(), expr(0), type(type_), isType(true) { 152 164 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 153 165 } 154 166 155 SizeofExpr::SizeofExpr( const SizeofExpr & other ) :167 SizeofExpr::SizeofExpr( const SizeofExpr & other ) : 156 168 Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { 157 169 } … … 162 174 } 163 175 164 void SizeofExpr::print( std::ostream & os, Indenter indent) const {176 void SizeofExpr::print( std::ostream & os, Indenter indent) const { 165 177 os << "Sizeof Expression on: "; 166 178 if (isType) type->print(os, indent+1); … … 169 181 } 170 182 171 AlignofExpr::AlignofExpr( Expression * expr_ ) :183 AlignofExpr::AlignofExpr( Expression * expr_ ) : 172 184 Expression(), expr(expr_), type(0), isType(false) { 173 185 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 174 186 } 175 187 176 AlignofExpr::AlignofExpr( Type * type_ ) :188 AlignofExpr::AlignofExpr( Type * type_ ) : 177 189 Expression(), expr(0), type(type_), isType(true) { 178 190 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 179 191 } 180 192 181 AlignofExpr::AlignofExpr( const AlignofExpr & other ) :193 AlignofExpr::AlignofExpr( const AlignofExpr & other ) : 182 194 Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { 183 195 } … … 188 200 } 189 201 190 void AlignofExpr::print( std::ostream & os, Indenter indent) const {202 void AlignofExpr::print( std::ostream & os, Indenter indent) const { 191 203 os << "Alignof Expression on: "; 192 204 if (isType) type->print(os, indent+1); … … 195 207 } 196 208 197 UntypedOffsetofExpr::UntypedOffsetofExpr( Type * type, const std::string &member ) :209 UntypedOffsetofExpr::UntypedOffsetofExpr( Type * type, const std::string & member ) : 198 210 Expression(), type(type), member(member) { 199 211 assert( type ); … … 201 213 } 202 214 203 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr & other ) :215 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr & other ) : 204 216 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 205 217 … … 208 220 } 209 221 210 void UntypedOffsetofExpr::print( std::ostream & os, Indenter indent) const {222 void UntypedOffsetofExpr::print( std::ostream & os, Indenter indent) const { 211 223 os << "Untyped Offsetof Expression on member " << member << " of "; 212 224 type->print(os, indent+1); … … 214 226 } 215 227 216 OffsetofExpr::OffsetofExpr( Type * type, DeclarationWithType *member ) :228 OffsetofExpr::OffsetofExpr( Type * type, DeclarationWithType * member ) : 217 229 Expression(), type(type), member(member) { 218 230 assert( member ); … … 221 233 } 222 234 223 OffsetofExpr::OffsetofExpr( const OffsetofExpr & other ) :235 OffsetofExpr::OffsetofExpr( const OffsetofExpr & other ) : 224 236 Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {} 225 237 … … 228 240 } 229 241 230 void OffsetofExpr::print( std::ostream & os, Indenter indent) const {242 void OffsetofExpr::print( std::ostream & os, Indenter indent) const { 231 243 os << "Offsetof Expression on member " << member->name << " of "; 232 244 type->print(os, indent+1); … … 234 246 } 235 247 236 OffsetPackExpr::OffsetPackExpr( StructInstType * type ) : Expression(), type( type ) {248 OffsetPackExpr::OffsetPackExpr( StructInstType * type ) : Expression(), type( type ) { 237 249 assert( type ); 238 250 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 239 251 } 240 252 241 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr & other ) : Expression( other ), type( maybeClone( other.type ) ) {}253 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr & other ) : Expression( other ), type( maybeClone( other.type ) ) {} 242 254 243 255 OffsetPackExpr::~OffsetPackExpr() { delete type; } 244 256 245 void OffsetPackExpr::print( std::ostream & os, Indenter indent ) const {257 void OffsetPackExpr::print( std::ostream & os, Indenter indent ) const { 246 258 os << "Offset pack expression on "; 247 259 type->print(os, indent+1); … … 249 261 } 250 262 251 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) : 252 Expression(), attr( attr ), expr(expr_), type(0), isType(false) { 253 } 254 255 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) : 256 Expression(), attr( attr ), expr(0), type(type_), isType(true) { 257 } 258 259 AttrExpr::AttrExpr( const AttrExpr &other ) : 260 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) { 261 } 262 263 AttrExpr::~AttrExpr() { 264 delete attr; 265 delete expr; 266 delete type; 267 } 268 269 void AttrExpr::print( std::ostream &os, Indenter indent) const { 270 os << "Attr "; 271 attr->print( os, indent+1); 272 if ( isType || expr ) { 273 os << "applied to: "; 274 if (isType) type->print(os, indent+1); 275 else expr->print(os, indent+1); 276 } // if 277 Expression::print( os, indent ); 278 } 279 280 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) { 263 CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) { 281 264 set_result(toType); 282 265 } 283 266 284 CastExpr::CastExpr( Expression * arg, bool isGenerated ) : Expression(),arg(arg), isGenerated( isGenerated ) {267 CastExpr::CastExpr( Expression * arg, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) { 285 268 set_result( new VoidType( Type::Qualifiers() ) ); 286 269 } 287 270 288 CastExpr::CastExpr( const CastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {271 CastExpr::CastExpr( const CastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) { 289 272 } 290 273 … … 293 276 } 294 277 295 void CastExpr::print( std::ostream &os, Indenter indent ) const { 296 os << "Cast of:" << std::endl << indent+1; 278 bool CastExpr::get_lvalue() const { 279 // This is actually wrong by C, but it works with our current set-up. 280 return arg->get_lvalue(); 281 } 282 283 void CastExpr::print( std::ostream & os, Indenter indent ) const { 284 os << (isGenerated ? "Generated " : "Explicit ") << "Cast of:" << std::endl << indent+1; 297 285 arg->print(os, indent+1); 298 286 os << std::endl << indent << "... to:"; … … 306 294 } 307 295 308 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {309 } 310 311 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {296 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) { 297 } 298 299 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) { 312 300 } 313 301 … … 327 315 } 328 316 329 void KeywordCastExpr::print( std::ostream & os, Indenter indent ) const {317 void KeywordCastExpr::print( std::ostream & os, Indenter indent ) const { 330 318 os << "Keyword Cast of:" << std::endl << indent+1; 331 319 arg->print(os, indent+1); … … 335 323 } 336 324 337 VirtualCastExpr::VirtualCastExpr( Expression * arg_, Type *toType ) : Expression(), arg(arg_) {325 VirtualCastExpr::VirtualCastExpr( Expression * arg_, Type * toType ) : Expression(), arg(arg_) { 338 326 set_result(toType); 339 327 } 340 328 341 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ) {329 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ) { 342 330 } 343 331 … … 346 334 } 347 335 348 void VirtualCastExpr::print( std::ostream & os, Indenter indent ) const {336 void VirtualCastExpr::print( std::ostream & os, Indenter indent ) const { 349 337 os << "Virtual Cast of:" << std::endl << indent+1; 350 338 arg->print(os, indent+1); … … 359 347 } 360 348 361 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression * aggregate ) :349 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression * aggregate ) : 362 350 Expression(), member(member), aggregate(aggregate) { 363 351 assert( aggregate ); 364 352 } 365 353 366 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr & other ) :354 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr & other ) : 367 355 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) { 368 356 } … … 373 361 } 374 362 375 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 363 bool UntypedMemberExpr::get_lvalue() const { 364 return aggregate->get_lvalue(); 365 } 366 367 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const { 376 368 os << "Untyped Member Expression, with field: " << std::endl << indent+1; 377 369 member->print(os, indent+1 ); 378 os << indent << "... from aggregate: " << std::endl << indent+1;370 os << indent << "... from aggregate:" << std::endl << indent+1; 379 371 aggregate->print(os, indent+1); 380 372 Expression::print( os, indent ); 381 373 } 382 374 383 MemberExpr::MemberExpr( DeclarationWithType * member, Expression *aggregate ) :375 MemberExpr::MemberExpr( DeclarationWithType * member, Expression * aggregate ) : 384 376 Expression(), member(member), aggregate(aggregate) { 385 377 assert( member ); … … 391 383 sub.apply( res ); 392 384 result = res; 393 result->set_lvalue( true );394 385 result->get_qualifiers() |= aggregate->result->get_qualifiers(); 395 386 } 396 387 397 MemberExpr::MemberExpr( const MemberExpr & other ) :388 MemberExpr::MemberExpr( const MemberExpr & other ) : 398 389 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { 399 390 } … … 404 395 } 405 396 406 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 407 os << "Member Expression, with field: " << std::endl; 397 bool MemberExpr::get_lvalue() const { 398 // This is actually wrong by C, but it works with our current set-up. 399 return true; 400 } 401 402 void MemberExpr::print( std::ostream & os, Indenter indent ) const { 403 os << "Member Expression, with field:" << std::endl; 408 404 os << indent+1; 409 405 member->print( os, indent+1 ); 410 os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;406 os << std::endl << indent << "... from aggregate:" << std::endl << indent+1; 411 407 aggregate->print(os, indent + 1); 412 408 Expression::print( os, indent ); 413 409 } 414 410 415 UntypedExpr::UntypedExpr( Expression * function, const std::list<Expression *> &args ) :411 UntypedExpr::UntypedExpr( Expression * function, const std::list<Expression *> & args ) : 416 412 Expression(), function(function), args(args) {} 417 413 418 UntypedExpr::UntypedExpr( const UntypedExpr & other ) :414 UntypedExpr::UntypedExpr( const UntypedExpr & other ) : 419 415 Expression( other ), function( maybeClone( other.function ) ) { 420 416 cloneAll( other.args, args ); … … 435 431 // if references are still allowed in the AST, dereference returns a reference 436 432 ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) ); 437 } else {438 // references have been removed, in which case dereference returns an lvalue of the base type.439 ret->result->set_lvalue( true );440 433 } 441 434 } … … 454 447 } 455 448 456 457 void UntypedExpr::print( std::ostream &os, Indenter indent ) const { 458 os << "Applying untyped: " << std::endl; 449 bool UntypedExpr::get_lvalue() const { 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); 454 } 455 456 void UntypedExpr::print( std::ostream & os, Indenter indent ) const { 457 os << "Applying untyped:" << std::endl; 459 458 os << indent+1; 460 459 function->print(os, indent+1); 461 os << std::endl << indent << "...to: " << std::endl;460 os << std::endl << indent << "...to:" << std::endl; 462 461 printAll(args, os, indent+1); 463 462 Expression::print( os, indent ); … … 469 468 } 470 469 471 NameExpr::NameExpr( const NameExpr & other ) : Expression( other ), name( other.name ) {470 NameExpr::NameExpr( const NameExpr & other ) : Expression( other ), name( other.name ) { 472 471 } 473 472 474 473 NameExpr::~NameExpr() {} 475 474 476 void NameExpr::print( std::ostream & os, Indenter indent ) const {475 void NameExpr::print( std::ostream & os, Indenter indent ) const { 477 476 os << "Name: " << get_name(); 478 477 Expression::print( os, indent ); 479 478 } 480 479 481 LogicalExpr::LogicalExpr( Expression * arg1_, Expression *arg2_, bool andp ) :480 LogicalExpr::LogicalExpr( Expression * arg1_, Expression * arg2_, bool andp ) : 482 481 Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) { 483 482 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 484 483 } 485 484 486 LogicalExpr::LogicalExpr( const LogicalExpr & other ) :485 LogicalExpr::LogicalExpr( const LogicalExpr & other ) : 487 486 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) { 488 487 } … … 493 492 } 494 493 495 void LogicalExpr::print( std::ostream & os, Indenter indent )const {494 void LogicalExpr::print( std::ostream & os, Indenter indent )const { 496 495 os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: "; 497 496 arg1->print(os); … … 504 503 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {} 505 504 506 ConditionalExpr::ConditionalExpr( const ConditionalExpr & other ) :505 ConditionalExpr::ConditionalExpr( const ConditionalExpr & other ) : 507 506 Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) { 508 507 } … … 514 513 } 515 514 516 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const { 515 bool ConditionalExpr::get_lvalue() const { 516 return false; 517 } 518 519 void ConditionalExpr::print( std::ostream & os, Indenter indent ) const { 517 520 os << "Conditional expression on: " << std::endl << indent+1; 518 521 arg1->print( os, indent+1 ); … … 527 530 528 531 529 void AsmExpr::print( std::ostream & os, Indenter indent ) const {532 void AsmExpr::print( std::ostream & os, Indenter indent ) const { 530 533 os << "Asm Expression: " << std::endl; 531 534 if ( inout ) inout->print( os, indent+1 ); … … 538 541 assert( callExpr ); 539 542 assert( callExpr->result ); 540 set_result( callExpr-> get_result()->clone() );543 set_result( callExpr->result->clone() ); 541 544 } 542 545 543 546 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) { 544 cloneAll( other.tempDecls, tempDecls );545 cloneAll( other.returnDecls, returnDecls );546 cloneAll( other.dtors, dtors );547 547 } 548 548 … … 550 550 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 551 551 delete callExpr; 552 deleteAll( tempDecls ); 553 deleteAll( returnDecls ); 554 deleteAll( dtors ); 555 } 556 557 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const { 552 } 553 554 void ImplicitCopyCtorExpr::print( std::ostream & os, Indenter indent ) const { 558 555 os << "Implicit Copy Constructor Expression: " << std::endl << indent+1; 559 556 callExpr->print( os, indent+1 ); 560 os << std::endl << indent << "... with temporaries:" << std::endl;561 printAll( tempDecls, os, indent+1 );562 os << std::endl << indent << "... with return temporaries:" << std::endl;563 printAll( returnDecls, os, indent+1 );564 Expression::print( os, indent );565 557 } 566 558 … … 581 573 } 582 574 583 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 575 bool ConstructorExpr::get_lvalue() const { 576 return false; 577 } 578 579 void ConstructorExpr::print( std::ostream & os, Indenter indent ) const { 584 580 os << "Constructor Expression: " << std::endl << indent+1; 585 581 callExpr->print( os, indent + 2 ); … … 590 586 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) { 591 587 assert( type && initializer ); 592 type->set_lvalue( true );593 588 set_result( type ); 594 589 } 595 590 596 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr & other ) : Expression( other ), initializer( other.initializer->clone() ) {}591 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr & other ) : Expression( other ), initializer( other.initializer->clone() ) {} 597 592 598 593 CompoundLiteralExpr::~CompoundLiteralExpr() { … … 600 595 } 601 596 602 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { 597 bool CompoundLiteralExpr::get_lvalue() const { 598 return true; 599 } 600 601 void CompoundLiteralExpr::print( std::ostream & os, Indenter indent ) const { 603 602 os << "Compound Literal Expression: " << std::endl << indent+1; 604 603 result->print( os, indent+1 ); … … 608 607 } 609 608 610 RangeExpr::RangeExpr( Expression * low, Expression *high ) : low( low ), high( high ) {}611 RangeExpr::RangeExpr( const RangeExpr & other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}612 void RangeExpr::print( std::ostream & os, Indenter indent ) const {609 RangeExpr::RangeExpr( Expression * low, Expression * high ) : low( low ), high( high ) {} 610 RangeExpr::RangeExpr( const RangeExpr & other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 611 void RangeExpr::print( std::ostream & os, Indenter indent ) const { 613 612 os << "Range Expression: "; 614 613 low->print( os, indent ); … … 618 617 } 619 618 620 StmtExpr::StmtExpr( CompoundStmt * statements ) : statements( statements ) {619 StmtExpr::StmtExpr( CompoundStmt * statements ) : statements( statements ) { 621 620 computeResult(); 622 621 } 623 StmtExpr::StmtExpr( const StmtExpr & other ) : Expression( other ), statements( other.statements->clone()) {622 StmtExpr::StmtExpr( const StmtExpr & other ) : Expression( other ), statements( other.statements->clone() ), resultExpr( other.resultExpr ) { 624 623 cloneAll( other.returnDecls, returnDecls ); 625 624 cloneAll( other.dtors, dtors ); … … 650 649 } 651 650 } 652 void StmtExpr::print( std::ostream &os, Indenter indent ) const { 651 bool StmtExpr::get_lvalue() const { 652 return false; 653 } 654 void StmtExpr::print( std::ostream & os, Indenter indent ) const { 653 655 os << "Statement Expression: " << std::endl << indent+1; 654 656 statements->print( os, indent+1 ); … … 666 668 667 669 long long UniqueExpr::count = 0; 668 UniqueExpr::UniqueExpr( Expression * expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {670 UniqueExpr::UniqueExpr( Expression * expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) { 669 671 assert( expr ); 670 672 assert( count != -1 ); … … 674 676 } 675 677 } 676 UniqueExpr::UniqueExpr( const UniqueExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {678 UniqueExpr::UniqueExpr( const UniqueExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 677 679 } 678 680 UniqueExpr::~UniqueExpr() { … … 681 683 delete var; 682 684 } 683 void UniqueExpr::print( std::ostream & os, Indenter indent ) const {685 void UniqueExpr::print( std::ostream & os, Indenter indent ) const { 684 686 os << "Unique Expression with id:" << id << std::endl << indent+1; 685 687 expr->print( os, indent+1 ); … … 732 734 } 733 735 734 DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode* deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {736 DeletedExpr::DeletedExpr( Expression * expr, Declaration * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) { 735 737 assert( expr->result ); 736 738 result = expr->result->clone(); … … 746 748 os << std::endl << indent+1 << "... deleted by: "; 747 749 deleteStmt->print( os, indent+1 ); 750 } 751 752 753 DefaultArgExpr::DefaultArgExpr( Expression * expr ) : expr( expr ) { 754 assert( expr->result ); 755 result = expr->result->clone(); 756 } 757 DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {} 758 DefaultArgExpr::~DefaultArgExpr() { 759 delete expr; 760 } 761 762 void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const { 763 os << "Default Argument Expression" << std::endl << indent+1; 764 expr->print( os, indent+1 ); 748 765 } 749 766
Note:
See TracChangeset
for help on using the changeset viewer.