Changeset 5e2c348 for src/SynTree


Ignore:
Timestamp:
Jan 31, 2018, 11:53:24 AM (7 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:
2cb70aa
Parents:
5a73f0f
Message:

Assign a result type to StmtExpr? after resolution [fixes #79]

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r5a73f0f r5e2c348  
    597597
    598598StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
     599        computeResult();
     600}
     601StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
     602        cloneAll( other.returnDecls, returnDecls );
     603        cloneAll( other.dtors, dtors );
     604}
     605StmtExpr::~StmtExpr() {
     606        delete statements;
     607        deleteAll( dtors );
     608        deleteAll( returnDecls );
     609}
     610void StmtExpr::computeResult() {
    599611        assert( statements );
    600         std::list< Statement * > & body = statements->get_kids();
     612        std::list< Statement * > & body = statements->kids;
     613        delete result;
     614        result = nullptr;
    601615        if ( ! body.empty() ) {
    602616                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) {
     
    608622                result = new VoidType( Type::Qualifiers() );
    609623        }
    610 }
    611 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
    612         cloneAll( other.returnDecls, returnDecls );
    613         cloneAll( other.dtors, dtors );
    614 }
    615 StmtExpr::~StmtExpr() {
    616         delete statements;
    617         deleteAll( dtors );
    618         deleteAll( returnDecls );
    619624}
    620625void StmtExpr::print( std::ostream &os, Indenter indent ) const {
  • src/SynTree/Expression.h

    r5a73f0f r5e2c348  
    728728        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
    729729
     730        // call to set the result type of this StmtExpr based on its body
     731        void computeResult();
     732
    730733        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    731734        std::list< Expression * > & get_dtors() { return dtors; }
Note: See TracChangeset for help on using the changeset viewer.