Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/TypeSubstitution.hpp

    r361bf01 r3e5dd913  
    6969        }
    7070
    71         void add( std::string formalType, const Type *actualType );
     71        void add( const TypeInstType * formalType, const Type *actualType );
     72        void add( const TypeInstType::TypeEnvKey & key, const Type *actualType );
    7273        void add( const TypeSubstitution &other );
    73         void remove( std::string formalType );
    74         const Type *lookup( std::string formalType ) const;
     74        void remove( const TypeInstType * formalType );
     75        const Type *lookup( const TypeInstType * formalType ) const;
    7576        bool empty() const;
    76 
    77         void addVar( std::string formalExpr, const Expr *actualExpr );
    7877
    7978        template< typename FormalIterator, typename ActualIterator >
     
    101100        friend class Pass;
    102101
    103         typedef std::unordered_map< std::string, ptr<Type> > TypeEnvType;
    104         typedef std::unordered_map< std::string, ptr<Expr> > VarEnvType;
     102        typedef std::unordered_map< TypeInstType::TypeEnvKey, ptr<Type> > TypeEnvType;
    105103        TypeEnvType typeEnv;
    106         VarEnvType varEnv;
    107104
    108105  public:
     
    113110        auto   end() const -> decltype( typeEnv.  end() ) { return typeEnv.  end(); }
    114111
    115         auto beginVar()       -> decltype( varEnv.begin() ) { return varEnv.begin(); }
    116         auto   endVar()       -> decltype( varEnv.  end() ) { return varEnv.  end(); }
    117         auto beginVar() const -> decltype( varEnv.begin() ) { return varEnv.begin(); }
    118         auto   endVar() const -> decltype( varEnv.  end() ) { return varEnv.  end(); }
    119112};
    120113
     114// this is the only place where type parameters outside a function formal may be substituted.
    121115template< typename FormalIterator, typename ActualIterator >
    122116void TypeSubstitution::add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) {
     
    129123                        if ( const TypeExpr *actual = actualIt->template as<TypeExpr>() ) {
    130124                                if ( formal->name != "" ) {
    131                                         typeEnv[ formal->name ] = actual->type;
     125                                        typeEnv[ formal ] = actual->type;
    132126                                } // if
    133127                        } else {
     
    135129                        } // if
    136130                } else {
    137                         // TODO: type check the formal and actual parameters
    138                         if ( (*formalIt)->name != "" ) {
    139                                 varEnv[ (*formalIt)->name ] = *actualIt;
    140                         } // if
     131                       
    141132                } // if
    142133        } // for
    143134}
     135
     136
    144137
    145138template< typename FormalIterator, typename ActualIterator >
     
    147140        add( formalBegin, formalEnd, actualBegin );
    148141}
     142
    149143
    150144} // namespace ast
     
    164158
    165159                const Type * postvisit( const TypeInstType * aggregateUseType );
    166                 const Expr * postvisit( const NameExpr * nameExpr );
    167160
    168161                /// Records type variable bindings from forall-statements
    169162                void previsit( const FunctionType * type );
    170163                /// Records type variable bindings from forall-statements and instantiations of generic types
    171                 void handleAggregateType( const BaseInstType * type );
     164                // void handleAggregateType( const BaseInstType * type );
    172165
    173                 void previsit( const StructInstType * aggregateUseType );
    174                 void previsit( const UnionInstType * aggregateUseType );
     166                // void previsit( const StructInstType * aggregateUseType );
     167                // void previsit( const UnionInstType * aggregateUseType );
    175168
    176169                const TypeSubstitution & sub;
    177170                int subCount = 0;
    178171                bool freeOnly;
    179                 typedef std::unordered_set< std::string > BoundVarsType;
     172                typedef std::unordered_set< TypeInstType::TypeEnvKey > BoundVarsType;
    180173                BoundVarsType boundVars;
    181174
Note: See TracChangeset for help on using the changeset viewer.