Changeset 0f9e4403 for src/ResolvExpr


Ignore:
Timestamp:
Apr 15, 2016, 12:03:11 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
29ad0ac
Parents:
c5833e8 (diff), 37f0da8 (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 gc_noraii

Location:
src/ResolvExpr
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sat May 16 23:41:42 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 23:54:02 2015
    13 // Update Count     : 3
     12// Last Modified On : Wed Mar  2 17:34:53 2016
     13// Update Count     : 4
    1414//
    1515
     
    3333                virtual Type* mutate( UnionInstType *aggregateUseType );
    3434                virtual Type* mutate( EnumInstType *aggregateUseType );
    35                 virtual Type* mutate( ContextInstType *aggregateUseType );
     35                virtual Type* mutate( TraitInstType *aggregateUseType );
    3636                virtual Type* mutate( TypeInstType *aggregateUseType );
    3737                virtual Type* mutate( TupleType *tupleType );
     38                virtual Type* mutate( VarArgsType *varArgsType );
    3839
    3940                const TypeEnvironment &env;
     
    8687        }
    8788
    88         Type *AdjustExprType::mutate( ContextInstType *aggregateUseType ) {
     89        Type *AdjustExprType::mutate( TraitInstType *aggregateUseType ) {
    8990                return aggregateUseType;
    9091        }
     
    111112                return tupleType;
    112113        }
     114
     115        Type *AdjustExprType::mutate( VarArgsType *varArgsType ) {
     116                return varArgsType;
     117        }
    113118} // namespace ResolvExpr
    114119
  • src/ResolvExpr/AlternativeFinder.cc

    rc5833e8 r0f9e4403  
    848848        }
    849849
     850        void AlternativeFinder::visit( OffsetPackExpr *offsetPackExpr ) {
     851                alternatives.push_back( Alternative( offsetPackExpr->clone(), env, Cost::zero ) );
     852        }
     853
    850854        void AlternativeFinder::resolveAttr( DeclarationWithType *funcDecl, FunctionType *function, Type *argType, const TypeEnvironment &env ) {
    851855                // assume no polymorphism
  • src/ResolvExpr/AlternativeFinder.h

    rc5833e8 r0f9e4403  
    5959                virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    6060                virtual void visit( OffsetofExpr *offsetofExpr );
     61                virtual void visit( OffsetPackExpr *offsetPackExpr );
    6162                virtual void visit( AttrExpr *attrExpr );
    6263                virtual void visit( LogicalExpr *logicalExpr );
  • src/ResolvExpr/CommonType.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 06:59:27 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 07:04:50 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 17:35:34 2016
     13// Update Count     : 3
    1414//
    1515
     
    3535                virtual void visit( UnionInstType *aggregateUseType );
    3636                virtual void visit( EnumInstType *aggregateUseType );
    37                 virtual void visit( ContextInstType *aggregateUseType );
     37                virtual void visit( TraitInstType *aggregateUseType );
    3838                virtual void visit( TypeInstType *aggregateUseType );
    3939                virtual void visit( TupleType *tupleType );
     40                virtual void visit( VarArgsType *varArgsType );
    4041
    4142                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     
    185186        }
    186187
    187         void CommonType::visit( ContextInstType *aggregateUseType ) {
     188        void CommonType::visit( TraitInstType *aggregateUseType ) {
    188189        }
    189190
     
    213214        void CommonType::visit( TupleType *tupleType ) {
    214215        }
     216
     217        void CommonType::visit( VarArgsType *varArgsType ) {
     218        }
    215219} // namespace ResolvExpr
    216220
  • src/ResolvExpr/ConversionCost.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 07:06:19 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 07:22:19 2015
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:35:46 2016
     13// Update Count     : 6
    1414//
    1515
     
    206206        }
    207207
    208         void ConversionCost::visit(ContextInstType *inst) {
     208        void ConversionCost::visit(TraitInstType *inst) {
    209209        }
    210210
     
    247247                } // if
    248248        }
     249
     250        void ConversionCost::visit(VarArgsType *varArgsType) {
     251                if ( dynamic_cast< VarArgsType* >( dest ) ) {
     252                        cost = Cost::zero;
     253                }
     254        }
    249255} // namespace ResolvExpr
    250256
  • src/ResolvExpr/ConversionCost.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 09:37:28 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 09:39:23 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 17:35:56 2016
     13// Update Count     : 3
    1414//
    1515
     
    3737                virtual void visit(UnionInstType *aggregateUseType);
    3838                virtual void visit(EnumInstType *aggregateUseType);
    39                 virtual void visit(ContextInstType *aggregateUseType);
     39                virtual void visit(TraitInstType *aggregateUseType);
    4040                virtual void visit(TypeInstType *aggregateUseType);
    4141                virtual void visit(TupleType *tupleType);
     42                virtual void visit(VarArgsType *varArgsType);
    4243          protected:
    4344                Type *dest;
  • src/ResolvExpr/PtrsAssignable.cc

    rc5833e8 r0f9e4403  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 11:44:11 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Sep 21 14:34:58 2015
    13 // Update Count     : 7
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:36:05 2016
     13// Update Count     : 8
    1414//
    1515
     
    3535                virtual void visit( UnionInstType *inst );
    3636                virtual void visit( EnumInstType *inst );
    37                 virtual void visit( ContextInstType *inst );
     37                virtual void visit( TraitInstType *inst );
    3838                virtual void visit( TypeInstType *inst );
    3939                virtual void visit( TupleType *tupleType );
     40                virtual void visit( VarArgsType *varArgsType );
    4041          private:
    4142                Type *dest;
     
    100101        }
    101102
    102         void PtrsAssignable::visit( ContextInstType *inst ) {
     103        void PtrsAssignable::visit( TraitInstType *inst ) {
    103104                // I definitely don't think we should be doing anything here
    104105        }
     
    137138///   }
    138139        }
     140
     141        void PtrsAssignable::visit( VarArgsType *varArgsType ) {
     142        }
    139143} // namespace ResolvExpr
    140144
  • src/ResolvExpr/PtrsCastable.cc

    rc5833e8 r0f9e4403  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 11:48:00 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Oct 05 14:49:12 2015
    13 // Update Count     : 7
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:36:18 2016
     13// Update Count     : 8
    1414//
    1515
     
    3636                virtual void visit(UnionInstType *inst);
    3737                virtual void visit(EnumInstType *inst);
    38                 virtual void visit(ContextInstType *inst);
     38                virtual void visit(TraitInstType *inst);
    3939                virtual void visit(TypeInstType *inst);
    4040                virtual void visit(TupleType *tupleType);
     41                virtual void visit(VarArgsType *varArgsType);
    4142          private:
    4243                Type *dest;
     
    115116
    116117        void PtrsCastable::visit(EnumInstType *inst) {
    117                 if ( dynamic_cast< EnumInstType* >( inst ) ) {
     118                if ( dynamic_cast< EnumInstType* >( dest ) ) {
    118119                        result = 1;
    119                 } else if ( BasicType *bt = dynamic_cast< BasicType* >( inst ) ) {
     120                } else if ( BasicType *bt = dynamic_cast< BasicType* >( dest ) ) {
    120121                        if ( bt->get_kind() == BasicType::SignedInt ) {
    121122                                result = 0;
     
    128129        }
    129130
    130         void PtrsCastable::visit(ContextInstType *inst) {
     131        void PtrsCastable::visit(TraitInstType *inst) {
    131132                // I definitely don't think we should be doing anything here
    132133        }
     
    139140                result = objectCast( dest, env, indexer );
    140141        }
     142
     143        void PtrsCastable::visit(VarArgsType *varArgsType) {
     144                result = objectCast( dest, env, indexer );
     145        }
    141146} // namespace ResolvExpr
    142147
  • src/ResolvExpr/RenameVars.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 12:05:18 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 14:51:35 2015
    13 // Update Count     : 4
     12// Last Modified On : Wed Mar  2 17:36:32 2016
     13// Update Count     : 5
    1414//
    1515
     
    8686        }
    8787
    88         void RenameVars::visit( ContextInstType *aggregateUseType ) {
     88        void RenameVars::visit( TraitInstType *aggregateUseType ) {
    8989                typeBefore( aggregateUseType );
    9090                acceptAll( aggregateUseType->get_parameters(), *this );
     
    111111                acceptAll( tupleType->get_types(), *this );
    112112                typeAfter( tupleType );
     113        }
     114
     115        void RenameVars::visit( VarArgsType *varArgsType ) {
     116                typeBefore( varArgsType );
     117                typeAfter( varArgsType );
    113118        }
    114119
  • src/ResolvExpr/RenameVars.h

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 12:10:28 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 12:11:53 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Mar  2 17:36:39 2016
     13// Update Count     : 3
    1414//
    1515
     
    4040                virtual void visit( UnionInstType *aggregateUseType );
    4141                virtual void visit( EnumInstType *aggregateUseType );
    42                 virtual void visit( ContextInstType *aggregateUseType );
     42                virtual void visit( TraitInstType *aggregateUseType );
    4343                virtual void visit( TypeInstType *aggregateUseType );
    4444                virtual void visit( TupleType *tupleType );
     45                virtual void visit( VarArgsType *varArgsType );
    4546
    4647                void typeBefore( Type *type );
  • src/ResolvExpr/Resolver.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  9 21:57:52 2016
    13 // Update Count     : 179
     12// Last Modified On : Thu Mar 24 16:43:11 2016
     13// Update Count     : 181
    1414//
    1515
     
    165165                Type *new_type = resolveTypeof( objectDecl->get_type(), *this );
    166166                objectDecl->set_type( new_type );
     167                // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that class-variable
     168                // initContext is changed multiple time because the LHS is analysed twice. The second analysis changes
     169                // initContext because of a function type can contain object declarations in the return and parameter types. So
     170                // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting
     171                // the RHS.
     172                Type *temp = initContext;
    167173                initContext = new_type;
    168174                SymTab::Indexer::visit( objectDecl );
     175                initContext = temp;
    169176        }
    170177
  • src/ResolvExpr/Unify.cc

    rc5833e8 r0f9e4403  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Unify.cc -- 
     7// Unify.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 12:27:10 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Sep 02 14:43:22 2015
    13 // Update Count     : 36
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:37:05 2016
     13// Update Count     : 37
    1414//
    1515
     
    3838                WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
    3939                operator bool() { return widenFirst && widenSecond; }
    40  
     40
    4141                bool widenFirst : 1, widenSecond : 1;
    4242        };
     
    4545          public:
    4646                Unify( Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
    47  
     47
    4848                bool get_result() const { return result; }
    4949          private:
     
    5656                virtual void visit(UnionInstType *aggregateUseType);
    5757                virtual void visit(EnumInstType *aggregateUseType);
    58                 virtual void visit(ContextInstType *aggregateUseType);
     58                virtual void visit(TraitInstType *aggregateUseType);
    5959                virtual void visit(TypeInstType *aggregateUseType);
    6060                virtual void visit(TupleType *tupleType);
     61                virtual void visit(VarArgsType *varArgsType);
    6162
    6263                template< typename RefType > void handleRefType( RefType *inst, Type *other );
     
    7879        bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common );
    7980        bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );
    80  
     81
    8182        bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) {
    8283                TypeEnvironment newEnv;
     
    136137                  case TypeDecl::Dtype:
    137138                        return ! isFtype( type, indexer );
    138  
     139
    139140                  case TypeDecl::Ftype:
    140141                        return isFtype( type, indexer );
     
    195196                bool widen1 = false, widen2 = false;
    196197                Type *type1 = 0, *type2 = 0;
    197  
     198
    198199                if ( env.lookup( var1->get_name(), class1 ) ) {
    199200                        hasClass1 = true;
     
    216217                        widen2 = widenMode.widenSecond && class2.allowWidening;
    217218                } // if
    218  
     219
    219220                if ( type1 && type2 ) {
    220221//    std::cout << "has type1 && type2" << std::endl;
     
    435436                // to unify, array types must both be VLA or both not VLA
    436437                // and must both have a dimension expression or not have a dimension
    437                 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen()
    438                                 && ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0)
    439                                         || (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) {
     438                if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) {
    440439
    441440                        // not positive this is correct in all cases, but it's needed for typedefs
     
    448447                                ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() );
    449448                                ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() );
    450                                 assert(ce1 && ce2);
    451 
    452                                 Constant * c1 = ce1->get_constant();
    453                                 Constant * c2 = ce2->get_constant();
    454 
    455                                 if ( c1->get_value() != c2->get_value() ) {
    456                                         // does not unify if the dimension is different
    457                                         return;
     449                                // see C11 Reference Manual 6.7.6.2.6
     450                                // two array types with size specifiers that are integer constant expressions are
     451                                // compatible if both size specifiers have the same constant value
     452                                if ( ce1 && ce2 ) {
     453                                        Constant * c1 = ce1->get_constant();
     454                                        Constant * c2 = ce2->get_constant();
     455
     456                                        if ( c1->get_value() != c2->get_value() ) {
     457                                                // does not unify if the dimension is different
     458                                                return;
     459                                        }
    458460                                }
    459461                        }
     
    484486
    485487                        if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    486        
     488
    487489                                if ( unifyDeclList( functionType->get_returnVals().begin(), functionType->get_returnVals().end(), otherFunction->get_returnVals().begin(), otherFunction->get_returnVals().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    488490
     
    539541        }
    540542
    541         void Unify::visit(ContextInstType *contextInst) {
     543        void Unify::visit(TraitInstType *contextInst) {
    542544                handleRefType( contextInst, type2 );
    543545        }
     
    582584        }
    583585
     586        void Unify::visit(VarArgsType *varArgsType) {
     587                result = dynamic_cast< VarArgsType* >( type2 );
     588        }
     589
    584590} // namespace ResolvExpr
    585591
Note: See TracChangeset for help on using the changeset viewer.