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