Ignore:
Timestamp:
Jul 12, 2019, 10:49:02 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
ef5b828
Parents:
ee6dbae
Message:

Cast cost and conversion cost now take constant parameters.
This required supporting visiting const node.
The PassVisitor? can now visit const nodes but not when using the Indexer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/typeops.h

    ree6dbae r7870799  
    7373
    7474        /// Replaces array types with equivalent pointer, and function types with a pointer-to-function
    75         const ast::Type * adjustExprType( 
     75        const ast::Type * adjustExprType(
    7676                const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab );
    7777
    7878        // in CastCost.cc
    79         Cost castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    80         Cost castCost( 
    81                 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 
     79        Cost castCost( const Type * src, const Type * dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
     80        Cost castCost(
     81                const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,
    8282                const ast::TypeEnvironment & env );
    8383
    8484        // in ConversionCost.cc
    85         Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    86         Cost conversionCost( 
    87                 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 
     85        Cost conversionCost( const Type *src, const Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env );
     86        Cost conversionCost(
     87                const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,
    8888                const ast::TypeEnvironment & env );
    8989
    9090        // in AlternativeFinder.cc
    91         Cost computeConversionCost( Type *actualType, Type *formalType, 
     91        Cost computeConversionCost( Type *actualType, Type *formalType,
    9292                const SymTab::Indexer &indexer, const TypeEnvironment &env );
    9393
    9494        // in PtrsAssignable.cc
    95         int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env );
     95        int ptrsAssignable( const Type * src, const Type * dest, const TypeEnvironment &env );
    9696        int ptrsAssignable( const ast::Type * src, const ast::Type * dst,
    9797                const ast::TypeEnvironment & env );
    9898
    9999        // in PtrsCastable.cc
    100         int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer );
    101         int ptrsCastable( 
    102                 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 
     100        int ptrsCastable( const Type * src, const Type * dest, const TypeEnvironment &env, const SymTab::Indexer &indexer );
     101        int ptrsCastable(
     102                const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab,
    103103                const ast::TypeEnvironment & env );
    104104
    105105        // in Unify.cc
    106106        bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    107         bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
     107        bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env );
    108108
    109109        inline bool typesCompatible( Type *t1, Type *t2, const SymTab::Indexer &indexer ) {
     
    112112        }
    113113
    114         inline bool typesCompatibleIgnoreQualifiers( Type *t1, Type *t2, const SymTab::Indexer &indexer ) {
     114        inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer &indexer ) {
    115115                TypeEnvironment env;
    116116                return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );
    117117        }
    118118
    119         bool typesCompatible( 
    120                 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 
     119        bool typesCompatible(
     120                const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {},
    121121                const ast::TypeEnvironment & env = {} );
    122        
     122
    123123        bool typesCompatibleIgnoreQualifiers(
    124                 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 
     124                const ast::Type *, const ast::Type *, const ast::SymbolTable &,
    125125                const ast::TypeEnvironment & env = {} );
    126126
     
    133133        Type * commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars );
    134134        ast::ptr< ast::Type > commonType(
    135                 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, WidenMode widen, 
     135                const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, WidenMode widen,
    136136                const ast::SymbolTable & symtab, ast::TypeEnvironment & env, const ast::OpenVarSet & open );
    137137
    138138        // in PolyCost.cc
    139139        int polyCost( Type *type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
    140         int polyCost( 
     140        int polyCost(
    141141                const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );
    142142
     
    149149        // new AST version in TypeEnvironment.cpp (only place it was used in old AST)
    150150
    151         template<typename Iter> 
     151        template<typename Iter>
    152152        bool occursIn( Type* ty, Iter begin, Iter end, const TypeEnvironment &env ) {
    153153                while ( begin != end ) {
     
    176176
    177177        /// flatten tuple type into existing list of types
    178         static inline void flatten( 
    179                 const ast::Type * type, std::vector< ast::ptr< ast::Type > > & out 
     178        static inline void flatten(
     179                const ast::Type * type, std::vector< ast::ptr< ast::Type > > & out
    180180        ) {
    181                 if ( auto tupleType = dynamic_cast< const ast::TupleType * >( type ) ) {       
     181                if ( auto tupleType = dynamic_cast< const ast::TupleType * >( type ) ) {
    182182                        for ( const ast::Type * t : tupleType->types ) {
    183183                                flatten( t, out );
Note: See TracChangeset for help on using the changeset viewer.