Changeset 7a80113 for src/ResolvExpr


Ignore:
Timestamp:
Sep 22, 2020, 11:29:12 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
0a945fd
Parents:
1c507eb (diff), 08f3ad3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/ResolvExpr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r1c507eb r7a80113  
    816816                /// Adds aggregate member interpretations
    817817                void addAggMembers(
    818                         const ast::ReferenceToType * aggrInst, const ast::Expr * expr,
     818                        const ast::BaseInstType * aggrInst, const ast::Expr * expr,
    819819                        const Candidate & cand, const Cost & addedCost, const std::string & name
    820820                ) {
     
    12631263
    12641264                void postvisit( const ast::UntypedOffsetofExpr * offsetofExpr ) {
    1265                         const ast::ReferenceToType * aggInst;
     1265                        const ast::BaseInstType * aggInst;
    12661266                        if (( aggInst = offsetofExpr->type.as< ast::StructInstType >() )) ;
    12671267                        else if (( aggInst = offsetofExpr->type.as< ast::UnionInstType >() )) ;
  • src/ResolvExpr/ConversionCost.cc

    r1c507eb r7a80113  
    520520                return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable );
    521521        } else {
    522                 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost );
    523                 src->accept( converter );
    524                 return converter.core.cost;
     522                return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
    525523        }
    526524}
     
    563561                        }
    564562                } else {
    565                         ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost );
    566                         src->accept( converter );
    567                         return converter.core.cost;
     563                        return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
    568564                }
    569565        } else {
  • src/ResolvExpr/ConversionCost.h

    r1c507eb r7a80113  
    8888        static size_t traceId;
    8989        Cost cost;
     90        Cost result() { return cost; }
    9091
    9192        ConversionCost_new( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab,
  • src/ResolvExpr/CurrentObject.cc

    r1c507eb r7a80113  
    923923
    924924        MemberIterator * createMemberIterator( const CodeLocation & loc, const Type * type ) {
    925                 if ( auto aggr = dynamic_cast< const ReferenceToType * >( type ) ) {
     925                if ( auto aggr = dynamic_cast< const BaseInstType * >( type ) ) {
    926926                        if ( auto sit = dynamic_cast< const StructInstType * >( aggr ) ) {
    927927                                return new StructIterator{ loc, sit };
     
    932932                                        dynamic_cast< const EnumInstType * >( type )
    933933                                                || dynamic_cast< const TypeInstType * >( type ),
    934                                         "Encountered unhandled ReferenceToType in createMemberIterator: %s",
     934                                        "Encountered unhandled BaseInstType in createMemberIterator: %s",
    935935                                                toString( type ).c_str() );
    936936                                return new SimpleIterator{ loc, type };
     
    965965                                        DesignatorChain & d = *dit;
    966966                                        PRINT( std::cerr << "____actual: " << t << std::endl; )
    967                                         if ( auto refType = dynamic_cast< const ReferenceToType * >( t ) ) {
     967                                        if ( auto refType = dynamic_cast< const BaseInstType * >( t ) ) {
    968968                                                // concatenate identical field names
    969969                                                for ( const Decl * mem : refType->lookup( nexpr->name ) ) {
  • src/ResolvExpr/Resolver.cc

    r1c507eb r7a80113  
    3838#include "Common/PassVisitor.h"          // for PassVisitor
    3939#include "Common/SemanticError.h"        // for SemanticError
     40#include "Common/Stats/ResolveTime.h"    // for ResolveTime::start(), ResolveTime::stop()
    4041#include "Common/utility.h"              // for ValueGuard, group_iterate
    4142#include "InitTweak/GenInit.h"
     
    965966                /// Finds deleted expressions in an expression tree
    966967                struct DeleteFinder_new final : public ast::WithShortCircuiting {
    967                         const ast::DeletedExpr * delExpr = nullptr;
     968                        const ast::DeletedExpr * result = nullptr;
    968969
    969970                        void previsit( const ast::DeletedExpr * expr ) {
    970                                 if ( delExpr ) { visit_children = false; }
    971                                 else { delExpr = expr; }
     971                                if ( result ) { visit_children = false; }
     972                                else { result = expr; }
    972973                        }
    973974
    974975                        void previsit( const ast::Expr * ) {
    975                                 if ( delExpr ) { visit_children = false; }
     976                                if ( result ) { visit_children = false; }
    976977                        }
    977978                };
     
    980981        /// Check if this expression is or includes a deleted expression
    981982        const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) {
    982                 ast::Pass<DeleteFinder_new> finder;
    983                 expr->accept( finder );
    984                 return finder.core.delExpr;
     983                return ast::Pass<DeleteFinder_new>::read( expr );
    985984        }
    986985
     
    11711170                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11721171                ) {
    1173                         return findKindExpression( untyped, symtab );
     1172                        Stats::ResolveTime::start( untyped );
     1173                        auto res = findKindExpression( untyped, symtab );
     1174                        Stats::ResolveTime::stop();
     1175                        return res;
    11741176                }
    11751177        } // anonymous namespace
     
    12611263                const ast::ThrowStmt *       previsit( const ast::ThrowStmt * );
    12621264                const ast::CatchStmt *       previsit( const ast::CatchStmt * );
     1265                const ast::CatchStmt *       postvisit( const ast::CatchStmt * );
    12631266                const ast::WaitForStmt *     previsit( const ast::WaitForStmt * );
    12641267
     
    14931496
    14941497        const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) {
    1495                 // TODO: This will need a fix for the decl/cond scoping problem.
     1498                // Until we are very sure this invarent (ifs that move between passes have thenPart)
     1499                // holds, check it. This allows a check for when to decode the mangling.
     1500                if ( auto ifStmt = catchStmt->body.as<ast::IfStmt>() ) {
     1501                        assert( ifStmt->thenPart );
     1502                }
     1503                // Encode the catchStmt so the condition can see the declaration.
    14961504                if ( catchStmt->cond ) {
    1497                         ast::ptr< ast::Type > boolType = new ast::BasicType{ ast::BasicType::Bool };
    1498                         catchStmt = ast::mutate_field(
    1499                                 catchStmt, &ast::CatchStmt::cond,
    1500                                 findSingleExpression( catchStmt->cond, boolType, symtab ) );
     1505                        ast::CatchStmt * stmt = mutate( catchStmt );
     1506                        stmt->body = new ast::IfStmt( stmt->location, stmt->cond, nullptr, stmt->body );
     1507                        stmt->cond = nullptr;
     1508                        return stmt;
     1509                }
     1510                return catchStmt;
     1511        }
     1512
     1513        const ast::CatchStmt * Resolver_new::postvisit( const ast::CatchStmt * catchStmt ) {
     1514                // Decode the catchStmt so everything is stored properly.
     1515                const ast::IfStmt * ifStmt = catchStmt->body.as<ast::IfStmt>();
     1516                if ( nullptr != ifStmt && nullptr == ifStmt->thenPart ) {
     1517                        assert( ifStmt->cond );
     1518                        assert( ifStmt->elsePart );
     1519                        ast::CatchStmt * stmt = ast::mutate( catchStmt );
     1520                        stmt->cond = ifStmt->cond;
     1521                        stmt->body = ifStmt->elsePart;
     1522                        // ifStmt should be implicately deleted here.
     1523                        return stmt;
    15011524                }
    15021525                return catchStmt;
Note: See TracChangeset for help on using the changeset viewer.