Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r630a82a rbb8ea30  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 17:16:23 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri May 13 13:19:09 2016
    1313// Update Count     : 40
    1414//
     
    7272
    7373void ConstantExpr::print( std::ostream &os, int indent ) const {
    74         os << std::string( indent, ' ' ) << "constant expression " ;
     74        os << "constant expression " ;
    7575        constant.print( os );
    7676        Expression::print( os, indent );
    77         os << std::endl;
    7877}
    7978
     
    9392
    9493void VariableExpr::print( std::ostream &os, int indent ) const {
    95         os << std::string( indent, ' ' ) << "Variable Expression: ";
     94        os << "Variable Expression: ";
    9695
    9796        Declaration *decl = get_var();
     
    122121
    123122void SizeofExpr::print( std::ostream &os, int indent) const {
    124         os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
     123        os << "Sizeof Expression on: ";
    125124
    126125        if (isType)
     
    212211
    213212        os << " of ";
     213
     214        if ( type ) {
     215                type->print(os, indent + 2);
     216        } else {
     217                os << "<NULL>";
     218        }
     219
     220        os << std::endl;
     221        Expression::print( os, indent );
     222}
     223
     224OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
     225        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     226}
     227
     228OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     229
     230OffsetPackExpr::~OffsetPackExpr() { delete type; }
     231
     232void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     233        os << std::string( indent, ' ' ) << "Offset pack expression on ";
    214234
    215235        if ( type ) {
     
    274294
    275295void CastExpr::print( std::ostream &os, int indent ) const {
    276         os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
     296        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
    277297        arg->print(os, indent+2);
    278298        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     
    297317
    298318void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    299         os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
     319        os << "Untyped Member Expression, with field: " << get_member();
    300320
    301321        Expression *agg = get_aggregate();
    302         os << std::string( indent, ' ' ) << "from aggregate: ";
    303         if (agg != 0) agg->print(os, indent + 2);
     322        os << ", from aggregate: ";
     323        if (agg != 0) {
     324                os << std::string( indent + 2, ' ' );
     325                agg->print(os, indent + 2);
     326        }
     327        os << std::string( indent+2, ' ' );
    304328        Expression::print( os, indent );
    305329}
     
    324348
    325349void MemberExpr::print( std::ostream &os, int indent ) const {
    326         os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
     350        os << "Member Expression, with field: " << std::endl;
    327351
    328352        assert( member );
     
    333357        Expression *agg = get_aggregate();
    334358        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
    335         if (agg != 0) agg->print(os, indent + 2);
     359        if (agg != 0) {
     360                os << std::string( indent + 2, ' ' );
     361                agg->print(os, indent + 2);
     362        }
     363        os << std::string( indent+2, ' ' );
    336364        Expression::print( os, indent );
    337365}
     
    351379
    352380void UntypedExpr::print( std::ostream &os, int indent ) const {
    353         os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
    354         function->print(os, indent + 4);
     381        os << "Applying untyped: " << std::endl;
     382        os << std::string( indent+2, ' ' );
     383        function->print(os, indent + 2);
    355384        os << std::string( indent, ' ' ) << "...to: " << std::endl;
    356         printArgs(os, indent + 4);
     385        printAll(args, os, indent + 2);
    357386        Expression::print( os, indent );
    358387}
     
    360389void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
    361390        std::list<Expression *>::const_iterator i;
    362         for (i = args.begin(); i != args.end(); i++)
     391        for (i = args.begin(); i != args.end(); i++) {
     392                os << std::string(indent, ' ' );
    363393                (*i)->print(os, indent);
     394        }
    364395}
    365396
     
    372403
    373404void NameExpr::print( std::ostream &os, int indent ) const {
    374         os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
     405        os << "Name: " << get_name() << std::endl;
    375406        Expression::print( os, indent );
    376407}
Note: See TracChangeset for help on using the changeset viewer.