Changeset c28a038d


Ignore:
Timestamp:
Jan 31, 2018, 4:53:23 PM (6 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:
c453ac4
Parents:
4670c79
Message:

Refactor resolveWith

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r4670c79 rc28a038d  
    8282                void previsit( ConstructorInit *ctorInit );
    8383          private:
    84         typedef std::list< Initializer * >::iterator InitIterator;
     84                typedef std::list< Initializer * >::iterator InitIterator;
    8585
    8686                template< typename PtrType >
    8787                void handlePtrType( PtrType * type );
    8888
    89           void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & );
    90           void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub );
    91           void fallbackInit( ConstructorInit * ctorInit );
     89                void resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts );
     90                void fallbackInit( ConstructorInit * ctorInit );
    9291
    9392                Type * functionReturn = nullptr;
     
    269268                std::cerr << std::endl;
    270269#endif
    271                 Type *new_type = resolveTypeof( functionDecl->get_type(), indexer );
     270                Type *new_type = resolveTypeof( functionDecl->type, indexer );
    272271                functionDecl->set_type( new_type );
    273272                GuardValue( functionReturn );
     
    279278                // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently
    280279                // see how it's useful.
    281                 for ( Declaration * d : functionDecl->get_functionType()->get_parameters() ) {
     280                for ( Declaration * d : functionDecl->type->parameters ) {
    282281                        if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( d ) ) {
    283                                 if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->get_init() ) ) {
    284                                         delete init->get_value()->get_env();
    285                                         init->get_value()->set_env( nullptr );
     282                                if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->init ) ) {
     283                                        delete init->value->env;
     284                                        init->value->env = nullptr;
    286285                                }
    287286                        }
     
    584583        }
    585584
    586 
    587         void Resolver::previsit( WithStmt * withStmt ) {
    588                 for ( Expression *& expr : withStmt->exprs )  {
     585        void Resolver::resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ) {
     586                for ( Expression *& expr : withExprs )  {
    589587                        // only struct- and union-typed expressions are viable candidates
    590588                        findKindExpression( expr, indexer, "with statement", isStructOrUnion );
     
    595593                                ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) );
    596594                                expr = new VariableExpr( tmp );
    597                                 stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
     595                                newStmts.push_back( new DeclStmt( tmp ) );
    598596                                if ( InitTweak::isConstructable( tmp->type ) ) {
    599597                                        // generate ctor/dtor and resolve them
     
    603601                        }
    604602                }
     603        }
     604
     605        void Resolver::previsit( WithStmt * withStmt ) {
     606                resolveWithExprs( withStmt->exprs, stmtsToAddBefore );
    605607        }
    606608
Note: See TracChangeset for help on using the changeset viewer.