Changeset 77971f6 for src/SynTree


Ignore:
Timestamp:
Oct 27, 2016, 3:24:02 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
3f0c6a5
Parents:
a1e67dd
git-author:
Rob Schluntz <rschlunt@…> (10/27/16 15:11:00)
git-committer:
Rob Schluntz <rschlunt@…> (10/27/16 15:24:02)
Message:

resolve ctor/dtors for UniqueExprs?

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    ra1e67dd r77971f6  
    581581
    582582long long UniqueExpr::count = 0;
    583 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), id( idVal ) {
     583UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), object( new ObjectDecl* ), id( idVal ) {
    584584        assert( count != -1 );
    585585        if ( id == -1 ) id = count++;
     
    589589                set_result( expr->get_result()->clone() );
    590590        }
    591 }
    592 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), id( other.id ) {
     591        set_object( nullptr );
     592}
     593UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), object( other.object ), id( other.id ) {
    593594}
    594595UniqueExpr::~UniqueExpr() {
     
    596597                delete *expr;
    597598        }
     599        if ( object.unique() ) {
     600                delete *object;
     601        }
    598602}
    599603void UniqueExpr::print( std::ostream &os, int indent ) const {
    600604        os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' );
    601605        get_expr()->print( os, indent+2 );
     606        if ( get_object() ) {
     607                os << " with decl: ";
     608                get_object()->printShort( os, indent+2 );
     609        }
    602610}
    603611
  • src/SynTree/Expression.h

    ra1e67dd r77971f6  
    742742        UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; }
    743743
     744        ObjectDecl * get_object() const { return *object; }
     745        UniqueExpr * set_object( ObjectDecl * newValue ) { *object = newValue; return this; }
     746
    744747        int get_id() const { return id; }
    745748
     
    750753private:
    751754        std::shared_ptr< Expression * > expr;
     755        std::shared_ptr< ObjectDecl * > object;
    752756        int id;
    753757        static long long count;
Note: See TracChangeset for help on using the changeset viewer.