Changeset be9036d for src/SynTree


Ignore:
Timestamp:
Aug 31, 2017, 3:29:38 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, 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:
326338ae
Parents:
5b21138
git-author:
Rob Schluntz <rschlunt@…> (08/31/17 15:29:33)
git-committer:
Rob Schluntz <rschlunt@…> (08/31/17 15:29:38)
Message:

Reorganize TraitInstType? and TraitDecl?, add sized trait definition to prelude

Previously, TraitInstType? cloned all of the members of TraitDecl?. This commit changes
TraitInstType? to instead contain a pointer to the base TraitDecl?, analogous to StructInstType?
and StructDecl?, etc. In particular, this makes the code simpler and makes it easier to
fully expand the members of a trait declaration.

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Mutator.cc

    r5b21138 rbe9036d  
    538538Type * Mutator::mutate( TraitInstType *aggregateUseType ) {
    539539        handleReferenceToType( aggregateUseType );
    540         mutateAll( aggregateUseType->get_members(), *this );
    541540        return aggregateUseType;
    542541}
  • src/SynTree/ReferenceToType.cc

    r5b21138 rbe9036d  
    132132std::string TraitInstType::typeString() const { return "trait"; }
    133133
    134 TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ) {
    135         cloneAll( other.members, members );
     134TraitInstType::TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes ) : Parent( tq, baseTrait->name, attributes ), baseTrait( baseTrait ) {}
     135
     136TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ), baseTrait( other.baseTrait ) {
    136137}
    137138
    138139TraitInstType::~TraitInstType() {
    139         deleteAll( members );
    140140}
    141141
  • src/SynTree/Type.h

    r5b21138 rbe9036d  
    471471        typedef ReferenceToType Parent;
    472472  public:
    473         // this member is filled in by the validate pass, which instantiates the members of the correponding
    474         // aggregate with the actual type parameters specified for this use of the context
    475         std::list< Declaration* > members;
    476 
    477         TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     473        // this decl is not "owned" by the trait inst; it is merely a pointer to elsewhere in the tree,
     474        // where the trait used in this type is actually defined
     475        TraitDecl * baseTrait = nullptr;
     476
     477        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}
     478        TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    478479        TraitInstType( const TraitInstType & other );
    479480        ~TraitInstType();
    480 
    481         std::list< Declaration* >& get_members() { return members; }
    482481
    483482        virtual bool isComplete() const;
  • src/SynTree/TypeSubstitution.h

    r5b21138 rbe9036d  
    177177void applySubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actual, MemberIterator memberBegin, MemberIterator memberEnd, OutputIterator out ) {
    178178        TypeSubstitution sub = TypeSubstitution( formalBegin, formalEnd, actual );
    179         for ( std::list< Declaration* >::iterator i = memberBegin; i != memberEnd; ++i ) {
     179        for ( auto i = memberBegin; i != memberEnd; ++i ) {
    180180                sub.apply( *i );
    181181                *out++ = *i;
  • src/SynTree/Visitor.cc

    r5b21138 rbe9036d  
    429429void Visitor::visit( TraitInstType *aggregateUseType ) {
    430430        handleReferenceToType( static_cast< ReferenceToType * >( aggregateUseType ) );
    431         acceptAll( aggregateUseType->get_members(), *this );
    432431}
    433432
Note: See TracChangeset for help on using the changeset viewer.