Changes in src/SynTree/Expression.cc [e04ef3a:630a82a]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
re04ef3a r630a82a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 16:03:39201613 // Update Count : 4 212 // Last Modified On : Fri Apr 8 17:16:23 2016 13 // Update Count : 40 14 14 // 15 15 … … 32 32 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {} 33 33 34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) , extension( other.extension ){34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) { 35 35 cloneAll( other.results, results ); 36 36 } … … 60 60 argName->print( os, indent+2 ); 61 61 } // if 62 63 if ( extension ) {64 os << std::string( indent, ' ' ) << "with extension:";65 } // if66 62 } 67 63 … … 76 72 77 73 void ConstantExpr::print( std::ostream &os, int indent ) const { 78 os << "constant expression " ;74 os << std::string( indent, ' ' ) << "constant expression " ; 79 75 constant.print( os ); 80 76 Expression::print( os, indent ); 77 os << std::endl; 81 78 } 82 79 83 80 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) { 84 assert( var );85 assert( var->get_type() );86 81 add_result( var->get_type()->clone() ); 87 82 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { … … 98 93 99 94 void VariableExpr::print( std::ostream &os, int indent ) const { 100 os << "Variable Expression: ";95 os << std::string( indent, ' ' ) << "Variable Expression: "; 101 96 102 97 Declaration *decl = get_var(); … … 127 122 128 123 void SizeofExpr::print( std::ostream &os, int indent) const { 129 os << "Sizeof Expression on: ";124 os << std::string( indent, ' ' ) << "Sizeof Expression on: "; 130 125 131 126 if (isType) … … 228 223 } 229 224 230 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {231 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );232 }233 234 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}235 236 OffsetPackExpr::~OffsetPackExpr() { delete type; }237 238 void OffsetPackExpr::print( std::ostream &os, int indent ) const {239 os << std::string( indent, ' ' ) << "Offset pack expression on ";240 241 if ( type ) {242 type->print(os, indent + 2);243 } else {244 os << "<NULL>";245 }246 247 os << std::endl;248 Expression::print( os, indent );249 }250 251 225 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) : 252 226 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) { … … 300 274 301 275 void CastExpr::print( std::ostream &os, int indent ) const { 302 os << "Cast of:" << std::endl << std::string( indent+2, ' ' );276 os << std::string( indent, ' ' ) << "Cast of:" << std::endl; 303 277 arg->print(os, indent+2); 304 278 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; … … 323 297 324 298 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 325 os << "UntypedMember Expression, with field: " << get_member();299 os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member(); 326 300 327 301 Expression *agg = get_aggregate(); 328 os << ", from aggregate: "; 329 if (agg != 0) { 330 os << std::string( indent + 2, ' ' ); 331 agg->print(os, indent + 2); 332 } 333 os << std::string( indent+2, ' ' ); 302 os << std::string( indent, ' ' ) << "from aggregate: "; 303 if (agg != 0) agg->print(os, indent + 2); 334 304 Expression::print( os, indent ); 335 305 } … … 354 324 355 325 void MemberExpr::print( std::ostream &os, int indent ) const { 356 os << "Member Expression, with field: " << std::endl;326 os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl; 357 327 358 328 assert( member ); … … 363 333 Expression *agg = get_aggregate(); 364 334 os << std::string( indent, ' ' ) << "from aggregate: " << std::endl; 365 if (agg != 0) { 366 os << std::string( indent + 2, ' ' ); 367 agg->print(os, indent + 2); 368 } 369 os << std::string( indent+2, ' ' ); 335 if (agg != 0) agg->print(os, indent + 2); 370 336 Expression::print( os, indent ); 371 337 } … … 385 351 386 352 void UntypedExpr::print( std::ostream &os, int indent ) const { 387 os << "Applying untyped: " << std::endl; 388 os << std::string( indent+2, ' ' ); 389 function->print(os, indent + 2); 353 os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl; 354 function->print(os, indent + 4); 390 355 os << std::string( indent, ' ' ) << "...to: " << std::endl; 391 printA ll(args, os, indent + 2);356 printArgs(os, indent + 4); 392 357 Expression::print( os, indent ); 393 358 } … … 395 360 void UntypedExpr::printArgs( std::ostream &os, int indent ) const { 396 361 std::list<Expression *>::const_iterator i; 397 for (i = args.begin(); i != args.end(); i++) { 398 os << std::string(indent, ' ' ); 362 for (i = args.begin(); i != args.end(); i++) 399 363 (*i)->print(os, indent); 400 }401 364 } 402 365 … … 409 372 410 373 void NameExpr::print( std::ostream &os, int indent ) const { 411 os << "Name: " << get_name() << std::endl;374 os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl; 412 375 Expression::print( os, indent ); 413 376 } … … 470 433 } 471 434 472 473 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {474 assert( callExpr );475 cloneAll( callExpr->get_results(), results );476 }477 478 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {479 cloneAll( other.tempDecls, tempDecls );480 cloneAll( other.returnDecls, returnDecls );481 cloneAll( other.dtors, dtors );482 }483 484 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {485 delete callExpr;486 deleteAll( tempDecls );487 deleteAll( returnDecls );488 deleteAll( dtors );489 }490 491 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {492 os << std::string( indent, ' ' ) << "Implicit Copy Constructor Expression: " << std::endl;493 assert( callExpr );494 callExpr->print( os, indent + 2 );495 os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;496 printAll(tempDecls, os, indent+2);497 os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;498 printAll(returnDecls, os, indent+2);499 Expression::print( os, indent );500 }501 502 435 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 503 436
Note:
See TracChangeset
for help on using the changeset viewer.