Changes in / [68c9165:b0ec971]
- Location:
- src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Attribute.cpp
r68c9165 rb0ec971 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
r68c9165 rb0ec971 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;1341 1340 return nullptr; 1342 1341 } … … 1410 1409 # define GET_LABELS_V(labels) \ 1411 1410 to<std::vector>::from( make_labels( std::move( labels ) ) ) 1412 1411 1413 1412 static ast::CV::Qualifiers cv( Type * ty ) { return { ty->get_qualifiers().val }; } 1414 1413 … … 1550 1549 1551 1550 virtual void visit( TypeDecl * old ) override final { 1552 if ( inCache( old ) ) return; 1551 if ( inCache( old ) ) return; 1553 1552 auto decl = new ast::TypeDecl{ 1554 1553 old->location, … … 1588 1587 virtual void visit( AsmDecl * old ) override final { 1589 1588 auto decl = new ast::AsmDecl{ 1590 old->location, 1589 old->location, 1591 1590 GET_ACCEPT_1(stmt, AsmStmt) 1592 1591 }; … … 2143 2142 rslt = new ast::ConstantExpr( 2144 2143 old->location, 2145 GET_ACCEPT_1(result, Type), 2146 old->constant.get_value(), 2144 GET_ACCEPT_1(result, Type), 2145 old->constant.get_value(), 2147 2146 (double) old->constant.get_dval() 2148 2147 ); … … 2164 2163 assert(!old->isType); 2165 2164 rslt = new ast::SizeofExpr( 2166 old->location, 2165 old->location, 2167 2166 GET_ACCEPT_1(expr, Expr) 2168 2167 ); … … 2171 2170 assert(old->isType); 2172 2171 rslt = new ast::SizeofExpr( 2173 old->location, 2172 old->location, 2174 2173 GET_ACCEPT_1(type, Type) 2175 2174 ); … … 2185 2184 assert(!old->isType); 2186 2185 rslt = new ast::AlignofExpr( 2187 old->location, 2186 old->location, 2188 2187 GET_ACCEPT_1(expr, Expr) 2189 2188 ); … … 2192 2191 assert(old->isType); 2193 2192 rslt = new ast::AlignofExpr( 2194 old->location, 2193 old->location, 2195 2194 GET_ACCEPT_1(type, Type) 2196 2195 ); … … 2236 2235 GET_ACCEPT_1(arg1, Expr), 2237 2236 GET_ACCEPT_1(arg2, Expr), 2238 old->get_isAnd() ? 2237 old->get_isAnd() ? 2239 2238 ast::LogicalFlag::AndExpr : 2240 2239 ast::LogicalFlag::OrExpr -
src/AST/Expr.cpp
r68c9165 rb0ec971 159 159 assert( aggregate->result ); 160 160 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; 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; 167 170 } 168 171 … … 342 345 } 343 346 344 TupleAssignExpr::TupleAssignExpr( 347 TupleAssignExpr::TupleAssignExpr( 345 348 const CodeLocation & loc, const Type * result, const StmtExpr * s ) 346 349 : Expr( loc, result ), stmtExpr() { -
src/AST/GenericSubstitution.cpp
r68c9165 rb0ec971 23 23 #include "Pass.hpp" 24 24 #include "Type.hpp" 25 #include "TypeSubstitution. hpp"25 #include "TypeSubstitution.cpp" 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 * ) {38 void previsit( const ReferenceType * ty ) { 39 39 // do nothing; allows substitution from base type 40 40 } -
src/AST/Pass.hpp
r68c9165 rb0ec971 178 178 const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) override final; 179 179 180 template<typename pass_type> 181 friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_type>& visitor ); 180 friend void acceptAll( std::list< ptr<Decl> > & decls, Pass<pass_t>& visitor ); 182 181 private: 183 182 -
src/AST/Pass.proto.hpp
r68c9165 rb0ec971 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 }137 117 }; 138 118 … … 158 138 "Previsit may not change the type of the node. It must return its paremeter or void." 159 139 ); 160 161 __assign<162 std::is_void<163 decltype( pass.previsit( node ) )164 >::value165 >::result( pass, node );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 } 166 146 } 167 147 -
src/AST/Print.cpp
r68c9165 rb0ec971 22 22 #include "TypeSubstitution.hpp" 23 23 24 #include "Common/utility.h" // for group_iterate 25 26 using namespace std; 24 #include "Common/utility.h" // for group_iterate 27 25 28 26 namespace ast { … … 30 28 template <typename C, typename... T> 31 29 constexpr auto make_array(T&&... values) -> 32 array<C,sizeof...(T)>30 std::array<C,sizeof...(T)> 33 31 { 34 return array<C,sizeof...(T)>{35 forward<T>(values)...32 return std::array<C,sizeof...(T)>{ 33 std::forward<T>(values)... 36 34 }; 37 35 } … … 39 37 class Printer : public Visitor { 40 38 public: 41 ostream & os;39 std::ostream & os; 42 40 Indenter indent; 43 bool short_mode; 44 45 Printer(ostream & os, Indenter indent, bool short_mode) : os( os ), indent( indent ), short_mode(short_mode) {} 41 42 Printer(std::ostream & os, Indenter indent) : os( os ), indent( indent ) {} 46 43 47 44 private: … … 54 51 // need an endl after each element because it's not 55 52 // easy to know when each individual item should end 56 os << endl;53 os << std::endl; 57 54 } // if 58 55 } // for … … 77 74 78 75 template<typename storage_t, size_t N> 79 void print(const storage_t & storage, const array<const char *, N> & Names ) {76 void print(const storage_t & storage, const std::array<const char *, N> & Names ) { 80 77 if ( storage.any() ) { 81 78 for ( size_t i = 0; i < Names.size(); i += 1 ) { … … 138 135 print( node->qualifiers ); 139 136 } 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 } // if146 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 } // if154 if ( ! node->members.empty() ) {155 os << endl << indent << "... with members" << endl;156 ++indent;157 printAll( node->members );158 --indent;159 } // if160 if ( ! node->attributes.empty() ) {161 os << endl << indent << "... with attributes" << endl;162 ++indent;163 printAll( node->attributes );164 --indent;165 } // if166 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 } // if175 print( node->storage );176 os << node->typeString();177 if ( node->base ) {178 os << " for ";179 ++indent;180 node->base->accept( *this );181 --indent;182 } // if183 if ( ! node->params.empty() ) {184 os << endl << indent << "... with parameters" << endl;185 ++indent;186 printAll( node->params );187 --indent;188 } // if189 if ( ! node->assertions.empty() ) {190 os << endl << indent << "... with assertions" << endl;191 ++indent;192 printAll( node->assertions );193 --indent;194 } // if195 }196 137 197 138 public: 198 virtual const ast::DeclWithType * visit( const ast::ObjectDecl* node ) {199 if ( !node->name.empty()) os << node->name << ": ";139 virtual const ast::DeclWithType * visit( const ast::ObjectDecl * node ) { 140 if ( node->name != "" ) os << node->name << ": "; 200 141 201 142 if ( node->linkage != Linkage::Cforall ) { … … 216 157 ? "maybe constructed" 217 158 : "not constructed" 218 ) << ")" << endl << indent+1;159 ) << ")" << std::endl << indent+1; 219 160 220 161 ++indent; 221 162 node->init->accept( *this ); 222 163 --indent; 223 os << endl;164 os << std::endl; 224 165 } // if 225 166 226 167 if ( ! node->attributes.empty() ) { 227 os << endl << indent << "... with attributes:" <<endl;168 os << std::endl << indent << "... with attributes:" << std::endl; 228 169 ++indent; 229 170 printAll( node->attributes ); … … 238 179 } 239 180 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 ) { 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 ) { 608 446 preprint( node ); 609 447 os << "void"; … … 611 449 } 612 450 613 virtual const ast::Type * visit( const ast::BasicType* node ) {451 virtual const ast::Type * visit( const ast::BasicType * node ) { 614 452 preprint( node ); 615 453 os << ast::BasicType::typeNames[ node->kind ]; … … 617 455 } 618 456 619 virtual const ast::Type * visit( const ast::PointerType* node ) {457 virtual const ast::Type * visit( const ast::PointerType * node ) { 620 458 preprint( node ); 621 459 if ( ! node->isArray() ) { … … 644 482 } 645 483 646 virtual const ast::Type * visit( const ast::ArrayType* node ) {484 virtual const ast::Type * visit( const ast::ArrayType * node ) { 647 485 preprint( node ); 648 486 if ( node->isStatic ) { … … 672 510 } 673 511 674 virtual const ast::Type * visit( const ast::ReferenceType* node ) {512 virtual const ast::Type * visit( const ast::ReferenceType * node ) { 675 513 preprint( node ); 676 514 … … 685 523 } 686 524 687 virtual const ast::Type * visit( const ast::QualifiedType* node ) {525 virtual const ast::Type * visit( const ast::QualifiedType * node ) { 688 526 preprint( node ); 689 527 … … 699 537 } 700 538 701 virtual const ast::Type * visit( const ast::FunctionType* node ) {539 virtual const ast::Type * visit( const ast::FunctionType * node ) { 702 540 preprint( node ); 703 541 … … 728 566 } 729 567 730 virtual const ast::Type * visit( const ast::StructInstType* node ) {568 virtual const ast::Type * visit( const ast::StructInstType * node ) { 731 569 preprint( node ); 732 570 … … 740 578 } 741 579 742 virtual const ast::Type * visit( const ast::UnionInstType* node ) {580 virtual const ast::Type * visit( const ast::UnionInstType * node ) { 743 581 preprint( node ); 744 582 … … 752 590 } 753 591 754 virtual const ast::Type * visit( const ast::EnumInstType* node ) {592 virtual const ast::Type * visit( const ast::EnumInstType * node ) { 755 593 preprint( node ); 756 594 … … 764 602 } 765 603 766 virtual const ast::Type * visit( const ast::TraitInstType* node ) {604 virtual const ast::Type * visit( const ast::TraitInstType * node ) { 767 605 preprint( node ); 768 606 … … 773 611 } 774 612 775 virtual const ast::Type * visit( const ast::TypeInstType* node ) {613 virtual const ast::Type * visit( const ast::TypeInstType * node ) { 776 614 preprint( node ); 777 615 … … 783 621 } 784 622 785 virtual const ast::Type * visit( const ast::TupleType* node ) {623 virtual const ast::Type * visit( const ast::TupleType * node ) { 786 624 preprint( node ); 787 625 … … 794 632 } 795 633 796 virtual const ast::Type * visit( const ast::TypeofType* node ) {634 virtual const ast::Type * visit( const ast::TypeofType * node ) { 797 635 preprint( node ); 798 636 … … 808 646 } 809 647 810 virtual const ast::Type * visit( const ast::VarArgsType* node ) {648 virtual const ast::Type * visit( const ast::VarArgsType * node ) { 811 649 preprint( node ); 812 650 os << "builtin var args pack"; … … 814 652 } 815 653 816 virtual const ast::Type * visit( const ast::ZeroType* node ) {654 virtual const ast::Type * visit( const ast::ZeroType * node ) { 817 655 preprint( node ); 818 656 os << "zero_t"; … … 820 658 } 821 659 822 virtual const ast::Type * visit( const ast::OneType* node ) {660 virtual const ast::Type * visit( const ast::OneType * node ) { 823 661 preprint( node ); 824 662 os << "one_t"; … … 826 664 } 827 665 828 virtual const ast::Type * visit( const ast::GlobalScopeType* node ) {666 virtual const ast::Type * visit( const ast::GlobalScopeType * node ) { 829 667 preprint( node ); 830 668 os << "Global Scope Type"; … … 832 670 } 833 671 834 virtual const ast::Designation * visit( const ast::Designation* node ) {672 virtual const ast::Designation * visit( const ast::Designation * node ) { 835 673 if ( node->designators.empty() ) return node; 836 674 os << "... designated by: " << std::endl; … … 845 683 } 846 684 847 virtual const ast::Init * visit( const ast::SingleInit* node ) {685 virtual const ast::Init * visit( const ast::SingleInit * node ) { 848 686 os << "Simple Initializer: "; 849 687 node->value->accept( *this ); … … 851 689 } 852 690 853 virtual const ast::Init * visit( const ast::ListInit* node ) {691 virtual const ast::Init * visit( const ast::ListInit * node ) { 854 692 os << "Compound initializer: " << std::endl; 855 693 ++indent; … … 869 707 } 870 708 871 virtual const ast::Init * visit( const ast::ConstructorInit* node ) {709 virtual const ast::Init * visit( const ast::ConstructorInit * node ) { 872 710 os << "Constructor initializer: " << std::endl; 873 711 if ( node->ctor ) { … … 894 732 } 895 733 896 virtual const ast::Attribute * visit( const ast::Attribute* node ) {734 virtual const ast::Attribute * visit( const ast::Attribute * node ) { 897 735 if ( node->empty() ) return node; 898 736 os << "Attribute with name: " << node->name; … … 905 743 } 906 744 907 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) {745 virtual const ast::TypeSubstitution * visit( const ast::TypeSubstitution * node ) { 908 746 os << indent << "Types:" << std::endl; 909 747 for ( const auto& i : *node ) { … … 927 765 }; 928 766 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 }; 767 void print( std::ostream & os, const ast::Node * node, Indenter indent ) { 768 Printer printer { os, indent }; 936 769 node->accept(printer); 937 770 } … … 940 773 // The size here needs to be explicit but at least the compiler will produce an error 941 774 // if the wrong size is specified 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;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; 945 778 } -
src/AST/TypeSubstitution.hpp
r68c9165 rb0ec971 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
r68c9165 rb0ec971 21 21 AST/DeclReplacer.cpp \ 22 22 AST/Expr.cpp \ 23 AST/GenericSubstitution.cpp \24 23 AST/Init.cpp \ 25 24 AST/LinkageSpec.cpp \ -
src/Makefile.in
r68c9165 rb0ec971 167 167 am__objects_1 = AST/Attribute.$(OBJEXT) AST/Convert.$(OBJEXT) \ 168 168 AST/Decl.$(OBJEXT) AST/DeclReplacer.$(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) 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) 174 173 am__objects_2 = CodeGen/CodeGenerator.$(OBJEXT) \ 175 174 CodeGen/FixMain.$(OBJEXT) CodeGen/GenType.$(OBJEXT) \ … … 575 574 AST/DeclReplacer.cpp \ 576 575 AST/Expr.cpp \ 577 AST/GenericSubstitution.cpp \578 576 AST/Init.cpp \ 579 577 AST/LinkageSpec.cpp \ … … 741 739 AST/$(DEPDIR)/$(am__dirstamp) 742 740 AST/Expr.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 743 AST/GenericSubstitution.$(OBJEXT): AST/$(am__dirstamp) \744 AST/$(DEPDIR)/$(am__dirstamp)745 741 AST/Init.$(OBJEXT): AST/$(am__dirstamp) AST/$(DEPDIR)/$(am__dirstamp) 746 742 AST/LinkageSpec.$(OBJEXT): AST/$(am__dirstamp) \ … … 1177 1173 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/DeclReplacer.Po@am__quote@ 1178 1174 @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@1180 1175 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/Init.Po@am__quote@ 1181 1176 @AMDEP_TRUE@@am__include@ @am__quote@AST/$(DEPDIR)/LinkageSpec.Po@am__quote@ -
src/ResolvExpr/Unify.cc
r68c9165 rb0ec971 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 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) }; 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) }; 658 659 } 659 660 } // namespace ResolvExpr -
src/Tuples/TupleExpansion.cc
r68c9165 rb0ec971 320 320 } 321 321 const ast::Type * makeTupleType( const std::vector<ast::ptr<ast::Expr>> & exprs ) { 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 }; 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 }; 341 344 } 342 345 … … 351 354 352 355 const ast::TypeInstType * isTtype( const ast::Type * type ) { 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 } 356 #warning unimplemented 358 357 return nullptr; 359 358 }
Note:
See TracChangeset
for help on using the changeset viewer.