- Timestamp:
- May 23, 2019, 11:35:04 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 20a5977, effe5b0
- Parents:
- b0ec971 (diff), 3ca912a (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. - git-author:
- Aaron Moss <a3moss@…> (05/23/19 11:34:34)
- git-committer:
- Aaron Moss <a3moss@…> (05/23/19 11:35:04)
- Location:
- src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Attribute.cpp
rb0ec971 r68c9165 28 28 auto end = name.find_last_not_of('_'); 29 29 if ( begin == std::string::npos || end == std::string::npos ) return ""; 30 30 31 31 // convert to lowercase 32 32 std::string ret; -
src/AST/Convert.cpp
rb0ec971 r68c9165 1130 1130 const ast::Type * visit( const ast::FunctionType * node ) override final { 1131 1131 auto ty = new FunctionType { 1132 cv( node ), 1132 cv( node ), 1133 1133 (bool)node->isVarArgs 1134 1134 }; … … 1338 1338 // TypeSubstitution is not a node in the old model, so the conversion result wouldn't fit in this->node. 1339 1339 assert( 0 ); 1340 (void)node; 1340 1341 return nullptr; 1341 1342 } … … 1409 1410 # define GET_LABELS_V(labels) \ 1410 1411 to<std::vector>::from( make_labels( std::move( labels ) ) ) 1411 1412 1412 1413 static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; } 1413 1414 … … 1549 1550 1550 1551 virtual void visit( TypeDecl * old ) override final { 1551 if ( inCache( old ) ) return; 1552 if ( inCache( old ) ) return; 1552 1553 auto decl = new ast::TypeDecl{ 1553 1554 old->location, … … 1587 1588 virtual void visit( AsmDecl * old ) override final { 1588 1589 auto decl = new ast::AsmDecl{ 1589 old->location, 1590 old->location, 1590 1591 GET_ACCEPT_1(stmt, AsmStmt) 1591 1592 }; … … 2142 2143 rslt = new ast::ConstantExpr( 2143 2144 old->location, 2144 GET_ACCEPT_1(result, Type), 2145 old->constant.get_value(), 2145 GET_ACCEPT_1(result, Type), 2146 old->constant.get_value(), 2146 2147 (double) old->constant.get_dval() 2147 2148 ); … … 2163 2164 assert(!old->isType); 2164 2165 rslt = new ast::SizeofExpr( 2165 old->location, 2166 old->location, 2166 2167 GET_ACCEPT_1(expr, Expr) 2167 2168 ); … … 2170 2171 assert(old->isType); 2171 2172 rslt = new ast::SizeofExpr( 2172 old->location, 2173 old->location, 2173 2174 GET_ACCEPT_1(type, Type) 2174 2175 ); … … 2184 2185 assert(!old->isType); 2185 2186 rslt = new ast::AlignofExpr( 2186 old->location, 2187 old->location, 2187 2188 GET_ACCEPT_1(expr, Expr) 2188 2189 ); … … 2191 2192 assert(old->isType); 2192 2193 rslt = new ast::AlignofExpr( 2193 old->location, 2194 old->location, 2194 2195 GET_ACCEPT_1(type, Type) 2195 2196 ); … … 2235 2236 GET_ACCEPT_1(arg1, Expr), 2236 2237 GET_ACCEPT_1(arg2, Expr), 2237 old->get_isAnd() ? 2238 old->get_isAnd() ? 2238 2239 ast::LogicalFlag::AndExpr : 2239 2240 ast::LogicalFlag::OrExpr -
src/AST/Expr.cpp
rb0ec971 r68c9165 159 159 assert( aggregate->result ); 160 160 161 #warning Needs GenericSubsitution.cpp building to work correctly 162 result.set_and_mutate( mem->get_type() )->qualifiers |= aggregate->result->qualifiers | CV::Lvalue; // FIXME temporary patch 163 164 // // take ownership of member type 165 // result = mem->get_type(); 166 // // substitute aggregate generic parameters into member type 167 // genericSubsitution( aggregate->result ).apply( result ); 168 // // ensure lvalue and appropriate restrictions from aggregate type 169 // result.get_and_mutate()->qualifiers |= aggregate->result->qualifiers | CV::Lvalue; 161 // take ownership of member type 162 result = mem->get_type(); 163 // substitute aggregate generic parameters into member type 164 genericSubsitution( aggregate->result ).apply( result ); 165 // ensure lvalue and appropriate restrictions from aggregate type 166 result.get_and_mutate()->qualifiers |= aggregate->result->qualifiers | CV::Lvalue; 170 167 } 171 168 … … 345 342 } 346 343 347 TupleAssignExpr::TupleAssignExpr( 344 TupleAssignExpr::TupleAssignExpr( 348 345 const CodeLocation & loc, const Type * result, const StmtExpr * s ) 349 346 : Expr( loc, result ), stmtExpr() { -
src/AST/GenericSubstitution.cpp
rb0ec971 r68c9165 23 23 #include "Pass.hpp" 24 24 #include "Type.hpp" 25 #include "TypeSubstitution. cpp"25 #include "TypeSubstitution.hpp" 26 26 27 27 namespace ast { … … 32 32 33 33 void previsit( const Type * ty ) { 34 assertf( false, "Attempted generic substitution for non-aggregate type: %s", 34 assertf( false, "Attempted generic substitution for non-aggregate type: %s", 35 35 toString( ty ).c_str() ); 36 36 } 37 37 38 void previsit( const ReferenceType * ty) {38 void previsit( const ReferenceType * ) { 39 39 // do nothing; allows substitution from base type 40 40 } -
src/AST/Pass.hpp
rb0ec971 r68c9165 178 178 const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) override final; 179 179 180 friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_t>& visitor ); 180 template<typename pass_type> 181 friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_type>& visitor ); 181 182 private: 182 183 -
src/AST/Pass.proto.hpp
rb0ec971 r68c9165 115 115 static constexpr bool value = std::is_void< ret_t >::value || 116 116 std::is_base_of<const node_t, typename std::remove_pointer<ret_t>::type >::value; 117 }; 118 119 template<bool is_void> 120 struct __assign; 121 122 template<> 123 struct __assign<true> { 124 template<typename pass_t, typename node_t> 125 static inline void result( pass_t & pass, const node_t * & node ) { 126 pass.previsit( node ); 127 } 128 }; 129 130 template<> 131 struct __assign<false> { 132 template<typename pass_t, typename node_t> 133 static inline void result( pass_t & pass, const node_t * & node ) { 134 node = pass.previsit( node ); 135 assertf(node, "Previsit must not return NULL"); 136 } 117 137 }; 118 138 … … 138 158 "Previsit may not change the type of the node. It must return its paremeter or void." 139 159 ); 140 if(std::is_void< decltype( pass.previsit(node) ) >::value) { 141 pass.previsit( node );142 } else {143 node = pass.previsit( node );144 assert(node);145 }160 161 __assign< 162 std::is_void< 163 decltype( pass.previsit( node ) ) 164 >::value 165 >::result( pass, node ); 146 166 } 147 167 -
src/AST/Print.cpp
rb0ec971 r68c9165 22 22 #include "TypeSubstitution.hpp" 23 23 24 #include "Common/utility.h" // for group_iterate 24 #include "Common/utility.h" // for group_iterate 25 26 using namespace std; 25 27 26 28 namespace ast { … … 28 30 template <typename C, typename... T> 29 31 constexpr auto make_array(T&&... values) -> 30 std::array<C,sizeof...(T)>32 array<C,sizeof...(T)> 31 33 { 32 return std::array<C,sizeof...(T)>{33 std::forward<T>(values)...34 return array<C,sizeof...(T)>{ 35 forward<T>(values)... 34 36 }; 35 37 } … … 37 39 class Printer : public Visitor { 38 40 public: 39 std::ostream & os;41 ostream & os; 40 42 Indenter indent; 41 42 Printer(std::ostream & os, Indenter indent) : os( os ), indent( indent ) {} 43 bool short_mode; 44 45 Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {} 43 46 44 47 private: … … 51 54 // need an endl after each element because it's not 52 55 // easy to know when each individual item should end 53 os << std::endl;56 os << endl; 54 57 } // if 55 58 } // for … … 74 77 75 78 template<typename storage_t, size_t N> 76 void print(const storage_t & storage, const std::array<const char *, N> & Names ) {79 void print(const storage_t & storage, const array<const char *, N> & Names ) { 77 80 if ( storage.any() ) { 78 81 for ( size_t i = 0; i < Names.size(); i += 1 ) { … … 135 138 print( node->qualifiers ); 136 139 } 140 141 void print( const ast::AggregateDecl * node ) { 142 os << node->typeString() << " " << node->name << ":"; 143 if ( node->linkage != Linkage::Cforall ) { 144 os << " " << Linkage::name( node->linkage ); 145 } // if 146 os << " with body : " << (node->body ? "yes " : "no "); 147 148 if ( ! node->params.empty() ) { 149 os << endl << indent << "... with parameters" << endl; 150 ++indent; 151 printAll( node->params ); 152 --indent; 153 } // if 154 if ( ! node->members.empty() ) { 155 os << endl << indent << "... with members" << endl; 156 ++indent; 157 printAll( node->members ); 158 --indent; 159 } // if 160 if ( ! node->attributes.empty() ) { 161 os << endl << indent << "... with attributes" << endl; 162 ++indent; 163 printAll( node->attributes ); 164 --indent; 165 } // if 166 os << endl; 167 } 168 169 void print( const ast::NamedTypeDecl * node ) { 170 if ( !node->name.empty() ) os << node->name << ": "; 171 172 if ( node->linkage != Linkage::Cforall ) { 173 os << Linkage::name( node->linkage ) << " "; 174 } // if 175 print( node->storage ); 176 os << node->typeString(); 177 if ( node->base ) { 178 os << " for "; 179 ++indent; 180 node->base->accept( *this ); 181 --indent; 182 } // if 183 if ( ! node->params.empty() ) { 184 os << endl << indent << "... with parameters" << endl; 185 ++indent; 186 printAll( node->params ); 187 --indent; 188 } // if 189 if ( ! node->assertions.empty() ) { 190 os << endl << indent << "... with assertions" << endl; 191 ++indent; 192 printAll( node->assertions ); 193 --indent; 194 } // if 195 } 137 196 138 197 public: 139 virtual const ast::DeclWithType * visit( const ast::ObjectDecl* node ) {140 if ( node->name != "") os << node->name << ": ";198 virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) { 199 if ( !node->name.empty() ) os << node->name << ": "; 141 200 142 201 if ( node->linkage != Linkage::Cforall ) { … … 157 216 ? "maybe constructed" 158 217 : "not constructed" 159 ) << ")" << std::endl << indent+1;218 ) << ")" << endl << indent+1; 160 219 161 220 ++indent; 162 221 node->init->accept( *this ); 163 222 --indent; 164 os << std::endl;223 os << endl; 165 224 } // if 166 225 167 226 if ( ! node->attributes.empty() ) { 168 os << std::endl << indent << "... with attributes:" << std::endl;227 os << endl << indent << "... with attributes:" << endl; 169 228 ++indent; 170 229 printAll( node->attributes ); … … 179 238 } 180 239 181 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) { 182 return node; 183 } 184 185 virtual const ast::Decl * visit( const ast::StructDecl * node ) { 186 return node; 187 } 188 189 virtual const ast::Decl * visit( const ast::UnionDecl * node ) { 190 return node; 191 } 192 193 virtual const ast::Decl * visit( const ast::EnumDecl * node ) { 194 return node; 195 } 196 197 virtual const ast::Decl * visit( const ast::TraitDecl * node ) { 198 return node; 199 } 200 201 virtual const ast::Decl * visit( const ast::TypeDecl * node ) { 202 return node; 203 } 204 205 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) { 206 return node; 207 } 208 209 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) { 210 return node; 211 } 212 213 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) { 214 return node; 215 } 216 217 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) { 218 return node; 219 } 220 221 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) { 222 return node; 223 } 224 225 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) { 226 return node; 227 } 228 229 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) { 230 return node; 231 } 232 233 virtual const ast::Stmt * visit( const ast::IfStmt * node ) { 234 return node; 235 } 236 237 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) { 238 return node; 239 } 240 241 virtual const ast::Stmt * visit( const ast::ForStmt * node ) { 242 return node; 243 } 244 245 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) { 246 return node; 247 } 248 249 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) { 250 return node; 251 } 252 253 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) { 254 return node; 255 } 256 257 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) { 258 return node; 259 } 260 261 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) { 262 return node; 263 } 264 265 virtual const ast::Stmt * visit( const ast::TryStmt * node ) { 266 return node; 267 } 268 269 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) { 270 return node; 271 } 272 273 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) { 274 return node; 275 } 276 277 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) { 278 return node; 279 } 280 281 virtual const ast::Stmt * visit( const ast::WithStmt * node ) { 282 return node; 283 } 284 285 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) { 286 return node; 287 } 288 289 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) { 290 return node; 291 } 292 293 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) { 294 return node; 295 } 296 297 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) { 298 return node; 299 } 300 301 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) { 302 return node; 303 } 304 305 virtual const ast::Expr * visit( const ast::NameExpr * node ) { 306 return node; 307 } 308 309 virtual const ast::Expr * visit( const ast::AddressExpr * node ) { 310 return node; 311 } 312 313 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) { 314 return node; 315 } 316 317 virtual const ast::Expr * visit( const ast::CastExpr * node ) { 318 return node; 319 } 320 321 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) { 322 return node; 323 } 324 325 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) { 326 return node; 327 } 328 329 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) { 330 return node; 331 } 332 333 virtual const ast::Expr * visit( const ast::MemberExpr * node ) { 334 return node; 335 } 336 337 virtual const ast::Expr * visit( const ast::VariableExpr * node ) { 338 return node; 339 } 340 341 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) { 342 return node; 343 } 344 345 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) { 346 return node; 347 } 348 349 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) { 350 return node; 351 } 352 353 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) { 354 return node; 355 } 356 357 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) { 358 return node; 359 } 360 361 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) { 362 return node; 363 } 364 365 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) { 366 return node; 367 } 368 369 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) { 370 return node; 371 } 372 373 virtual const ast::Expr * visit( const ast::CommaExpr * node ) { 374 return node; 375 } 376 377 virtual const ast::Expr * visit( const ast::TypeExpr * node ) { 378 return node; 379 } 380 381 virtual const ast::Expr * visit( const ast::AsmExpr * node ) { 382 return node; 383 } 384 385 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) { 386 return node; 387 } 388 389 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) { 390 return node; 391 } 392 393 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) { 394 return node; 395 } 396 397 virtual const ast::Expr * visit( const ast::RangeExpr * node ) { 398 return node; 399 } 400 401 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) { 402 return node; 403 } 404 405 virtual const ast::Expr * visit( const ast::TupleExpr * node ) { 406 return node; 407 } 408 409 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) { 410 return node; 411 } 412 413 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) { 414 return node; 415 } 416 417 virtual const ast::Expr * visit( const ast::StmtExpr * node ) { 418 return node; 419 } 420 421 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) { 422 return node; 423 } 424 425 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) { 426 return node; 427 } 428 429 virtual const ast::Expr * visit( const ast::InitExpr * node ) { 430 return node; 431 } 432 433 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) { 434 return node; 435 } 436 437 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) { 438 return node; 439 } 440 441 virtual const ast::Expr * visit( const ast::GenericExpr * node ) { 442 return node; 443 } 444 445 virtual const ast::Type * visit( const ast::VoidType * node ) { 240 virtual const ast::DeclWithType * visit( const ast::FunctionDecl * node ) { 241 if ( !node->name.empty() ) { 242 os << node->name << ": "; 243 } // if 244 if ( node->linkage != Linkage::Cforall ) { 245 os << Linkage::name( node->linkage ) << " "; 246 } // if 247 248 printAll( node->attributes ); 249 250 print( node->storage ); 251 print( node->funcSpec ); 252 253 if ( node->type ) { 254 node->type->accept( *this ); 255 } else { 256 os << "untyped entity "; 257 } // if 258 259 if ( node->stmts ) { 260 os << indent << "... with body" << endl << indent+1; 261 ++indent; 262 node->stmts->accept( *this ); 263 --indent; 264 } // if 265 return node; 266 } 267 268 virtual const ast::Decl * visit( const ast::StructDecl * node ) { 269 print(node); 270 return node; 271 } 272 273 virtual const ast::Decl * visit( const ast::UnionDecl * node ) { 274 print(node); 275 return node; 276 } 277 278 virtual const ast::Decl * visit( const ast::EnumDecl * node ) { 279 print(node); 280 return node; 281 } 282 283 virtual const ast::Decl * visit( const ast::TraitDecl * node ) { 284 print(node); 285 return node; 286 } 287 288 virtual const ast::Decl * visit( const ast::TypeDecl * node ) { 289 print( node ); 290 if ( node->init ) { 291 os << endl << indent << "with type initializer: "; 292 ++indent; 293 node->init->accept( *this ); 294 --indent; 295 } 296 return node; 297 } 298 299 virtual const ast::Decl * visit( const ast::TypedefDecl * node ) { 300 print( node ); 301 return node; 302 } 303 304 virtual const ast::AsmDecl * visit( const ast::AsmDecl * node ) { 305 node->stmt->accept( *this ); 306 return node; 307 } 308 309 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * node ) { 310 os << "Static Assert with condition: "; 311 ++indent; 312 node->cond->accept( *this ); 313 --indent; 314 os << endl << indent << "and message: "; 315 ++indent; 316 node->msg->accept( *this ); 317 --indent; 318 os << endl; 319 return node; 320 } 321 322 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) { 323 os << "CompoundStmt" << endl; 324 ++indent; 325 printAll( node->kids ); 326 --indent; 327 return node; 328 } 329 330 virtual const ast::Stmt * visit( const ast::ExprStmt * node ) { 331 ++indent; 332 os << "Expression Statement:" << endl << indent; 333 node->expr->accept( *this ); 334 --indent; 335 return node; 336 } 337 338 virtual const ast::Stmt * visit( const ast::AsmStmt * node ) { 339 os << "Assembler Statement:" << endl; 340 ++indent; 341 os << indent << "instruction: " << endl << indent; 342 node->instruction->accept( *this ); 343 if ( ! node->output.empty() ) { 344 os << endl << indent+1 << "output: " << endl; 345 printAll( node->output ); 346 } // if 347 if ( ! node->input.empty() ) { 348 os << indent+1 << "input: " << endl; 349 printAll( node->input ); 350 } // if 351 if ( ! node->clobber.empty() ) { 352 os << indent+1 << "clobber: " << endl; 353 printAll( node->clobber ); 354 } // if 355 --indent; 356 return node; 357 } 358 359 virtual const ast::Stmt * visit( const ast::DirectiveStmt * node ) { 360 os << "GCC Directive:" << node->directive << endl; 361 return node; 362 } 363 364 virtual const ast::Stmt * visit( const ast::IfStmt * node ) { 365 os << "If on condition: " << endl; 366 os << indent+1; 367 ++indent; 368 node->cond->accept( *this ); 369 --indent; 370 371 if ( !node->inits.empty() ) { 372 os << indent << "... with initialization: \n"; 373 ++indent; 374 for ( const Stmt * stmt : node->inits ) { 375 os << indent; 376 stmt->accept( *this ); 377 } 378 --indent; 379 os << endl; 380 } 381 382 os << indent << "... then: " << endl; 383 384 ++indent; 385 os << indent; 386 node->thenPart->accept( *this ); 387 --indent; 388 389 if ( node->elsePart != 0 ) { 390 os << indent << "... else: " << endl; 391 ++indent; 392 os << indent; 393 node->elsePart->accept( *this ); 394 --indent; 395 } // if 396 return node; 397 } 398 399 virtual const ast::Stmt * visit( const ast::WhileStmt * node ) { 400 return node; 401 } 402 403 virtual const ast::Stmt * visit( const ast::ForStmt * node ) { 404 return node; 405 } 406 407 virtual const ast::Stmt * visit( const ast::SwitchStmt * node ) { 408 return node; 409 } 410 411 virtual const ast::Stmt * visit( const ast::CaseStmt * node ) { 412 return node; 413 } 414 415 virtual const ast::Stmt * visit( const ast::BranchStmt * node ) { 416 return node; 417 } 418 419 virtual const ast::Stmt * visit( const ast::ReturnStmt * node ) { 420 return node; 421 } 422 423 virtual const ast::Stmt * visit( const ast::ThrowStmt * node ) { 424 return node; 425 } 426 427 virtual const ast::Stmt * visit( const ast::TryStmt * node ) { 428 return node; 429 } 430 431 virtual const ast::Stmt * visit( const ast::CatchStmt * node ) { 432 return node; 433 } 434 435 virtual const ast::Stmt * visit( const ast::FinallyStmt * node ) { 436 return node; 437 } 438 439 virtual const ast::Stmt * visit( const ast::WaitForStmt * node ) { 440 return node; 441 } 442 443 virtual const ast::Stmt * visit( const ast::WithStmt * node ) { 444 return node; 445 } 446 447 virtual const ast::NullStmt * visit( const ast::NullStmt * node ) { 448 return node; 449 } 450 451 virtual const ast::Stmt * visit( const ast::DeclStmt * node ) { 452 return node; 453 } 454 455 virtual const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) { 456 return node; 457 } 458 459 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) { 460 return node; 461 } 462 463 virtual const ast::Expr * visit( const ast::UntypedExpr * node ) { 464 return node; 465 } 466 467 virtual const ast::Expr * visit( const ast::NameExpr * node ) { 468 return node; 469 } 470 471 virtual const ast::Expr * visit( const ast::AddressExpr * node ) { 472 return node; 473 } 474 475 virtual const ast::Expr * visit( const ast::LabelAddressExpr * node ) { 476 return node; 477 } 478 479 virtual const ast::Expr * visit( const ast::CastExpr * node ) { 480 return node; 481 } 482 483 virtual const ast::Expr * visit( const ast::KeywordCastExpr * node ) { 484 return node; 485 } 486 487 virtual const ast::Expr * visit( const ast::VirtualCastExpr * node ) { 488 return node; 489 } 490 491 virtual const ast::Expr * visit( const ast::UntypedMemberExpr * node ) { 492 return node; 493 } 494 495 virtual const ast::Expr * visit( const ast::MemberExpr * node ) { 496 return node; 497 } 498 499 virtual const ast::Expr * visit( const ast::VariableExpr * node ) { 500 return node; 501 } 502 503 virtual const ast::Expr * visit( const ast::ConstantExpr * node ) { 504 return node; 505 } 506 507 virtual const ast::Expr * visit( const ast::SizeofExpr * node ) { 508 return node; 509 } 510 511 virtual const ast::Expr * visit( const ast::AlignofExpr * node ) { 512 return node; 513 } 514 515 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * node ) { 516 return node; 517 } 518 519 virtual const ast::Expr * visit( const ast::OffsetofExpr * node ) { 520 return node; 521 } 522 523 virtual const ast::Expr * visit( const ast::OffsetPackExpr * node ) { 524 return node; 525 } 526 527 virtual const ast::Expr * visit( const ast::LogicalExpr * node ) { 528 return node; 529 } 530 531 virtual const ast::Expr * visit( const ast::ConditionalExpr * node ) { 532 return node; 533 } 534 535 virtual const ast::Expr * visit( const ast::CommaExpr * node ) { 536 return node; 537 } 538 539 virtual const ast::Expr * visit( const ast::TypeExpr * node ) { 540 return node; 541 } 542 543 virtual const ast::Expr * visit( const ast::AsmExpr * node ) { 544 return node; 545 } 546 547 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * node ) { 548 return node; 549 } 550 551 virtual const ast::Expr * visit( const ast::ConstructorExpr * node ) { 552 return node; 553 } 554 555 virtual const ast::Expr * visit( const ast::CompoundLiteralExpr * node ) { 556 return node; 557 } 558 559 virtual const ast::Expr * visit( const ast::RangeExpr * node ) { 560 return node; 561 } 562 563 virtual const ast::Expr * visit( const ast::UntypedTupleExpr * node ) { 564 return node; 565 } 566 567 virtual const ast::Expr * visit( const ast::TupleExpr * node ) { 568 return node; 569 } 570 571 virtual const ast::Expr * visit( const ast::TupleIndexExpr * node ) { 572 return node; 573 } 574 575 virtual const ast::Expr * visit( const ast::TupleAssignExpr * node ) { 576 return node; 577 } 578 579 virtual const ast::Expr * visit( const ast::StmtExpr * node ) { 580 return node; 581 } 582 583 virtual const ast::Expr * visit( const ast::UniqueExpr * node ) { 584 return node; 585 } 586 587 virtual const ast::Expr * visit( const ast::UntypedInitExpr * node ) { 588 return node; 589 } 590 591 virtual const ast::Expr * visit( const ast::InitExpr * node ) { 592 return node; 593 } 594 595 virtual const ast::Expr * visit( const ast::DeletedExpr * node ) { 596 return node; 597 } 598 599 virtual const ast::Expr * visit( const ast::DefaultArgExpr * node ) { 600 return node; 601 } 602 603 virtual const ast::Expr * visit( const ast::GenericExpr * node ) { 604 return node; 605 } 606 607 virtual const ast::Type * visit( const ast::VoidType * node ) { 446 608 preprint( node ); 447 609 os << "void"; … … 449 611 } 450 612 451 virtual const ast::Type * visit( const ast::BasicType* node ) {613 virtual const ast::Type * visit( const ast::BasicType * node ) { 452 614 preprint( node ); 453 615 os << ast::BasicType::typeNames[ node->kind ]; … … 455 617 } 456 618 457 virtual const ast::Type * visit( const ast::PointerType* node ) {619 virtual const ast::Type * visit( const ast::PointerType * node ) { 458 620 preprint( node ); 459 621 if ( ! node->isArray() ) { … … 482 644 } 483 645 484 virtual const ast::Type * visit( const ast::ArrayType* node ) {646 virtual const ast::Type * visit( const ast::ArrayType * node ) { 485 647 preprint( node ); 486 648 if ( node->isStatic ) { … … 510 672 } 511 673 512 virtual const ast::Type * visit( const ast::ReferenceType* node ) {674 virtual const ast::Type * visit( const ast::ReferenceType * node ) { 513 675 preprint( node ); 514 676 … … 523 685 } 524 686 525 virtual const ast::Type * visit( const ast::QualifiedType* node ) {687 virtual const ast::Type * visit( const ast::QualifiedType * node ) { 526 688 preprint( node ); 527 689 … … 537 699 } 538 700 539 virtual const ast::Type * visit( const ast::FunctionType* node ) {701 virtual const ast::Type * visit( const ast::FunctionType * node ) { 540 702 preprint( node ); 541 703 … … 566 728 } 567 729 568 virtual const ast::Type * visit( const ast::StructInstType* node ) {730 virtual const ast::Type * visit( const ast::StructInstType * node ) { 569 731 preprint( node ); 570 732 … … 578 740 } 579 741 580 virtual const ast::Type * visit( const ast::UnionInstType* node ) {742 virtual const ast::Type * visit( const ast::UnionInstType * node ) { 581 743 preprint( node ); 582 744 … … 590 752 } 591 753 592 virtual const ast::Type * visit( const ast::EnumInstType* node ) {754 virtual const ast::Type * visit( const ast::EnumInstType * node ) { 593 755 preprint( node ); 594 756 … … 602 764 } 603 765 604 virtual const ast::Type * visit( const ast::TraitInstType* node ) {766 virtual const ast::Type * visit( const ast::TraitInstType * node ) { 605 767 preprint( node ); 606 768 … … 611 773 } 612 774 613 virtual const ast::Type * visit( const ast::TypeInstType* node ) {775 virtual const ast::Type * visit( const ast::TypeInstType * node ) { 614 776 preprint( node ); 615 777 … … 621 783 } 622 784 623 virtual const ast::Type * visit( const ast::TupleType* node ) {785 virtual const ast::Type * visit( const ast::TupleType * node ) { 624 786 preprint( node ); 625 787 … … 632 794 } 633 795 634 virtual const ast::Type * visit( const ast::TypeofType* node ) {796 virtual const ast::Type * visit( const ast::TypeofType * node ) { 635 797 preprint( node ); 636 798 … … 646 808 } 647 809 648 virtual const ast::Type * visit( const ast::VarArgsType* node ) {810 virtual const ast::Type * visit( const ast::VarArgsType * node ) { 649 811 preprint( node ); 650 812 os << "builtin var args pack"; … … 652 814 } 653 815 654 virtual const ast::Type * visit( const ast::ZeroType* node ) {816 virtual const ast::Type * visit( const ast::ZeroType * node ) { 655 817 preprint( node ); 656 818 os << "zero_t"; … … 658 820 } 659 821 660 virtual const ast::Type * visit( const ast::OneType* node ) {822 virtual const ast::Type * visit( const ast::OneType * node ) { 661 823 preprint( node ); 662 824 os << "one_t"; … … 664 826 } 665 827 666 virtual const ast::Type * visit( const ast::GlobalScopeType* node ) {828 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) { 667 829 preprint( node ); 668 830 os << "Global Scope Type"; … … 670 832 } 671 833 672 virtual const ast::Designation * visit( const ast::Designation* node ) {834 virtual const ast::Designation * visit( const ast::Designation * node ) { 673 835 if ( node->designators.empty() ) return node; 674 836 os << "... designated by: " << std::endl; … … 683 845 } 684 846 685 virtual const ast::Init * visit( const ast::SingleInit* node ) {847 virtual const ast::Init * visit( const ast::SingleInit * node ) { 686 848 os << "Simple Initializer: "; 687 849 node->value->accept( *this ); … … 689 851 } 690 852 691 virtual const ast::Init * visit( const ast::ListInit* node ) {853 virtual const ast::Init * visit( const ast::ListInit * node ) { 692 854 os << "Compound initializer: " << std::endl; 693 855 ++indent; … … 707 869 } 708 870 709 virtual const ast::Init * visit( const ast::ConstructorInit* node ) {871 virtual const ast::Init * visit( const ast::ConstructorInit * node ) { 710 872 os << "Constructor initializer: " << std::endl; 711 873 if ( node->ctor ) { … … 732 894 } 733 895 734 virtual const ast::Attribute * visit( const ast::Attribute* node ) {896 virtual const ast::Attribute * visit( const ast::Attribute * node ) { 735 897 if ( node->empty() ) return node; 736 898 os << "Attribute with name: " << node->name; … … 743 905 } 744 906 745 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution 907 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) { 746 908 os << indent << "Types:" << std::endl; 747 909 for ( const auto& i : *node ) { … … 765 927 }; 766 928 767 void print( std::ostream & os, const ast::Node * node, Indenter indent ) { 768 Printer printer { os, indent }; 929 void print( ostream & os, const ast::Node * node, Indenter indent ) { 930 Printer printer { os, indent, false }; 931 node->accept(printer); 932 } 933 934 void printShort( ostream & os, const ast::Node * node, Indenter indent ) { 935 Printer printer { os, indent, true }; 769 936 node->accept(printer); 770 937 } … … 773 940 // The size here needs to be explicit but at least the compiler will produce an error 774 941 // if the wrong size is specified 775 constexpr std::array<const char*, 3> Printer::Names::FuncSpecifiers;776 constexpr std::array<const char*, 5> Printer::Names::StorageClasses;777 constexpr std::array<const char*, 6> Printer::Names::Qualifiers;942 constexpr array<const char*, 3> Printer::Names::FuncSpecifiers; 943 constexpr array<const char*, 5> Printer::Names::StorageClasses; 944 constexpr array<const char*, 6> Printer::Names::Qualifiers; 778 945 } -
src/AST/TypeSubstitution.hpp
rb0ec971 r68c9165 25 25 #include "Fwd.hpp" // for UniqueId 26 26 #include "ParseNode.hpp" 27 #include "Type.hpp" 27 #include "Type.hpp" 28 28 #include "Common/SemanticError.h" // for SemanticError 29 29 #include "Visitor.hpp" -
src/AST/module.mk
rb0ec971 r68c9165 21 21 AST/DeclReplacer.cpp \ 22 22 AST/Expr.cpp \ 23 AST/GenericSubstitution.cpp \ 23 24 AST/Init.cpp \ 24 25 AST/LinkageSpec.cpp \ -
src/Makefile.in
rb0ec971 r68c9165 167 167 am__objects_1 = AST/Attribute.$(OBJEXT) AST/Convert.$(OBJEXT) \ 168 168 AST/Decl.$(OBJEXT) AST/DeclReplacer.$(OBJEXT) \ 169 AST/Expr.$(OBJEXT) AST/Init.$(OBJEXT) \ 170 AST/LinkageSpec.$(OBJEXT) AST/Node.$(OBJEXT) \ 171 AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) AST/Stmt.$(OBJEXT) \ 172 AST/Type.$(OBJEXT) AST/TypeSubstitution.$(OBJEXT) 169 AST/Expr.$(OBJEXT) AST/GenericSubstitution.$(OBJEXT) \ 170 AST/Init.$(OBJEXT) AST/LinkageSpec.$(OBJEXT) \ 171 AST/Node.$(OBJEXT) AST/Pass.$(OBJEXT) AST/Print.$(OBJEXT) \ 172 AST/Stmt.$(OBJEXT) AST/Type.$(OBJEXT) \ 173 AST/TypeSubstitution.$(OBJEXT) 173 174 am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \ 174 175 CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ … … 574 575 AST/DeclReplacer.cpp \ 575 576 AST/Expr.cpp \ 577 AST/GenericSubstitution.cpp \ 576 578 AST/Init.cpp \ 577 579 AST/LinkageSpec.cpp \ … … 739 741 AST/$(DEPDIR)/$(am__dirstamp) 740 742 AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 743 AST/GenericSubstitution.$(OBJEXT): AST/$(am__dirstamp) \ 744 AST/$(DEPDIR)/$(am__dirstamp) 741 745 AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 742 746 AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \ … … 1173 1177 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@ 1174 1178 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Expr.Po@am__quote@ 1179 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/GenericSubstitution.Po@am__quote@ 1175 1180 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@ 1176 1181 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@ -
src/ResolvExpr/Unify.cc
rb0ec971 r68c9165 179 179 result = false; 180 180 } else { 181 result = env.bindVarToVar( 182 var1, var2, TypeDecl::Data{ entry1->second, entry2->second }, needAssertions, 181 result = env.bindVarToVar( 182 var1, var2, TypeDecl::Data{ entry1->second, entry2->second }, needAssertions, 183 183 haveAssertions, openVars, widenMode, indexer ); 184 184 } … … 648 648 649 649 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ) { 650 assert(!"restore after AST added to build"); 651 // if ( func->returns.empty() ) return new ast::VoidType{}; 652 // if ( func->returns.size() == 1 ) return func->returns[0]->get_type(); 653 654 // std::vector<ast::ptr<ast::Type>> tys; 655 // for ( const ast::DeclWithType * decl : func->returns ) { 656 // tys.emplace_back( decl->get_type() ); 657 // } 658 // return new ast::TupleType{ std::move(tys) }; 650 if ( func->returns.empty() ) return new ast::VoidType{}; 651 if ( func->returns.size() == 1 ) return func->returns[0]->get_type(); 652 653 std::vector<ast::ptr<ast::Type>> tys; 654 for ( const ast::DeclWithType * decl : func->returns ) { 655 tys.emplace_back( decl->get_type() ); 656 } 657 return new ast::TupleType{ std::move(tys) }; 659 658 } 660 659 } // namespace ResolvExpr -
src/Tuples/TupleExpansion.cc
rb0ec971 r68c9165 320 320 } 321 321 const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) { 322 (void) exprs; 323 #warning Not implemented; needs Type.cpp in build 324 assertf(false, "Not implemented; needs Type.cpp in build"); 325 // // produce the TupleType which aggregates the types of the exprs 326 // std::vector<ast::ptr<ast::Type>> types; 327 // ast::CV::Qualifiers quals{ 328 // ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 329 // ast::CV::Atomic | ast::CV::Mutex }; 330 331 // for ( const ast::Expr * expr : exprs ) { 332 // assert( expr->result ); 333 // // if the type of any expr is void, the type of the entire tuple is void 334 // if ( expr->result->isVoid() ) return new ast::VoidType{}; 335 336 // // qualifiers on the tuple type are the qualifiers that exist on all components 337 // quals &= expr->result->qualifiers; 338 339 // types.emplace_back( expr->result ); 340 // } 341 342 // if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; } 343 // return new ast::TupleType{ std::move(types), quals }; 322 // produce the TupleType which aggregates the types of the exprs 323 std::vector<ast::ptr<ast::Type>> types; 324 ast::CV::Qualifiers quals{ 325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 326 ast::CV::Atomic | ast::CV::Mutex }; 327 328 for ( const ast::Expr * expr : exprs ) { 329 assert( expr->result ); 330 // if the type of any expr is void, the type of the entire tuple is void 331 if ( expr->result->isVoid() ) return new ast::VoidType{}; 332 333 // qualifiers on the tuple type are the qualifiers that exist on all components 334 quals &= expr->result->qualifiers; 335 336 types.emplace_back( expr->result ); 337 } 338 339 if ( exprs.empty() ) { quals = ast::CV::Qualifiers{}; } 340 return new ast::TupleType{ std::move(types), quals }; 344 341 } 345 342 … … 354 351 355 352 const ast::TypeInstType * isTtype( const ast::Type * type ) { 356 #warning unimplemented 353 if ( const ast::TypeInstType * inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 354 if ( inst->base && inst->base->kind == ast::TypeVar::Ttype ) { 355 return inst; 356 } 357 } 357 358 return nullptr; 358 359 }
Note: See TracChangeset
for help on using the changeset viewer.