Changeset fac05b3 for src/ResolvExpr


Ignore:
Timestamp:
Apr 6, 2023, 4:09:24 PM (17 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
485393c
Parents:
c468150
Message:

Removed members from TupleType?. They were only used in one place, CurrentObject?. That now has a patch to create its own imaginary members.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CurrentObject.cc

    rc468150 rfac05b3  
    1010// Created On       : Tue Jun 13 15:28:32 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  1 09:16:01 2022
    13 // Update Count     : 15
     12// Last Modified On : Thu Apr  6 16:03:00 2023
     13// Update Count     : 16
    1414//
    1515
     
    899899
    900900        class TupleIterator final : public AggregateIterator {
     901                MemberList * memberList;
     902
     903                TupleIterator( const CodeLocation & loc,
     904                        const ast::TupleType * inst, MemberList * memberList )
     905                : AggregateIterator(
     906                        loc, "TupleIterator", toString("Tuple", inst->size()), inst, *memberList
     907                ), memberList( memberList ) {}
     908
     909                // The two layer constructor, this helper and the destructor
     910                // are all to pretend that Tuples have members (they do not).
     911                static MemberList * newImaginaryMembers( const ast::TupleType * inst ) {
     912                        auto ret = new MemberList();
     913                        ret->reserve( inst->types.size() );
     914                        for ( const ast::Type * type : inst->types ) {
     915                                ret->emplace_back( new ast::ObjectDecl(
     916                                        CodeLocation(), "", type,
     917                                        new ast::ListInit( CodeLocation(), {}, {}, ast::NoConstruct )
     918                                ) );
     919                        }
     920                        return ret;
     921                }
     922
    901923        public:
    902924                TupleIterator( const CodeLocation & loc, const TupleType * inst )
    903                 : AggregateIterator(
    904                         loc, "TupleIterator", toString("Tuple", inst->size()), inst, inst->members
    905                 ) {}
     925                : TupleIterator( loc, inst, newImaginaryMembers( inst ) ) {}
     926
     927                virtual ~TupleIterator() {
     928                        delete memberList;
     929                }
    906930
    907931                operator bool() const override {
Note: See TracChangeset for help on using the changeset viewer.