Ignore:
Timestamp:
May 24, 2019, 10:19:41 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d908563
Parents:
6a9d4b4 (diff), 292642a (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' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r6a9d4b4 r933f32f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Fri Oct 05 09:43:00 2018
    13 // Update Count     : 214
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Feb 19 18:09:56 2019
     13// Update Count     : 240
    1414//
    1515
     
    5454                }
    5555
    56                 void previsit( FunctionDecl *functionDecl );
    57                 void postvisit( FunctionDecl *functionDecl );
    58                 void previsit( ObjectDecl *objectDecll );
     56                void previsit( FunctionDecl * functionDecl );
     57                void postvisit( FunctionDecl * functionDecl );
     58                void previsit( ObjectDecl * objectDecll );
    5959                void previsit( EnumDecl * enumDecl );
    6060                void previsit( StaticAssertDecl * assertDecl );
     
    6363                void previsit( PointerType * at );
    6464
    65                 void previsit( ExprStmt *exprStmt );
    66                 void previsit( AsmExpr *asmExpr );
    67                 void previsit( AsmStmt *asmStmt );
    68                 void previsit( IfStmt *ifStmt );
    69                 void previsit( WhileStmt *whileStmt );
    70                 void previsit( ForStmt *forStmt );
    71                 void previsit( SwitchStmt *switchStmt );
    72                 void previsit( CaseStmt *caseStmt );
    73                 void previsit( BranchStmt *branchStmt );
    74                 void previsit( ReturnStmt *returnStmt );
    75                 void previsit( ThrowStmt *throwStmt );
    76                 void previsit( CatchStmt *catchStmt );
     65                void previsit( ExprStmt * exprStmt );
     66                void previsit( AsmExpr * asmExpr );
     67                void previsit( AsmStmt * asmStmt );
     68                void previsit( IfStmt * ifStmt );
     69                void previsit( WhileStmt * whileStmt );
     70                void previsit( ForStmt * forStmt );
     71                void previsit( SwitchStmt * switchStmt );
     72                void previsit( CaseStmt * caseStmt );
     73                void previsit( BranchStmt * branchStmt );
     74                void previsit( ReturnStmt * returnStmt );
     75                void previsit( ThrowStmt * throwStmt );
     76                void previsit( CatchStmt * catchStmt );
    7777                void previsit( WaitForStmt * stmt );
    7878
    79                 void previsit( SingleInit *singleInit );
    80                 void previsit( ListInit *listInit );
    81                 void previsit( ConstructorInit *ctorInit );
     79                void previsit( SingleInit * singleInit );
     80                void previsit( ListInit * listInit );
     81                void previsit( ConstructorInit * ctorInit );
    8282          private:
    8383                typedef std::list< Initializer * >::iterator InitIterator;
     
    105105        }
    106106
    107         void resolveDecl( Declaration * decl, const SymTab::Indexer &indexer ) {
     107        void resolveDecl( Declaration * decl, const SymTab::Indexer & indexer ) {
    108108                PassVisitor<Resolver> resolver( indexer );
    109109                maybeAccept( decl, resolver );
     
    149149                };
    150150
    151                 void finishExpr( Expression *&expr, const TypeEnvironment &env, TypeSubstitution * oldenv = nullptr ) {
     151                void finishExpr( Expression *& expr, const TypeEnvironment & env, TypeSubstitution * oldenv = nullptr ) {
    152152                        expr->env = oldenv ? oldenv->clone() : new TypeSubstitution;
    153153                        env.makeSubstitution( *expr->env );
     
    280280
    281281        // used in resolveTypeof
    282         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
     282        Expression * resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer ) {
    283283                TypeEnvironment env;
    284284                return resolveInVoidContext( expr, indexer, env );
    285285        }
    286286
    287         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ) {
     287        Expression * resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer, TypeEnvironment & env ) {
    288288                // it's a property of the language that a cast expression has either 1 or 0 interpretations; if it has 0
    289289                // interpretations, an exception has already been thrown.
    290290                assertf( expr, "expected a non-null expression." );
    291291
    292                 static CastExpr untyped( nullptr ); // cast to void
    293                 untyped.location = expr->location;
     292                CastExpr * untyped = new CastExpr( expr ); // cast to void
     293                untyped->location = expr->location;
    294294
    295295                // set up and resolve expression cast to void
    296                 untyped.arg = expr;
    297296                Alternative choice;
    298                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() );
     297                findUnfinishedKindExpression( untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() );
    299298                CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
     299                assert( castExpr );
    300300                env = std::move( choice.env );
    301301
     
    305305
    306306                // unlink the arg so that it isn't deleted twice at the end of the program
    307                 untyped.arg = nullptr;
     307                untyped->arg = nullptr;
    308308                return ret;
    309309        }
    310310
    311         void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
     311        void findVoidExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    312312                resetTyVarRenaming();
    313313                TypeEnvironment env;
     
    318318        }
    319319
    320         void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) {
     320        void findSingleExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    321321                findKindExpression( untyped, indexer, "", standardAlternativeFilter );
    322322        }
     
    337337                        if ( dynamic_cast< EnumInstType * >( type ) ) {
    338338                                return true;
    339                         } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) {
     339                        } else if ( BasicType * bt = dynamic_cast< BasicType * >( type ) ) {
    340340                                return bt->isInteger();
    341341                        } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) {
     
    346346                }
    347347
    348                 void findIntegralExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
     348                void findIntegralExpression( Expression *& untyped, const SymTab::Indexer & indexer ) {
    349349                        findKindExpression( untyped, indexer, "condition", isIntegralType );
    350350                }
     
    402402        }
    403403
    404         void Resolver::previsit( ObjectDecl *objectDecl ) {
     404        void Resolver::previsit( ObjectDecl * objectDecl ) {
    405405                // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that
    406406                // class-variable initContext is changed multiple time because the LHS is analysed twice.
     
    432432        }
    433433
    434         void Resolver::previsit( FunctionDecl *functionDecl ) {
     434        void Resolver::previsit( FunctionDecl * functionDecl ) {
    435435#if 0
    436436                std::cerr << "resolver visiting functiondecl ";
     
    442442        }
    443443
    444         void Resolver::postvisit( FunctionDecl *functionDecl ) {
     444        void Resolver::postvisit( FunctionDecl * functionDecl ) {
    445445                // default value expressions have an environment which shouldn't be there and trips up
    446446                // later passes.
     
    467467        }
    468468
    469         void Resolver::previsit( ExprStmt *exprStmt ) {
     469        void Resolver::previsit( ExprStmt * exprStmt ) {
    470470                visit_children = false;
    471471                assertf( exprStmt->expr, "ExprStmt has null Expression in resolver" );
     
    473473        }
    474474
    475         void Resolver::previsit( AsmExpr *asmExpr ) {
     475        void Resolver::previsit( AsmExpr * asmExpr ) {
    476476                visit_children = false;
    477477                findVoidExpression( asmExpr->operand, indexer );
     
    481481        }
    482482
    483         void Resolver::previsit( AsmStmt *asmStmt ) {
     483        void Resolver::previsit( AsmStmt * asmStmt ) {
    484484                visit_children = false;
    485485                acceptAll( asmStmt->get_input(), *visitor );
     
    487487        }
    488488
    489         void Resolver::previsit( IfStmt *ifStmt ) {
     489        void Resolver::previsit( IfStmt * ifStmt ) {
    490490                findIntegralExpression( ifStmt->condition, indexer );
    491491        }
    492492
    493         void Resolver::previsit( WhileStmt *whileStmt ) {
     493        void Resolver::previsit( WhileStmt * whileStmt ) {
    494494                findIntegralExpression( whileStmt->condition, indexer );
    495495        }
    496496
    497         void Resolver::previsit( ForStmt *forStmt ) {
     497        void Resolver::previsit( ForStmt * forStmt ) {
    498498                if ( forStmt->condition ) {
    499499                        findIntegralExpression( forStmt->condition, indexer );
     
    505505        }
    506506
    507         void Resolver::previsit( SwitchStmt *switchStmt ) {
     507        void Resolver::previsit( SwitchStmt * switchStmt ) {
    508508                GuardValue( currentObject );
    509509                findIntegralExpression( switchStmt->condition, indexer );
     
    512512        }
    513513
    514         void Resolver::previsit( CaseStmt *caseStmt ) {
     514        void Resolver::previsit( CaseStmt * caseStmt ) {
    515515                if ( caseStmt->condition ) {
    516516                        std::list< InitAlternative > initAlts = currentObject.getOptions();
     
    531531        }
    532532
    533         void Resolver::previsit( BranchStmt *branchStmt ) {
     533        void Resolver::previsit( BranchStmt * branchStmt ) {
    534534                visit_children = false;
    535535                // must resolve the argument for a computed goto
     
    542542        }
    543543
    544         void Resolver::previsit( ReturnStmt *returnStmt ) {
     544        void Resolver::previsit( ReturnStmt * returnStmt ) {
    545545                visit_children = false;
    546546                if ( returnStmt->expr ) {
     
    549549        }
    550550
    551         void Resolver::previsit( ThrowStmt *throwStmt ) {
     551        void Resolver::previsit( ThrowStmt * throwStmt ) {
    552552                visit_children = false;
    553553                // TODO: Replace *exception type with &exception type.
     
    561561        }
    562562
    563         void Resolver::previsit( CatchStmt *catchStmt ) {
     563        void Resolver::previsit( CatchStmt * catchStmt ) {
    564564                if ( catchStmt->cond ) {
    565565                        findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer );
     
    725725
    726726                                                }
    727                                                 catch( SemanticErrorException &e ) {
     727                                                catch( SemanticErrorException & e ) {
    728728                                                        errors.append( e );
    729729                                                }
    730730                                        }
    731731                                }
    732                                 catch( SemanticErrorException &e ) {
     732                                catch( SemanticErrorException & e ) {
    733733                                        errors.append( e );
    734734                                }
     
    782782        }
    783783
    784         void Resolver::previsit( SingleInit *singleInit ) {
     784        void Resolver::previsit( SingleInit * singleInit ) {
    785785                visit_children = false;
    786786                // resolve initialization using the possibilities as determined by the currentObject cursor
     
    814814                                if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) {
    815815                                        if ( isCharType( pt->get_base() ) ) {
    816                                                 if ( CastExpr *ce = dynamic_cast< CastExpr * >( newExpr ) ) {
     816                                                if ( CastExpr * ce = dynamic_cast< CastExpr * >( newExpr ) ) {
    817817                                                        // strip cast if we're initializing a char[] with a char *,
    818818                                                        // e.g.  char x[] = "hello";
     
    894894        }
    895895
    896         void Resolver::previsit( ConstructorInit *ctorInit ) {
     896        void Resolver::previsit( ConstructorInit * ctorInit ) {
    897897                visit_children = false;
    898898                // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
Note: See TracChangeset for help on using the changeset viewer.