Changeset fac05b3
- Timestamp:
- Apr 6, 2023, 4:09:24 PM (20 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 485393c
- Parents:
- c468150
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
rc468150 rfac05b3 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
rc468150 rfac05b3 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
rc468150 rfac05b3 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
rc468150 rfac05b3 10 10 // Created On : Tue Jun 13 15:28:32 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 1 09:16:01 202213 // Update Count : 1 512 // Last Modified On : Thu Apr 6 16:03:00 2023 13 // Update Count : 16 14 14 // 15 15 … … 899 899 900 900 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 901 923 public: 902 924 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 } 906 930 907 931 operator bool() const override {
Note: See TracChangeset
for help on using the changeset viewer.