Ignore:
Timestamp:
Jun 20, 2017, 1:19:53 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
579263a
Parents:
c6d2e93
git-author:
Rob Schluntz <rschlunt@…> (06/20/17 13:16:13)
git-committer:
Rob Schluntz <rschlunt@…> (06/20/17 13:19:53)
Message:

major effort on designations, works in many cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rc6d2e93 re4d829b  
    9292
    9393        Declaration *decl = get_var();
    94         // if ( decl != 0) decl->print(os, indent + 2);
    9594        if ( decl != 0) decl->printShort(os, indent + 2);
    9695        os << std::endl;
     
    670669}
    671670
     671InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
     672InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
     673InitAlternative::~InitAlternative() {
     674        delete type;
     675        delete designation;
     676}
     677
     678UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
     679UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
     680UntypedInitExpr::~UntypedInitExpr() {
     681        delete expr;
     682}
     683
     684void UntypedInitExpr::print( std::ostream & os, int indent ) const {
     685        os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );
     686        expr->print( os, indent+2 );
     687        if ( ! initAlts.empty() ) {
     688                for ( const InitAlternative & alt : initAlts ) {
     689                        os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
     690                        alt.type->print( os, indent+2 );
     691                        alt.designation->print( os, indent+2 );
     692                }
     693        }
     694}
     695
     696InitExpr::InitExpr( Expression * expr, Type * type, Designation * designation ) : expr( expr ), designation( designation ) {
     697        set_result( type );
     698}
     699InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
     700InitExpr::~InitExpr() {
     701        delete expr;
     702        delete designation;
     703}
     704
     705void InitExpr::print( std::ostream & os, int indent ) const {
     706        os << "Init Expression" << std::endl << std::string( indent+2, ' ' );
     707        expr->print( os, indent+2 );
     708        os << std::string( indent+2, ' ' ) << "with designation: ";
     709        designation->print( os, indent+2 );
     710}
     711
     712
    672713std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    673714        if ( expr ) {
Note: See TracChangeset for help on using the changeset viewer.