Changeset fbcde64 for src/SynTree


Ignore:
Timestamp:
Mar 30, 2017, 5:21:07 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
936a287
Parents:
89ae7f4
Message:

remove duplication in compound literal, support aggregate-type compound literals

Location:
src/SynTree
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r89ae7f4 rfbcde64  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:42:04 2017
    13 // Update Count     : 51
     12// Last Modified On : Thu Mar 30 16:41:13 2017
     13// Update Count     : 52
    1414//
    1515
     
    571571
    572572
    573 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     573CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    574574        assert( type && initializer );
    575         set_result( type->clone() );
    576 }
    577 
    578 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {}
     575        set_result( type );
     576}
     577
     578CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    579579
    580580CompoundLiteralExpr::~CompoundLiteralExpr() {
    581581        delete initializer;
    582         delete type;
    583582}
    584583
     
    586585        os << "Compound Literal Expression: " << std::endl;
    587586        os << std::string( indent+2, ' ' );
    588         type->print( os, indent + 2 );
     587        get_result()->print( os, indent + 2 );
    589588        os << std::string( indent+2, ' ' );
    590589        initializer->print( os, indent + 2 );
  • src/SynTree/Expression.h

    r89ae7f4 rfbcde64  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jan 14 14:37:54 2017
    13 // Update Count     : 37
     12// Last Modified On : Thu Mar 30 16:44:00 2017
     13// Update Count     : 41
    1414//
    1515
     
    3535
    3636        Type *& get_result() { return result; }
     37        const Type * get_result() const { return result; }
    3738        void set_result( Type * newValue ) { result = newValue; }
    3839        bool has_result() const { return result != nullptr; }
     
    586587        virtual ~CompoundLiteralExpr();
    587588
    588         Type * get_type() const { return type; }
    589         void set_type( Type * t ) { type = t; }
    590 
    591589        Initializer * get_initializer() const { return initializer; }
    592590        void set_initializer( Initializer * i ) { initializer = i; }
     
    597595        virtual void print( std::ostream & os, int indent = 0 ) const;
    598596  private:
    599         Type * type;
    600597        Initializer * initializer;
    601598};
  • src/SynTree/Mutator.cc

    r89ae7f4 rfbcde64  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:02:23 2017
    13 // Update Count     : 21
     12// Last Modified On : Thu Mar 30 16:45:19 2017
     13// Update Count     : 22
    1414//
    1515
     
    369369        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
    370370        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
    371         compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) );
    372371        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
    373372        return compLitExpr;
  • src/SynTree/Visitor.cc

    r89ae7f4 rfbcde64  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:01:25 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 30 16:45:25 2017
     13// Update Count     : 24
    1414//
    1515
     
    292292void Visitor::visit( CompoundLiteralExpr *compLitExpr ) {
    293293        maybeAccept( compLitExpr->get_result(), *this );
    294         maybeAccept( compLitExpr->get_type(), *this );
    295294        maybeAccept( compLitExpr->get_initializer(), *this );
    296295}
Note: See TracChangeset for help on using the changeset viewer.