Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
b7c89aa
Parents:
f9feab8 (diff), 305581d (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/AdjustExprType.cc

    rf9feab8 r90152a4  
    2424        class AdjustExprType : public WithShortCircuiting {
    2525          public:
    26                 AdjustExprType( const TypeEnvironment &env, const SymTab::Indexer &indexer );
     26                AdjustExprType( const TypeEnvironment & env, const SymTab::Indexer & indexer );
    2727                void premutate( VoidType * ) { visit_children = false; }
    2828                void premutate( BasicType * ) { visit_children = false; }
     
    4545
    4646          private:
    47                 const TypeEnvironment &env;
    48                 const SymTab::Indexer &indexer;
     47                const TypeEnvironment & env;
     48                const SymTab::Indexer & indexer;
    4949        };
    5050
     
    5555        }
    5656
     57        void adjustExprType( Type *& type ) {
     58                TypeEnvironment env;
     59                SymTab::Indexer indexer;
     60                adjustExprType( type, env, indexer );
     61        }
     62
    5763        AdjustExprType::AdjustExprType( const TypeEnvironment &env, const SymTab::Indexer &indexer )
    5864                : env( env ), indexer( indexer ) {
     
    6066
    6167        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
    62                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
     68                PointerType *pointerType = new PointerType{ arrayType->get_qualifiers(), arrayType->base };
    6369                arrayType->base = nullptr;
    6470                delete arrayType;
     
    6773
    6874        Type * AdjustExprType::postmutate( FunctionType * functionType ) {
    69                 return new PointerType( Type::Qualifiers(), functionType );
     75                return new PointerType{ Type::Qualifiers(), functionType };
    7076        }
    7177
    7278        Type * AdjustExprType::postmutate( TypeInstType * typeInst ) {
    73                 EqvClass eqvClass;
    74                 if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    75                         if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    76                                 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    77                                 return pointerType;
     79                if ( const EqvClass* eqvClass = env.lookup( typeInst->get_name() ) ) {
     80                        if ( eqvClass->data.kind == TypeDecl::Ftype ) {
     81                                return new PointerType{ Type::Qualifiers(), typeInst };
    7882                        }
    7983                } else if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    8084                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
    8185                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
    82                                         PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    83                                         return pointerType;
     86                                        return new PointerType{ Type::Qualifiers(), typeInst };
    8487                                } // if
    8588                        } // if
Note: See TracChangeset for help on using the changeset viewer.