Changeset 8f98b78 for src/ResolvExpr


Ignore:
Timestamp:
Sep 19, 2017, 3:55:54 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
764e009
Parents:
695e00d
Message:

Now properly resolve the calls to get_monitor

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r695e00d r8f98b78  
    118118        }
    119119
     120        Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
     121                TypeEnvironment env;
     122                AlternativeFinder finder( indexer, env );
     123                finder.find( untyped );
     124                #if 0
     125                if ( finder.get_alternatives().size() != 1 ) {
     126                        std::cout << "untyped expr is ";
     127                        untyped->print( std::cout );
     128                        std::cout << std::endl << "alternatives are:";
     129                        for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
     130                                i->print( std::cout );
     131                        } // for
     132                } // if
     133                #endif
     134                assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." );
     135                Alternative &choice = finder.get_alternatives().front();
     136                Expression *newExpr = choice.expr->clone();
     137                finishExpr( newExpr, choice.env );
     138                return newExpr;
     139        }
     140
    120141        namespace {
    121                 Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) {
    122                         TypeEnvironment env;
    123                         AlternativeFinder finder( indexer, env );
    124                         finder.find( untyped );
    125 #if 0
    126                         if ( finder.get_alternatives().size() != 1 ) {
    127                                 std::cout << "untyped expr is ";
    128                                 untyped->print( std::cout );
    129                                 std::cout << std::endl << "alternatives are:";
    130                                 for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    131                                         i->print( std::cout );
    132                                 } // for
    133                         } // if
    134 #endif
    135                         assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end." );
    136                         Alternative &choice = finder.get_alternatives().front();
    137                         Expression *newExpr = choice.expr->clone();
    138                         finishExpr( newExpr, choice.env );
    139                         return newExpr;
    140                 }
    141 
    142142                bool isIntegralType( Type *type ) {
    143143                        if ( dynamic_cast< EnumInstType * >( type ) ) {
     
    393393        }
    394394
    395         inline void resolveAsIf( Expression *& expr, Resolver & resolver ) {
     395        inline void resolveAsIf( Expression *& expr, SymTab::Indexer & indexer ) {
    396396                if( !expr ) return;
    397                 Expression * newExpr = findSingleExpression( expr, resolver );
     397                Expression * newExpr = findSingleExpression( expr, indexer );
    398398                delete expr;
    399399                expr = newExpr;
    400400        }
    401401
    402         inline void resolveAsType( Expression *& expr, Type * type, Resolver & resolver ) {
     402        inline void resolveAsType( Expression *& expr, Type * type, SymTab::Indexer & indexer ) {
    403403                if( !expr ) return;
    404                 Expression * newExpr = findSingleExpression( new CastExpr( expr, type ), resolver );
     404                Expression * newExpr = findSingleExpression( new CastExpr( expr, type ), indexer );
    405405                delete expr;
    406406                expr = newExpr;
     
    417417
    418418        void Resolver::previsit( WaitForStmt * stmt ) {
     419                visit_children = false;
    419420
    420421                // Resolve all clauses first
     
    422423
    423424                        TypeEnvironment env;
    424                         AlternativeFinder funcFinder( *this, env );
     425                        AlternativeFinder funcFinder( indexer, env );
    425426
    426427                        // Find all alternatives for a function in canonical form
     
    511512
    512513                                                                // Check if the argument matches the parameter type in the current scope
    513                                                                 if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, *this ) ) {
     514                                                                if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) {
    514515                                                                        // Type doesn't match
    515516                                                                        stringstream ss;
     
    573574                        // Resolve the conditions as if it were an IfStmt
    574575                        // Resolve the statments normally
    575                         resolveAsIf( clause.condition, *this );
    576                         clause.statement->accept( *this );
     576                        resolveAsIf( clause.condition, this->indexer );
     577                        clause.statement->accept( *visitor );
    577578                }
    578579
     
    582583                        // Resolve the conditions as if it were an IfStmt
    583584                        // Resolve the statments normally
    584                         resolveAsType( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), *this );
    585                         resolveAsIf  ( stmt->timeout.condition, *this );
    586                         stmt->timeout.statement->accept( *this );
     585                        resolveAsType( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), this->indexer );
     586                        resolveAsIf  ( stmt->timeout.condition, this->indexer );
     587                        stmt->timeout.statement->accept( *visitor );
    587588                }
    588589
     
    590591                        // Resolve the conditions as if it were an IfStmt
    591592                        // Resolve the statments normally
    592                         resolveAsIf( stmt->orelse.condition, *this );
    593                         stmt->orelse.statement->accept( *this );
     593                        resolveAsIf( stmt->orelse.condition, this->indexer );
     594                        stmt->orelse.statement->accept( *visitor );
    594595                }
    595596        }
  • src/ResolvExpr/Resolver.h

    r695e00d r8f98b78  
    2929        /// Checks types and binds syntactic constructs to typed representations
    3030        void resolve( std::list< Declaration * > translationUnit );
    31         Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
    32         Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
     31        Expression * resolveInVoidContext( Expression *expr   , const SymTab::Indexer &indexer );
     32        Expression * findVoidExpression  ( Expression *untyped, const SymTab::Indexer &indexer );
     33        Expression * findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer );
    3334        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    3435        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
Note: See TracChangeset for help on using the changeset viewer.