Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r954c954 r7ff3e522  
    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()
    4140#include "Common/utility.h"              // for ValueGuard, group_iterate
    4241#include "InitTweak/GenInit.h"
     
    966965                /// Finds deleted expressions in an expression tree
    967966                struct DeleteFinder_new final : public ast::WithShortCircuiting {
    968                         const ast::DeletedExpr * result = nullptr;
     967                        const ast::DeletedExpr * delExpr = nullptr;
    969968
    970969                        void previsit( const ast::DeletedExpr * expr ) {
    971                                 if ( result ) { visit_children = false; }
    972                                 else { result = expr; }
     970                                if ( delExpr ) { visit_children = false; }
     971                                else { delExpr = expr; }
    973972                        }
    974973
    975974                        void previsit( const ast::Expr * ) {
    976                                 if ( result ) { visit_children = false; }
     975                                if ( delExpr ) { visit_children = false; }
    977976                        }
    978977                };
     
    981980        /// Check if this expression is or includes a deleted expression
    982981        const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) {
    983                 return ast::Pass<DeleteFinder_new>::read( expr );
     982                ast::Pass<DeleteFinder_new> finder;
     983                expr->accept( finder );
     984                return finder.core.delExpr;
    984985        }
    985986
     
    11701171                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11711172                ) {
    1172                         Stats::ResolveTime::start( untyped );
    1173                         auto res = findKindExpression( untyped, symtab );
    1174                         Stats::ResolveTime::stop();
    1175                         return res;
     1173                        return findKindExpression( untyped, symtab );
    11761174                }
    11771175        } // anonymous namespace
     
    12231221                template<typename Iter>
    12241222                inline bool nextMutex( Iter & it, const Iter & end ) {
    1225                         while ( it != end && ! (*it)->is_mutex() ) { ++it; }
     1223                        while ( it != end && ! (*it)->get_type()->is_mutex() ) { ++it; }
    12261224                        return it != end;
    12271225                }
     
    12631261                const ast::ThrowStmt *       previsit( const ast::ThrowStmt * );
    12641262                const ast::CatchStmt *       previsit( const ast::CatchStmt * );
    1265                 const ast::CatchStmt *       postvisit( const ast::CatchStmt * );
    12661263                const ast::WaitForStmt *     previsit( const ast::WaitForStmt * );
    12671264
     
    14961493
    14971494        const ast::CatchStmt * Resolver_new::previsit( const ast::CatchStmt * catchStmt ) {
    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.
     1495                // TODO: This will need a fix for the decl/cond scoping problem.
    15041496                if ( catchStmt->cond ) {
    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;
     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 ) );
    15241501                }
    15251502                return catchStmt;
     
    16381615                                                                // Check if the argument matches the parameter type in the current
    16391616                                                                // scope
    1640                                                                 // ast::ptr< ast::Type > paramType = (*param)->get_type();
     1617                                                                ast::ptr< ast::Type > paramType = (*param)->get_type();
    16411618                                                                if (
    16421619                                                                        ! unify(
    1643                                                                                 arg->expr->result, *param, resultEnv, need, have, open,
     1620                                                                                arg->expr->result, paramType, resultEnv, need, have, open,
    16441621                                                                                symtab )
    16451622                                                                ) {
     
    16481625                                                                        ss << "candidate function not viable: no known conversion "
    16491626                                                                                "from '";
    1650                                                                         ast::print( ss, *param );
     1627                                                                        ast::print( ss, (*param)->get_type() );
    16511628                                                                        ss << "' to '";
    16521629                                                                        ast::print( ss, arg->expr->result );
Note: See TracChangeset for help on using the changeset viewer.