Changeset 09c72d5


Ignore:
Timestamp:
Mar 2, 2018, 5:34:52 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
b8baa37
Parents:
dd05e12
git-author:
Rob Schluntz <rschlunt@…> (03/02/18 17:10:28)
git-committer:
Rob Schluntz <rschlunt@…> (03/02/18 17:34:52)
Message:

Add function to add bindings from TypeSubstitution? to TypeEnvironment?

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/TypeEnvironment.cc

    rdd05e12 r09c72d5  
    118118                        env.push_back( newClass );
    119119                } // for
     120        }
     121
     122        void TypeEnvironment::add( const TypeSubstitution & sub ) {
     123                EqvClass newClass;
     124                for ( auto p : sub ) {
     125                        newClass.vars.insert( p.first );
     126                        newClass.type = p.second->clone();
     127                        newClass.allowWidening = false;
     128                        // Minimal assumptions. Not technically correct, but might be good enough, and
     129                        // is the best we can do at the moment since information is lost in the
     130                        // transition to TypeSubstitution
     131                        newClass.data = TypeDecl::Data{ TypeDecl::Dtype, false };
     132                        add( newClass );
     133                }
    120134        }
    121135
  • src/ResolvExpr/TypeEnvironment.h

    rdd05e12 r09c72d5  
    7676                void add( const EqvClass &eqvClass );
    7777                void add( const Type::ForallList &tyDecls );
     78                void add( const TypeSubstitution & sub );
    7879                template< typename SynTreeClass > int apply( SynTreeClass *&type ) const;
    7980                template< typename SynTreeClass > int applyFree( SynTreeClass *&type ) const;
  • src/SynTree/TypeSubstitution.h

    rdd05e12 r09c72d5  
    8282        TypeEnvType typeEnv;
    8383        VarEnvType varEnv;
     84
     85  public:
     86        // has to come after declaration of typeEnv
     87        auto begin()       -> decltype( typeEnv.begin() ) { return typeEnv.begin(); }
     88        auto   end()       -> decltype( typeEnv.  end() ) { return typeEnv.  end(); }
     89        auto begin() const -> decltype( typeEnv.begin() ) { return typeEnv.begin(); }
     90        auto   end() const -> decltype( typeEnv.  end() ) { return typeEnv.  end(); }
    8491};
    8592
Note: See TracChangeset for help on using the changeset viewer.