Changeset 1d2b64f for src/ResolvExpr


Ignore:
Timestamp:
Dec 13, 2016, 5:20:54 PM (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:
d5556a3
Parents:
722617d
git-author:
Rob Schluntz <rschlunt@…> (12/13/16 17:16:27)
git-committer:
Rob Schluntz <rschlunt@…> (12/13/16 17:20:54)
Message:

combine environments and costs in tuple assignment, resolve ctor/dtors for tuple assignment temporaries

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r722617d r1d2b64f  
    3636          public:
    3737                Resolver() : SymTab::Indexer( false ) {}
    38 
    39                 using SymTab::Indexer::visit;
     38                Resolver( const SymTab:: Indexer & other ) : SymTab::Indexer( other ) {
     39                        if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) {
     40                                functionReturn = res->functionReturn;
     41                                initContext = res->initContext;
     42                                inEnumDecl = res->inEnumDecl;
     43                        }
     44                }
     45
     46                typedef SymTab::Indexer Parent;
     47                using Parent::visit;
    4048                virtual void visit( FunctionDecl *functionDecl ) override;
    4149                virtual void visit( ObjectDecl *functionDecl ) override;
     
    192200                        initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
    193201                }
    194                 SymTab::Indexer::visit( objectDecl );
     202                Parent::visit( objectDecl );
    195203                if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
    196204                        // delete newly created signed int type
     
    212220        void Resolver::visit( ArrayType * at ) {
    213221                handlePtrType( at );
    214                 Visitor::visit( at );
     222                Parent::visit( at );
    215223        }
    216224
    217225        void Resolver::visit( PointerType * pt ) {
    218226                handlePtrType( pt );
    219                 Visitor::visit( pt );
     227                Parent::visit( pt );
    220228        }
    221229
     
    225233                        typeDecl->set_base( new_type );
    226234                } // if
    227                 SymTab::Indexer::visit( typeDecl );
     235                Parent::visit( typeDecl );
    228236        }
    229237
     
    238246                ValueGuard< Type * > oldFunctionReturn( functionReturn );
    239247                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    240                 SymTab::Indexer::visit( functionDecl );
     248                Parent::visit( functionDecl );
    241249        }
    242250
    243251        void Resolver::visit( EnumDecl * enumDecl ) {
    244252                // in case we decide to allow nested enums
    245                 bool oldInEnumDecl = inEnumDecl;
     253                ValueGuard< bool > oldInEnumDecl( inEnumDecl );
    246254                inEnumDecl = true;
    247                 SymTab::Indexer::visit( enumDecl );
    248                 inEnumDecl = oldInEnumDecl;
     255                Parent::visit( enumDecl );
    249256        }
    250257
    251258        void Resolver::visit( ExprStmt *exprStmt ) {
    252                 if ( exprStmt->get_expr() ) {
    253                         Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this );
    254                         delete exprStmt->get_expr();
    255                         exprStmt->set_expr( newExpr );
    256                 } // if
     259                assertf( exprStmt->get_expr(), "ExprStmt has null Expression in resolver" );
     260                Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this );
     261                delete exprStmt->get_expr();
     262                exprStmt->set_expr( newExpr );
    257263        }
    258264
     
    277283                delete ifStmt->get_condition();
    278284                ifStmt->set_condition( newExpr );
    279                 Visitor::visit( ifStmt );
     285                Parent::visit( ifStmt );
    280286        }
    281287
     
    284290                delete whileStmt->get_condition();
    285291                whileStmt->set_condition( newExpr );
    286                 Visitor::visit( whileStmt );
     292                Parent::visit( whileStmt );
    287293        }
    288294
    289295        void Resolver::visit( ForStmt *forStmt ) {
    290                 SymTab::Indexer::visit( forStmt );
     296                Parent::visit( forStmt );
    291297
    292298                if ( forStmt->get_condition() ) {
     
    318324
    319325        void Resolver::visit( CaseStmt *caseStmt ) {
    320                 Visitor::visit( caseStmt );
     326                Parent::visit( caseStmt );
    321327        }
    322328
     
    482488                        } else {
    483489                                // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
    484                                 Visitor::visit( listInit );
     490                                Parent::visit( listInit );
    485491                        }
    486492                } else {
    487493                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
    488                                 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
     494                                || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) );
    489495                        // basic types are handled here
    490                         Visitor::visit( listInit );
     496                        Parent::visit( listInit );
    491497                }
    492498
     
    554560        }
    555561
     562        // needs to be callable from outside the resolver, so this is a standalone function
     563        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ) {
     564                assert( ctorInit );
     565                Resolver resolver( indexer );
     566                ctorInit->accept( resolver );
     567        }
     568
     569        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ) {
     570                assert( stmtExpr );
     571                Resolver resolver( indexer );
     572                stmtExpr->accept( resolver );
     573        }
     574
    556575        void Resolver::visit( ConstructorInit *ctorInit ) {
    557576                // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
  • src/ResolvExpr/Resolver.h

    r722617d r1d2b64f  
    2525        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
    2626        Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer );
     27        void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
     28        void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
    2729} // namespace ResolvExpr
    2830
Note: See TracChangeset for help on using the changeset viewer.