Changes in / [8472c6c:beabdf3]
- Location:
- src
- Files:
-
- 5 edited
-
AST/Pass.impl.hpp (modified) (1 diff)
-
AST/Type.cpp (modified) (2 diffs)
-
AST/Type.hpp (modified) (2 diffs)
-
ResolvExpr/CurrentObject.cc (modified) (4 diffs)
-
ResolvExpr/CurrentObject.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r8472c6c rbeabdf3 2042 2042 if ( __visit_children() ) { 2043 2043 maybe_accept( node, &TupleType::types ); 2044 maybe_accept( node, &TupleType::members ); 2044 2045 } 2045 2046 -
src/AST/Type.cpp
r8472c6c rbeabdf3 10 10 // Created On : Mon May 13 15:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Apr 6 15:59:00 202313 // Update Count : 712 // Last Modified On : Thu Nov 24 9:49:00 2022 13 // Update Count : 6 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) ) {} 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 } 202 220 203 221 bool isUnboundType(const Type * type) { -
src/AST/Type.hpp
r8472c6c rbeabdf3 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Apr 6 15:58:00 202313 // Update Count : 912 // Last Modified On : Thu Nov 24 9:47:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 457 457 public: 458 458 std::vector<ptr<Type>> types; 459 std::vector<ptr<Decl>> members; 459 460 460 461 TupleType( std::vector<ptr<Type>> && ts, CV::Qualifiers q = {} ); -
src/ResolvExpr/CurrentObject.cc
r8472c6c rbeabdf3 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Jun 13 15:28:32 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Apr 6 16:25:00 202313 // Update Count : 1 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 1 09:16:01 2022 13 // Update Count : 15 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 the611 /// 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 init630 /// alternative, but adding designators in operator* creates duplicates.631 virtual std::deque< InitAlternative > first() const = 0;632 };633 634 595 /// create a new MemberIterator that traverses a type correctly 635 596 MemberIterator * createMemberIterator( const CodeLocation & loc, const Type * type ); … … 723 684 724 685 void setPosition( 725 std::deque< ast::ptr<ast::Expr>>::const_iterator begin,726 std::deque< ast::ptr<ast::Expr>>::const_iterator end686 std::deque< ptr< Expr > >::const_iterator begin, 687 std::deque< ptr< Expr > >::const_iterator end 727 688 ) override { 728 689 if ( begin == end ) return; … … 938 899 939 900 class TupleIterator final : public AggregateIterator { 940 MemberList * memberList; 941 942 TupleIterator( const CodeLocation & loc, 943 const ast::TupleType * inst, MemberList * memberList ) 901 public: 902 TupleIterator( const CodeLocation & loc, const TupleType * inst ) 944 903 : 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 962 public: 963 TupleIterator( const CodeLocation & loc, const TupleType * inst ) 964 : TupleIterator( loc, inst, newImaginaryMembers( inst ) ) {} 965 966 virtual ~TupleIterator() { 967 delete memberList; 968 } 904 loc, "TupleIterator", toString("Tuple", inst->size()), inst, inst->members 905 ) {} 969 906 970 907 operator bool() const override { -
src/ResolvExpr/CurrentObject.h
r8472c6c rbeabdf3 9 9 // Author : Rob Schluntz 10 10 // Created On : Thu Jun 8 11:07:25 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thu Apr 6 16:14:00 202313 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:36:48 2017 13 // Update Count : 3 14 14 // 15 15 … … 65 65 66 66 /// Iterates members of a type by initializer 67 class MemberIterator; 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 }; 68 104 69 105 /// Builds initializer lists in resolution
Note:
See TracChangeset
for help on using the changeset viewer.