Ignore:
Timestamp:
Nov 24, 2022, 11:01:37 AM (19 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
82a90d4
Parents:
78de1e5
Message:

Minimal changes to pull out nested types, TypeInstType::TypeEnvKey? and TypeDecl::Data (now TypeData?) from there parent types. Although they do connect to the parent types they were nested in they are used on their own most of the time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/TypeEnvironment.cpp

    r78de1e5 r93c10de  
    8282}
    8383
    84 const EqvClass * TypeEnvironment::lookup( const TypeInstType::TypeEnvKey & var ) const {
     84const EqvClass * TypeEnvironment::lookup( const TypeEnvKey & var ) const {
    8585        for ( ClassList::const_iterator i = env.begin(); i != env.end(); ++i ) {
    8686                if ( i->vars.find( var ) != i->vars.end() ) return &*i;
     
    122122void TypeEnvironment::writeToSubstitution( TypeSubstitution & sub ) const {
    123123        for ( const auto & clz : env ) {
    124                 TypeInstType::TypeEnvKey clzRep;
     124                TypeEnvKey clzRep;
    125125                bool first = true;
    126126                for ( const auto & var : clz.vars ) {
     
    146146        struct Occurs : public ast::WithVisitorRef<Occurs> {
    147147                bool result;
    148                 std::unordered_set< TypeInstType::TypeEnvKey > vars;
     148                std::unordered_set< TypeEnvKey > vars;
    149149                const TypeEnvironment & tenv;
    150150
    151                 Occurs( const TypeInstType::TypeEnvKey & var, const TypeEnvironment & env )
     151                Occurs( const TypeEnvKey & var, const TypeEnvironment & env )
    152152                : result( false ), vars(), tenv( env ) {
    153153                        if ( const EqvClass * clz = tenv.lookup( var ) ) {
     
    170170
    171171        /// true if `var` occurs in `ty` under `env`
    172         bool occurs( const Type * ty, const TypeInstType::TypeEnvKey & var, const TypeEnvironment & env ) {
     172        bool occurs( const Type * ty, const TypeEnvKey & var, const TypeEnvironment & env ) {
    173173                Pass<Occurs> occur{ var, env };
    174174                maybe_accept( ty, occur );
     
    258258namespace {
    259259        /// true if the given type can be bound to the given type variable
    260         bool tyVarCompatible( const TypeDecl::Data & data, const Type * type ) {
     260        bool tyVarCompatible( const TypeData & data, const Type * type ) {
    261261                switch ( data.kind ) {
    262262                  case TypeDecl::Dtype:
     
    279279
    280280bool TypeEnvironment::bindVar(
    281                 const TypeInstType * typeInst, const Type * bindTo, const TypeDecl::Data & data,
     281                const TypeInstType * typeInst, const Type * bindTo, const TypeData & data,
    282282                AssertionSet & need, AssertionSet & have, const OpenVarSet & open, WidenMode widen,
    283283                const SymbolTable & symtab
     
    319319
    320320bool TypeEnvironment::bindVarToVar(
    321                 const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data,
     321                const TypeInstType * var1, const TypeInstType * var2, TypeData && data,
    322322                AssertionSet & need, AssertionSet & have, const OpenVarSet & open,
    323323                WidenMode widen, const SymbolTable & symtab
     
    457457}
    458458
    459 TypeEnvironment::ClassList::iterator TypeEnvironment::internal_lookup( const TypeInstType::TypeEnvKey & var ) {
     459TypeEnvironment::ClassList::iterator TypeEnvironment::internal_lookup( const TypeEnvKey & var ) {
    460460        for ( ClassList::iterator i = env.begin(); i != env.end(); ++i ) {
    461461                if ( i->vars.count( var ) ) return i;
Note: See TracChangeset for help on using the changeset viewer.