- Timestamp:
- Apr 8, 2023, 3:50:53 PM (16 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 372b6d3, ea2759b
- Parents:
- beabdf3 (diff), 485393c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
rbeabdf3 r8472c6c 2042 2042 if ( __visit_children() ) { 2043 2043 maybe_accept( node, &TupleType::types ); 2044 maybe_accept( node, &TupleType::members );2045 2044 } 2046 2045 -
src/AST/Type.cpp
rbeabdf3 r8472c6c 10 10 // Created On : Mon May 13 15:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Nov 24 9:49:00 202213 // Update Count : 612 // Last Modified On : Thu Apr 6 15:59:00 2023 13 // Update Count : 7 14 14 // 15 15 … … 199 199 200 200 TupleType::TupleType( std::vector<ptr<Type>> && ts, CV::Qualifiers q ) 201 : Type( q ), types( std::move(ts) ), members() { 202 // This constructor is awkward. `TupleType` needs to contain objects so that members can be 203 // named, but members without initializer nodes end up getting constructors, which breaks 204 // things. This happens because the object decls have to be visited so that their types are 205 // kept in sync with the types listed here. Ultimately, the types listed here should perhaps 206 // be eliminated and replaced with a list-view over members. The temporary solution is to 207 // make a `ListInit` with `maybeConstructed = false`, so when the object is visited it is not 208 // constructed. Potential better solutions include: 209 // a) Separate `TupleType` from its declarations, into `TupleDecl` and `Tuple{Inst?}Type`, 210 // similar to the aggregate types. 211 // b) Separate initializer nodes better, e.g. add a `MaybeConstructed` node that is replaced 212 // by `genInit`, rather than the current boolean flag. 213 members.reserve( types.size() ); 214 for ( const Type * ty : types ) { 215 members.emplace_back( new ObjectDecl{ 216 CodeLocation(), "", ty, new ListInit( CodeLocation(), {}, {}, NoConstruct ), 217 Storage::Classes{}, Linkage::Cforall } ); 218 } 219 } 201 : Type( q ), types( std::move(ts) ) {} 220 202 221 203 bool isUnboundType(const Type * type) { -
src/AST/Type.hpp
rbeabdf3 r8472c6c 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Nov 24 9:47:00 202213 // Update Count : 812 // Last Modified On : Thu Apr 6 15:58:00 2023 13 // Update Count : 9 14 14 // 15 15 … … 457 457 public: 458 458 std::vector<ptr<Type>> types; 459 std::vector<ptr<Decl>> members;460 459 461 460 TupleType( std::vector<ptr<Type>> && ts, CV::Qualifiers q = {} ); -
src/ResolvExpr/CurrentObject.cc
rbeabdf3 r8472c6c 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Jun 13 15:28:32 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 1 09:16:01 202213 // Update Count : 1 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Apr 6 16:25:00 2023 13 // Update Count : 17 14 14 // 15 15 … … 593 593 594 594 namespace ast { 595 /// Iterates members of a type by initializer. 596 class MemberIterator { 597 public: 598 virtual ~MemberIterator() {} 599 600 /// Internal set position based on iterator ranges. 601 virtual void setPosition( 602 std::deque< ptr< Expr > >::const_iterator it, 603 std::deque< ptr< Expr > >::const_iterator end ) = 0; 604 605 /// Walks the current object using the given designators as a guide. 606 void setPosition( const std::deque< ptr< Expr > > & designators ) { 607 setPosition( designators.begin(), designators.end() ); 608 } 609 610 /// Retrieve the list of possible (Type,Designation) pairs for the 611 /// current position in the current object. 612 virtual std::deque< InitAlternative > operator* () const = 0; 613 614 /// True if the iterator is not currently at the end. 615 virtual operator bool() const = 0; 616 617 /// Moves the iterator by one member in the current object. 618 virtual MemberIterator & bigStep() = 0; 619 620 /// Moves the iterator by one member in the current subobject. 621 virtual MemberIterator & smallStep() = 0; 622 623 /// The type of the current object. 624 virtual const Type * getType() = 0; 625 626 /// The type of the current subobject. 627 virtual const Type * getNext() = 0; 628 629 /// Helper for operator*; aggregates must add designator to each init 630 /// alternative, but adding designators in operator* creates duplicates. 631 virtual std::deque< InitAlternative > first() const = 0; 632 }; 633 595 634 /// create a new MemberIterator that traverses a type correctly 596 635 MemberIterator * createMemberIterator( const CodeLocation & loc, const Type * type ); … … 684 723 685 724 void setPosition( 686 std::deque< ptr< Expr >>::const_iterator begin,687 std::deque< ptr< Expr >>::const_iterator end725 std::deque<ast::ptr<ast::Expr>>::const_iterator begin, 726 std::deque<ast::ptr<ast::Expr>>::const_iterator end 688 727 ) override { 689 728 if ( begin == end ) return; … … 899 938 900 939 class TupleIterator final : public AggregateIterator { 940 MemberList * memberList; 941 942 TupleIterator( const CodeLocation & loc, 943 const ast::TupleType * inst, MemberList * memberList ) 944 : AggregateIterator( 945 loc, "TupleIterator", toString("Tuple", inst->size()), inst, *memberList 946 ), memberList( memberList ) {} 947 948 // The two layer constructor, this helper and the destructor 949 // are all to pretend that Tuples have members (they do not). 950 static MemberList * newImaginaryMembers( const ast::TupleType * inst ) { 951 auto ret = new MemberList(); 952 ret->reserve( inst->types.size() ); 953 for ( const ast::Type * type : inst->types ) { 954 ret->emplace_back( new ast::ObjectDecl( 955 CodeLocation(), "", type, 956 new ast::ListInit( CodeLocation(), {}, {}, ast::NoConstruct ) 957 ) ); 958 } 959 return ret; 960 } 961 901 962 public: 902 963 TupleIterator( const CodeLocation & loc, const TupleType * inst ) 903 : AggregateIterator( 904 loc, "TupleIterator", toString("Tuple", inst->size()), inst, inst->members 905 ) {} 964 : TupleIterator( loc, inst, newImaginaryMembers( inst ) ) {} 965 966 virtual ~TupleIterator() { 967 delete memberList; 968 } 906 969 907 970 operator bool() const override { -
src/ResolvExpr/CurrentObject.h
rbeabdf3 r8472c6c 9 9 // Author : Rob Schluntz 10 10 // Created On : Thu Jun 8 11:07:25 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:36:48 201713 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Apr 6 16:14:00 2023 13 // Update Count : 4 14 14 // 15 15 … … 65 65 66 66 /// Iterates members of a type by initializer 67 class MemberIterator { 68 public: 69 virtual ~MemberIterator() {} 70 71 /// Internal set position based on iterator ranges 72 virtual void setPosition( 73 std::deque< ptr< Expr > >::const_iterator it, 74 std::deque< ptr< Expr > >::const_iterator end ) = 0; 75 76 /// walks the current object using the given designators as a guide 77 void setPosition( const std::deque< ptr< Expr > > & designators ) { 78 setPosition( designators.begin(), designators.end() ); 79 } 80 81 /// retrieve the list of possible (Type,Designation) pairs for the current position in the 82 /// current object 83 virtual std::deque< InitAlternative > operator* () const = 0; 84 85 /// true if the iterator is not currently at the end 86 virtual operator bool() const = 0; 87 88 /// moves the iterator by one member in the current object 89 virtual MemberIterator & bigStep() = 0; 90 91 /// moves the iterator by one member in the current subobject 92 virtual MemberIterator & smallStep() = 0; 93 94 /// the type of the current object 95 virtual const Type * getType() = 0; 96 97 /// the type of the current subobject 98 virtual const Type * getNext() = 0; 99 100 /// helper for operator*; aggregates must add designator to each init alternative, but 101 /// adding designators in operator* creates duplicates 102 virtual std::deque< InitAlternative > first() const = 0; 103 }; 67 class MemberIterator; 104 68 105 69 /// Builds initializer lists in resolution
Note: See TracChangeset
for help on using the changeset viewer.