Changeset 40e636a for src/ResolvExpr


Ignore:
Timestamp:
Jul 21, 2016, 11:19:24 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
b81adcc4
Parents:
5f98ce5
Message:

only generate array dimension constant inside of functions, recursively mutate array types into pointer types in function parameter lists, fix bug where global compound literal object is lost

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r5f98ce5 r40e636a  
    4242
    4343                virtual void visit( ArrayType * at );
     44                virtual void visit( PointerType * at );
    4445
    4546                virtual void visit( ExprStmt *exprStmt );
     
    6061          private:
    6162        typedef std::list< Initializer * >::iterator InitIterator;
     63
     64                template< typename PtrType >
     65                void handlePtrType( PtrType * type );
    6266
    6367          void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & );
     
    193197        }
    194198
     199        template< typename PtrType >
     200        void Resolver::handlePtrType( PtrType * type ) {
     201                if ( type->get_dimension() ) {
     202                        CastExpr *castExpr = new CastExpr( type->get_dimension(), SymTab::SizeType->clone() );
     203                        Expression *newExpr = findSingleExpression( castExpr, *this );
     204                        delete type->get_dimension();
     205                        type->set_dimension( newExpr );
     206                }
     207        }
     208
    195209        void Resolver::visit( ArrayType * at ) {
    196                 if ( at->get_dimension() ) {
    197                         CastExpr *castExpr = new CastExpr( at->get_dimension(), SymTab::SizeType->clone() );
    198                         Expression *newExpr = findSingleExpression( castExpr, *this );
    199                         delete at->get_dimension();
    200                         at->set_dimension( newExpr );
    201                 }
     210                handlePtrType( at );
    202211                Visitor::visit( at );
     212        }
     213
     214        void Resolver::visit( PointerType * pt ) {
     215                handlePtrType( pt );
     216                Visitor::visit( pt );
    203217        }
    204218
Note: See TracChangeset for help on using the changeset viewer.