Changeset e0e9a0b for src/AST/Type.cpp
- Timestamp:
- Jun 27, 2019, 5:16:54 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7d0881c
- Parents:
- 6be3b7d6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Type.cpp
r6be3b7d6 re0e9a0b 21 21 22 22 #include "Decl.hpp" 23 #include "ForallSubstitutor.hpp" // for substituteForall 23 24 #include "Init.hpp" 25 #include "Common/utility.h" // for copy, move 24 26 #include "InitTweak/InitTweak.h" // for getPointerBase 25 27 #include "Tuples/Tuples.h" // for isTtype … … 91 93 ); 92 94 95 // --- ParameterizedType 96 97 void ParameterizedType::initWithSub( 98 const ParameterizedType & o, Pass< ForallSubstitutor > & sub 99 ) { 100 forall = sub.pass( o.forall ); 101 } 102 93 103 // --- FunctionType 104 105 FunctionType::FunctionType( const FunctionType & o ) 106 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), returns(), params(), 107 isVarArgs( o.isVarArgs ) { 108 Pass< ForallSubstitutor > sub; 109 initWithSub( o, sub ); // initialize substitution map 110 returns = sub.pass( o.returns ); // apply to return and parameter types 111 params = sub.pass( o.params ); 112 } 94 113 95 114 namespace { … … 107 126 108 127 // --- ReferenceToType 128 129 void ReferenceToType::initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub ) { 130 ParameterizedType::initWithSub( o, sub ); // initialize substitution 131 params = sub.pass( o.params ); // apply to parameters 132 } 133 134 ReferenceToType::ReferenceToType( const ReferenceToType & o ) 135 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), params(), name( o.name ), 136 hoistType( o.hoistType ) { 137 Pass< ForallSubstitutor > sub; 138 initWithSub( o, sub ); 139 } 140 109 141 std::vector<readonly<Decl>> ReferenceToType::lookup( const std::string& name ) const { 110 142 assertf( aggr(), "Must have aggregate to perform lookup" ); … … 119 151 // --- StructInstType 120 152 121 StructInstType::StructInstType( const StructDecl * b, CV::Qualifiers q,122 std::vector<ptr<Attribute>>&& as )123 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {}153 StructInstType::StructInstType( 154 const StructDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 155 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 124 156 125 157 bool StructInstType::isComplete() const { return base ? base->body : false; } … … 127 159 // --- UnionInstType 128 160 129 UnionInstType::UnionInstType( const UnionDecl * b, CV::Qualifiers q,130 std::vector<ptr<Attribute>>&& as )131 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {}161 UnionInstType::UnionInstType( 162 const UnionDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 163 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 132 164 133 165 bool UnionInstType::isComplete() const { return base ? base->body : false; } … … 135 167 // --- EnumInstType 136 168 137 EnumInstType::EnumInstType( const EnumDecl * b, CV::Qualifiers q,138 std::vector<ptr<Attribute>>&& as )139 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {}169 EnumInstType::EnumInstType( 170 const EnumDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 171 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 140 172 141 173 bool EnumInstType::isComplete() const { return base ? base->body : false; } … … 143 175 // --- TraitInstType 144 176 145 TraitInstType::TraitInstType( const TraitDecl * b, CV::Qualifiers q,146 std::vector<ptr<Attribute>>&& as )147 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {}177 TraitInstType::TraitInstType( 178 const TraitDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 179 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 148 180 149 181 // --- TypeInstType 182 183 TypeInstType::TypeInstType( const TypeInstType & o ) 184 : ReferenceToType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) { 185 Pass< ForallSubstitutor > sub; 186 initWithSub( o, sub ); // initialize substitution 187 base = sub.pass( o.base ); // apply to base type 188 } 150 189 151 190 void TypeInstType::set_base( const TypeDecl * b ) { … … 159 198 160 199 TupleType::TupleType( std::vector<ptr<Type>> && ts, CV::Qualifiers q ) 161 : Type( q ), types( std::move(ts) ), members() {200 : Type( q ), types( move(ts) ), members() { 162 201 // This constructor is awkward. `TupleType` needs to contain objects so that members can be 163 202 // named, but members without initializer nodes end up getting constructors, which breaks
Note: See TracChangeset
for help on using the changeset viewer.