Changeset 58fe85a for src/AST/Type.cpp
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Type.cpp
r3c64c668 r58fe85a 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon May 13 15:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Dec 15 16:56:28 201913 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jul 23 14:16:00 2020 13 // Update Count : 5 14 14 // 15 15 … … 22 22 #include "Decl.hpp" 23 23 #include "Init.hpp" 24 #include "Common/utility.h" // for copy, move 24 25 #include "InitTweak/InitTweak.h" // for getPointerBase 25 26 #include "Tuples/Tuples.h" // for isTtype … … 91 92 92 93 // --- FunctionType 93 94 94 namespace { 95 bool containsTtype( const std::vector<ptr< DeclWithType>> & l ) {95 bool containsTtype( const std::vector<ptr<Type>> & l ) { 96 96 if ( ! l.empty() ) { 97 return Tuples::isTtype( l.back() ->get_type());97 return Tuples::isTtype( l.back() ); 98 98 } 99 99 return false; … … 105 105 } 106 106 107 // --- ReferenceToType 108 std::vector<readonly<Decl>> ReferenceToType::lookup( const std::string& name ) const { 107 std::vector<readonly<Decl>> BaseInstType::lookup( const std::string& name ) const { 109 108 assertf( aggr(), "Must have aggregate to perform lookup" ); 110 109 … … 116 115 } 117 116 118 // --- S tructInstType117 // --- SueInstType (StructInstType, UnionInstType, EnumInstType) 119 118 120 StructInstType::StructInstType( const StructDecl * b, CV::Qualifiers q, 121 std::vector<ptr<Attribute>>&& as ) 122 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {} 119 template<typename decl_t> 120 SueInstType<decl_t>::SueInstType( 121 const decl_t * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 122 : BaseInstType( b->name, q, move(as) ), base( b ) {} 123 123 124 bool StructInstType::isComplete() const { return base ? base->body : false; } 124 template<typename decl_t> 125 SueInstType<decl_t>::SueInstType( 126 const base_type * b, std::vector<ptr<Expr>> && params, 127 CV::Qualifiers q, std::vector<ptr<Attribute>> && as ) 128 : BaseInstType( b->name, std::move(params), q, std::move(as) ), base( b ) {} 125 129 126 // --- UnionInstType 130 template<typename decl_t> 131 bool SueInstType<decl_t>::isComplete() const { 132 return base ? base->body : false; 133 } 127 134 128 UnionInstType::UnionInstType( const UnionDecl * b, CV::Qualifiers q, 129 std::vector<ptr<Attribute>>&& as ) 130 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {} 131 132 bool UnionInstType::isComplete() const { return base ? base->body : false; } 133 134 // --- EnumInstType 135 136 EnumInstType::EnumInstType( const EnumDecl * b, CV::Qualifiers q, 137 std::vector<ptr<Attribute>>&& as ) 138 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {} 139 140 bool EnumInstType::isComplete() const { return base ? base->body : false; } 135 template class SueInstType<StructDecl>; 136 template class SueInstType<UnionDecl>; 137 template class SueInstType<EnumDecl>; 141 138 142 139 // --- TraitInstType 143 140 144 TraitInstType::TraitInstType( const TraitDecl * b, CV::Qualifiers q, 145 std::vector<ptr<Attribute>>&& as ) 146 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {} 147 148 // --- TypeInstType 141 TraitInstType::TraitInstType( 142 const TraitDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 143 : BaseInstType( b->name, q, move(as) ), base( b ) {} 149 144 150 145 void TypeInstType::set_base( const TypeDecl * b ) { … … 158 153 159 154 TupleType::TupleType( std::vector<ptr<Type>> && ts, CV::Qualifiers q ) 160 : Type( q ), types( std::move(ts) ), members() {155 : Type( q ), types( move(ts) ), members() { 161 156 // This constructor is awkward. `TupleType` needs to contain objects so that members can be 162 157 // named, but members without initializer nodes end up getting constructors, which breaks … … 173 168 for ( const Type * ty : types ) { 174 169 members.emplace_back( new ObjectDecl{ 175 CodeLocation{}, "", ty, new ListInit( CodeLocation{}, {}, {}, MaybeConstruct ),170 CodeLocation{}, "", ty, new ListInit( CodeLocation{}, {}, {}, NoConstruct ), 176 171 Storage::Classes{}, Linkage::Cforall } ); 177 172 } 173 } 174 175 bool isUnboundType(const Type * type) { 176 if (auto typeInst = dynamic_cast<const TypeInstType *>(type)) { 177 // xxx - look for a type name produced by renameTyVars. 178 179 // TODO: once TypeInstType representation is updated, it should properly check 180 // if the context id is filled. this is a temporary hack for now 181 return typeInst->formal_usage > 0; 182 } 183 return false; 178 184 } 179 185
Note:
See TracChangeset
for help on using the changeset viewer.