Changeset c957e7f


Ignore:
Timestamp:
May 22, 2019, 5:58:56 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0b57626, b0ec971
Parents:
489bacf
Message:

Added initializer printers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    r489bacf rc957e7f  
    2222#include "TypeSubstitution.hpp"
    2323
     24#include "Common/utility.h"      // for group_iterate
    2425
    2526namespace ast {
     
    475476
    476477        virtual const ast::Designation *      visit( const ast::Designation          * node ) {
     478                if ( node->designators.empty() ) return node;
     479                os << "... designated by: " << std::endl;
     480                ++indent;
     481                for ( const ast::Expr * d : node->designators ) {
     482                        os << indent;
     483                        d->accept( *this );
     484                        os << std::endl;
     485                }
     486                --indent;
    477487                return node;
    478488        }
    479489
    480490        virtual const ast::Init *             visit( const ast::SingleInit           * node ) {
     491                os << "Simple Initializer: ";
     492                node->value->accept( *this );
    481493                return node;
    482494        }
    483495
    484496        virtual const ast::Init *             visit( const ast::ListInit             * node ) {
     497                os << "Compound initializer: " << std::endl;
     498                ++indent;
     499                for ( auto p : group_iterate( node->designations, node->initializers ) ) {
     500                        const ast::Designation * d = std::get<0>(p);
     501                        const ast::Init * init = std::get<1>(p);
     502                        os << indent;
     503                        init->accept( *this );
     504                        os << std::endl;
     505                        if ( ! d->designators.empty() ) {
     506                                os << indent;
     507                                d->accept( *this );
     508                        }
     509                }
     510                --indent;
    485511                return node;
    486512        }
    487513
    488514        virtual const ast::Init *             visit( const ast::ConstructorInit      * node ) {
     515                os << "Constructor initializer: " << std::endl;
     516                if ( node->ctor ) {
     517                        os << indent << "... initially constructed with ";
     518                        ++indent;
     519                        node->ctor->accept( *this );
     520                        --indent;
     521                }
     522
     523                if ( node->dtor ) {
     524                        os << indent << "... destructed with ";
     525                        ++indent;
     526                        node->dtor->accept( *this );
     527                        --indent;
     528                }
     529
     530                if ( node->init ) {
     531                        os << indent << "... with fallback C-style initializer: ";
     532                        ++indent;
     533                        node->init->accept( *this );
     534                        --indent;
     535                }
    489536                return node;
    490537        }
Note: See TracChangeset for help on using the changeset viewer.