- File:
-
- 1 edited
-
src/CodeGen/CodeGeneratorNew.cpp (modified) (69 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGeneratorNew.cpp
r0bd3faf r6e7ed0aa 24 24 namespace CodeGen { 25 25 26 int CodeGenerator ::tabsize = 4;26 int CodeGenerator_new::tabsize = 4; 27 27 28 28 // The kinds of statements that should be followed by whitespace. … … 35 35 } 36 36 37 void CodeGenerator ::extension( ast::Expr const * expr ) {37 void CodeGenerator_new::extension( ast::Expr const * expr ) { 38 38 if ( expr->extension ) output << "__extension__ "; 39 39 } 40 40 41 void CodeGenerator ::extension( ast::Decl const * decl ) {41 void CodeGenerator_new::extension( ast::Decl const * decl ) { 42 42 if ( decl->extension ) output << "__extension__ "; 43 43 } 44 44 45 void CodeGenerator ::asmName( ast::DeclWithType const * decl ) {45 void CodeGenerator_new::asmName( ast::DeclWithType const * decl ) { 46 46 if ( auto asmName = decl->asmName.as<ast::ConstantExpr>() ) { 47 47 output << " asm ( " << asmName->rep << " )"; … … 49 49 } 50 50 51 CodeGenerator ::LabelPrinter & CodeGenerator::LabelPrinter::operator()(51 CodeGenerator_new::LabelPrinter & CodeGenerator_new::LabelPrinter::operator()( 52 52 std::vector<ast::Label> const & l ) { 53 53 labels = &l; … … 55 55 } 56 56 57 std::ostream & CodeGenerator ::LabelPrinter::operator()( std::ostream & output ) const {57 std::ostream & CodeGenerator_new::LabelPrinter::operator()( std::ostream & output ) const { 58 58 const std::vector<ast::Label> & labels = *this->labels; 59 59 for ( const ast::Label & label : labels ) { … … 66 66 // Using updateLocation at the beginning of a node and endl within a node 67 67 // should become the method of formating. 68 void CodeGenerator ::updateLocation( CodeLocation const & to ) {68 void CodeGenerator_new::updateLocation( CodeLocation const & to ) { 69 69 // Skip if linemarks shouldn't appear or if location is unset. 70 70 if ( !options.lineMarks || to.isUnset() ) return; … … 86 86 } 87 87 88 void CodeGenerator ::updateLocation( ast::ParseNode const * to ) {88 void CodeGenerator_new::updateLocation( ast::ParseNode const * to ) { 89 89 updateLocation( to->location ); 90 90 } 91 91 92 std::ostream & CodeGenerator ::LineEnder::operator()( std::ostream & os ) const {92 std::ostream & CodeGenerator_new::LineEnder::operator()( std::ostream & os ) const { 93 93 os << "\n" << std::flush; 94 94 cg.currentLocation.first_line++; … … 96 96 } 97 97 98 CodeGenerator ::CodeGenerator( std::ostream & os, const Options & options ) :99 indent( 0, CodeGenerator ::tabsize ), output( os ),98 CodeGenerator_new::CodeGenerator_new( std::ostream & os, const Options & options ) : 99 indent( 0, CodeGenerator_new::tabsize ), output( os ), 100 100 options( options ), printLabels( *this ), endl( *this ) 101 101 {} 102 102 103 std::string CodeGenerator ::mangleName( ast::DeclWithType const * decl ) {103 std::string CodeGenerator_new::mangleName( ast::DeclWithType const * decl ) { 104 104 // GCC builtins should always be printed unmangled. 105 105 if ( options.pretty || decl->linkage.is_gcc_builtin ) { … … 112 112 } 113 113 114 void CodeGenerator ::genAttributes(114 void CodeGenerator_new::genAttributes( 115 115 const std::vector<ast::ptr<ast::Attribute>> & attributes ) { 116 116 if ( attributes.empty() ) return; … … 129 129 } 130 130 131 void CodeGenerator ::previsit( ast::Node const * ) {131 void CodeGenerator_new::previsit( ast::Node const * ) { 132 132 // All traversal is manual. 133 133 // TODO: Which means the ast::Pass is just providing a default no visit? … … 135 135 } 136 136 137 void CodeGenerator ::previsit( ast::ParseNode const * node ) {137 void CodeGenerator_new::previsit( ast::ParseNode const * node ) { 138 138 previsit( (ast::Node const *)node ); 139 139 updateLocation( node ); 140 140 } 141 141 142 void CodeGenerator ::postvisit( ast::Node const * node ) {142 void CodeGenerator_new::postvisit( ast::Node const * node ) { 143 143 std::stringstream ss; 144 144 ast::print( ss, node ); … … 146 146 } 147 147 148 void CodeGenerator ::previsit( ast::Expr const * expr ) {148 void CodeGenerator_new::previsit( ast::Expr const * expr ) { 149 149 previsit( (ast::ParseNode const *)expr ); 150 150 GuardAction( [this, expr](){ … … 155 155 } 156 156 157 void CodeGenerator ::postvisit( ast::FunctionDecl const * decl ) {157 void CodeGenerator_new::postvisit( ast::FunctionDecl const * decl ) { 158 158 // Deleted decls should never be used, so don't print them in C. 159 159 if ( decl->isDeleted && options.genC ) return; … … 168 168 169 169 std::ostringstream acc; 170 ast::Pass<CodeGenerator > subCG( acc, subOptions );170 ast::Pass<CodeGenerator_new> subCG( acc, subOptions ); 171 171 // Add the forall clause. 172 172 // TODO: These probably should be removed by now and the assert used. … … 213 213 } 214 214 215 ast::ObjectDecl const * CodeGenerator::postvisit( 215 //void CodeGenerator_new::postvisit( ast::ObjectDecl const * decl_ ) { 216 ast::ObjectDecl const * CodeGenerator_new::postvisit( 216 217 ast::ObjectDecl const * decl ) { 217 218 // Deleted decls should never be used, so don't print them in C. … … 261 262 } 262 263 263 void CodeGenerator ::handleStorageClass( ast::DeclWithType const * decl ) {264 void CodeGenerator_new::handleStorageClass( ast::DeclWithType const * decl ) { 264 265 if ( decl->storage.any() ) { 265 266 ast::print( output, decl->storage ); … … 267 268 } 268 269 269 void CodeGenerator ::handleAggregate(270 void CodeGenerator_new::handleAggregate( 270 271 ast::AggregateDecl const * decl, std::string const & kind ) { 271 272 if ( !decl->params.empty() && !options.genC ) { … … 295 296 } 296 297 297 void CodeGenerator ::postvisit( ast::StructDecl const * decl ) {298 void CodeGenerator_new::postvisit( ast::StructDecl const * decl ) { 298 299 extension( decl ); 299 300 handleAggregate( decl, "struct " ); 300 301 } 301 302 302 void CodeGenerator ::postvisit( ast::UnionDecl const * decl ) {303 void CodeGenerator_new::postvisit( ast::UnionDecl const * decl ) { 303 304 extension( decl ); 304 305 handleAggregate( decl, "union " ); … … 331 332 } 332 333 333 void CodeGenerator ::postvisit( ast::EnumDecl const * decl ) {334 void CodeGenerator_new::postvisit( ast::EnumDecl const * decl ) { 334 335 extension( decl ); 335 336 auto members = decl->members; … … 369 370 } 370 371 371 void CodeGenerator ::postvisit( ast::TraitDecl const * decl ) {372 void CodeGenerator_new::postvisit( ast::TraitDecl const * decl ) { 372 373 assertf( !options.genC, "TraitDecls should not reach code generation." ); 373 374 extension( decl ); … … 375 376 } 376 377 377 void CodeGenerator ::postvisit( ast::TypedefDecl const * decl ) {378 void CodeGenerator_new::postvisit( ast::TypedefDecl const * decl ) { 378 379 assertf( !options.genC, "Typedefs should not reach code generation." ); 379 380 output << "typedef " << genType( decl->base, decl->name, options ) << endl; 380 381 } 381 382 382 void CodeGenerator ::postvisit( ast::TypeDecl const * decl ) {383 void CodeGenerator_new::postvisit( ast::TypeDecl const * decl ) { 383 384 assertf( !options.genC, "TypeDecls should not reach code generation." ); 384 385 output << decl->genTypeString() << " " << decl->name; … … 396 397 } 397 398 398 void CodeGenerator ::postvisit( ast::StaticAssertDecl const * decl ) {399 void CodeGenerator_new::postvisit( ast::StaticAssertDecl const * decl ) { 399 400 output << "_Static_assert("; 400 401 decl->cond->accept( *visitor ); … … 404 405 } 405 406 406 void CodeGenerator ::postvisit( ast::Designation const * designation ) {407 void CodeGenerator_new::postvisit( ast::Designation const * designation ) { 407 408 auto designators = designation->designators; 408 409 if ( 0 == designators.size() ) return; … … 422 423 } 423 424 424 void CodeGenerator ::postvisit( ast::SingleInit const * init ) {425 void CodeGenerator_new::postvisit( ast::SingleInit const * init ) { 425 426 init->value->accept( *visitor ); 426 427 } 427 428 428 void CodeGenerator ::postvisit( ast::ListInit const * init ) {429 void CodeGenerator_new::postvisit( ast::ListInit const * init ) { 429 430 auto initBegin = init->initializers.begin(); 430 431 auto initEnd = init->initializers.end(); … … 445 446 } 446 447 447 void CodeGenerator ::postvisit( ast::ConstructorInit const * init ) {448 void CodeGenerator_new::postvisit( ast::ConstructorInit const * init ) { 448 449 assertf( !options.genC, "ConstructorInit nodes should not reach code generation." ); 449 450 // This isn't actual code, but labels the constructor/destructor pairs. … … 455 456 } 456 457 457 void CodeGenerator ::postvisit( ast::ApplicationExpr const * expr ) {458 void CodeGenerator_new::postvisit( ast::ApplicationExpr const * expr ) { 458 459 extension( expr ); 459 460 if ( auto var = expr->func.as<ast::VariableExpr>() ) { … … 549 550 } 550 551 551 void CodeGenerator ::postvisit( ast::UntypedExpr const * expr ) {552 void CodeGenerator_new::postvisit( ast::UntypedExpr const * expr ) { 552 553 extension( expr ); 553 554 if ( auto name = expr->func.as<ast::NameExpr>() ) { … … 637 638 } 638 639 639 void CodeGenerator ::postvisit( ast::RangeExpr const * expr ) {640 void CodeGenerator_new::postvisit( ast::RangeExpr const * expr ) { 640 641 expr->low->accept( *visitor ); 641 642 output << " ... "; … … 643 644 } 644 645 645 void CodeGenerator ::postvisit( ast::NameExpr const * expr ) {646 void CodeGenerator_new::postvisit( ast::NameExpr const * expr ) { 646 647 extension( expr ); 647 648 if ( const OperatorInfo * opInfo = operatorLookup( expr->name ) ) { … … 656 657 } 657 658 658 void CodeGenerator ::postvisit( ast::DimensionExpr const * expr ) {659 void CodeGenerator_new::postvisit( ast::DimensionExpr const * expr ) { 659 660 extension( expr ); 660 661 output << "/*non-type*/" << expr->name; 661 662 } 662 663 663 void CodeGenerator ::postvisit( ast::AddressExpr const * expr ) {664 void CodeGenerator_new::postvisit( ast::AddressExpr const * expr ) { 664 665 extension( expr ); 665 666 output << "(&"; … … 668 669 } 669 670 670 void CodeGenerator ::postvisit( ast::LabelAddressExpr const * expr ) {671 void CodeGenerator_new::postvisit( ast::LabelAddressExpr const * expr ) { 671 672 extension( expr ); 672 673 output << "(&&" << expr->arg << ")"; 673 674 } 674 675 675 void CodeGenerator ::postvisit( ast::CastExpr const * expr ) {676 void CodeGenerator_new::postvisit( ast::CastExpr const * expr ) { 676 677 extension( expr ); 677 678 output << "("; … … 687 688 } 688 689 689 void CodeGenerator ::postvisit( ast::KeywordCastExpr const * expr ) {690 void CodeGenerator_new::postvisit( ast::KeywordCastExpr const * expr ) { 690 691 assertf( !options.genC, "KeywordCastExpr should not reach code generation." ); 691 692 extension( expr ); … … 695 696 } 696 697 697 void CodeGenerator ::postvisit( ast::VirtualCastExpr const * expr ) {698 void CodeGenerator_new::postvisit( ast::VirtualCastExpr const * expr ) { 698 699 assertf( !options.genC, "VirtualCastExpr should not reach code generation." ); 699 700 extension( expr ); … … 704 705 } 705 706 706 void CodeGenerator ::postvisit( ast::UntypedMemberExpr const * expr ) {707 void CodeGenerator_new::postvisit( ast::UntypedMemberExpr const * expr ) { 707 708 assertf( !options.genC, "UntypedMemberExpr should not reach code generation." ); 708 709 extension( expr ); … … 712 713 } 713 714 714 void CodeGenerator ::postvisit( ast::MemberExpr const * expr ) {715 void CodeGenerator_new::postvisit( ast::MemberExpr const * expr ) { 715 716 extension( expr ); 716 717 expr->aggregate->accept( *visitor ); … … 718 719 } 719 720 720 void CodeGenerator ::postvisit( ast::VariableExpr const * expr ) {721 void CodeGenerator_new::postvisit( ast::VariableExpr const * expr ) { 721 722 extension( expr ); 722 723 const OperatorInfo * opInfo; … … 732 733 } 733 734 734 void CodeGenerator ::postvisit( ast::ConstantExpr const * expr ) {735 void CodeGenerator_new::postvisit( ast::ConstantExpr const * expr ) { 735 736 extension( expr ); 736 737 output << expr->rep; 737 738 } 738 739 739 void CodeGenerator ::postvisit( ast::SizeofExpr const * expr ) {740 void CodeGenerator_new::postvisit( ast::SizeofExpr const * expr ) { 740 741 extension( expr ); 741 742 output << "sizeof("; … … 748 749 } 749 750 750 void CodeGenerator ::postvisit( ast::AlignofExpr const * expr ) {751 void CodeGenerator_new::postvisit( ast::AlignofExpr const * expr ) { 751 752 // Using the GCC extension to avoid changing the std to C11. 752 753 extension( expr ); … … 760 761 } 761 762 762 void CodeGenerator ::postvisit( ast::UntypedOffsetofExpr const * expr ) {763 void CodeGenerator_new::postvisit( ast::UntypedOffsetofExpr const * expr ) { 763 764 assertf( !options.genC, "UntypedOffsetofExpr should not reach code generation." ); 764 765 output << "offsetof("; … … 768 769 } 769 770 770 void CodeGenerator ::postvisit( ast::OffsetofExpr const * expr ) {771 void CodeGenerator_new::postvisit( ast::OffsetofExpr const * expr ) { 771 772 // Use GCC builtin 772 773 output << "__builtin_offsetof("; … … 776 777 } 777 778 778 void CodeGenerator ::postvisit( ast::OffsetPackExpr const * expr ) {779 void CodeGenerator_new::postvisit( ast::OffsetPackExpr const * expr ) { 779 780 assertf( !options.genC, "OffsetPackExpr should not reach code generation." ); 780 781 output << "__CFA_offsetpack(" << genType( expr->type, "", options ) << ")"; 781 782 } 782 783 783 void CodeGenerator ::postvisit( ast::LogicalExpr const * expr ) {784 void CodeGenerator_new::postvisit( ast::LogicalExpr const * expr ) { 784 785 extension( expr ); 785 786 output << "("; … … 790 791 } 791 792 792 void CodeGenerator ::postvisit( ast::ConditionalExpr const * expr ) {793 void CodeGenerator_new::postvisit( ast::ConditionalExpr const * expr ) { 793 794 extension( expr ); 794 795 output << "("; … … 801 802 } 802 803 803 void CodeGenerator ::postvisit( ast::CommaExpr const * expr ) {804 void CodeGenerator_new::postvisit( ast::CommaExpr const * expr ) { 804 805 extension( expr ); 805 806 output << "("; … … 817 818 } 818 819 819 void CodeGenerator ::postvisit( ast::TupleAssignExpr const * expr ) {820 void CodeGenerator_new::postvisit( ast::TupleAssignExpr const * expr ) { 820 821 assertf( !options.genC, "TupleAssignExpr should not reach code generation." ); 821 822 expr->stmtExpr->accept( *visitor ); 822 823 } 823 824 824 void CodeGenerator ::postvisit( ast::UntypedTupleExpr const * expr ) {825 void CodeGenerator_new::postvisit( ast::UntypedTupleExpr const * expr ) { 825 826 assertf( !options.genC, "UntypedTupleExpr should not reach code generation." ); 826 827 extension( expr ); … … 830 831 } 831 832 832 void CodeGenerator ::postvisit( ast::TupleExpr const * expr ) {833 void CodeGenerator_new::postvisit( ast::TupleExpr const * expr ) { 833 834 assertf( !options.genC, "TupleExpr should not reach code generation." ); 834 835 extension( expr ); … … 838 839 } 839 840 840 void CodeGenerator ::postvisit( ast::TupleIndexExpr const * expr ) {841 void CodeGenerator_new::postvisit( ast::TupleIndexExpr const * expr ) { 841 842 assertf( !options.genC, "TupleIndexExpr should not reach code generation." ); 842 843 extension( expr ); … … 845 846 } 846 847 847 void CodeGenerator ::postvisit( ast::TypeExpr const * expr ) {848 void CodeGenerator_new::postvisit( ast::TypeExpr const * expr ) { 848 849 // TODO: Should there be an assertion there? 849 850 if ( !options.genC ) { … … 852 853 } 853 854 854 void CodeGenerator ::postvisit( ast::AsmExpr const * expr ) {855 void CodeGenerator_new::postvisit( ast::AsmExpr const * expr ) { 855 856 if ( !expr->inout.empty() ) { 856 857 output << "[ " << expr->inout << " ] "; … … 862 863 } 863 864 864 void CodeGenerator ::postvisit( ast::CompoundLiteralExpr const * expr ) {865 void CodeGenerator_new::postvisit( ast::CompoundLiteralExpr const * expr ) { 865 866 //assert( expr->result && dynamic_cast<ast::ListInit const *>( expr->init ) ); 866 867 assert( expr->result && expr->init.as<ast::ListInit>() ); … … 869 870 } 870 871 871 void CodeGenerator ::postvisit( ast::UniqueExpr const * expr ) {872 void CodeGenerator_new::postvisit( ast::UniqueExpr const * expr ) { 872 873 assertf( !options.genC, "UniqueExpr should not reach code generation." ); 873 874 output << "unq<" << expr->id << ">{ "; … … 876 877 } 877 878 878 void CodeGenerator ::postvisit( ast::StmtExpr const * expr ) {879 void CodeGenerator_new::postvisit( ast::StmtExpr const * expr ) { 879 880 auto stmts = expr->stmts->kids; 880 881 output << "({" << endl; … … 904 905 } 905 906 906 void CodeGenerator ::postvisit( ast::ConstructorExpr const * expr ) {907 void CodeGenerator_new::postvisit( ast::ConstructorExpr const * expr ) { 907 908 assertf( !options.genC, "ConstructorExpr should not reach code generation." ); 908 909 expr->callExpr->accept( *visitor ); 909 910 } 910 911 911 void CodeGenerator ::postvisit( ast::DeletedExpr const * expr ) {912 void CodeGenerator_new::postvisit( ast::DeletedExpr const * expr ) { 912 913 assertf( !options.genC, "DeletedExpr should not reach code generation." ); 913 914 expr->expr->accept( *visitor ); 914 915 } 915 916 916 void CodeGenerator ::postvisit( ast::DefaultArgExpr const * expr ) {917 void CodeGenerator_new::postvisit( ast::DefaultArgExpr const * expr ) { 917 918 assertf( !options.genC, "DefaultArgExpr should not reach code generation." ); 918 919 expr->expr->accept( *visitor ); 919 920 } 920 921 921 void CodeGenerator ::postvisit( ast::GenericExpr const * expr ) {922 void CodeGenerator_new::postvisit( ast::GenericExpr const * expr ) { 922 923 assertf( !options.genC, "GenericExpr should not reach code generation." ); 923 924 output << "_Generic("; … … 939 940 } 940 941 941 void CodeGenerator ::postvisit( ast::CompoundStmt const * stmt ) {942 void CodeGenerator_new::postvisit( ast::CompoundStmt const * stmt ) { 942 943 output << "{" << endl; 943 944 … … 954 955 } 955 956 956 void CodeGenerator ::postvisit( ast::ExprStmt const * stmt ) {957 void CodeGenerator_new::postvisit( ast::ExprStmt const * stmt ) { 957 958 assert( stmt ); 958 959 // Cast the top-level expression to void to reduce gcc warnings. … … 966 967 } 967 968 968 void CodeGenerator ::postvisit( ast::AsmStmt const * stmt ) {969 void CodeGenerator_new::postvisit( ast::AsmStmt const * stmt ) { 969 970 output << "asm "; 970 971 if ( stmt->isVolatile ) output << "volatile "; … … 990 991 } 991 992 992 void CodeGenerator ::postvisit( ast::AsmDecl const * decl ) {993 void CodeGenerator_new::postvisit( ast::AsmDecl const * decl ) { 993 994 output << "asm "; 994 995 ast::AsmStmt const * stmt = decl->stmt; … … 998 999 } 999 1000 1000 void CodeGenerator ::postvisit( ast::DirectiveDecl const * decl ) {1001 void CodeGenerator_new::postvisit( ast::DirectiveDecl const * decl ) { 1001 1002 // endl prevents spaces before the directive. 1002 1003 output << endl << decl->stmt->directive; 1003 1004 } 1004 1005 1005 void CodeGenerator ::postvisit( ast::DirectiveStmt const * stmt ) {1006 void CodeGenerator_new::postvisit( ast::DirectiveStmt const * stmt ) { 1006 1007 // endl prevents spaces before the directive. 1007 1008 output << endl << stmt->directive; 1008 1009 } 1009 1010 1010 void CodeGenerator ::postvisit( ast::IfStmt const * stmt ) {1011 void CodeGenerator_new::postvisit( ast::IfStmt const * stmt ) { 1011 1012 output << "if ( "; 1012 1013 stmt->cond->accept( *visitor ); … … 1021 1022 } 1022 1023 1023 void CodeGenerator ::postvisit( ast::SwitchStmt const * stmt ) {1024 void CodeGenerator_new::postvisit( ast::SwitchStmt const * stmt ) { 1024 1025 output << "switch ( "; 1025 1026 stmt->cond->accept( *visitor ); … … 1035 1036 } 1036 1037 1037 void CodeGenerator ::postvisit( ast::CaseClause const * clause ) {1038 void CodeGenerator_new::postvisit( ast::CaseClause const * clause ) { 1038 1039 updateLocation( clause ); 1039 1040 output << indent; … … 1055 1056 } 1056 1057 1057 void CodeGenerator ::postvisit( ast::BranchStmt const * stmt ) {1058 void CodeGenerator_new::postvisit( ast::BranchStmt const * stmt ) { 1058 1059 switch ( stmt->kind ) { 1059 1060 case ast::BranchStmt::Goto: … … 1090 1091 } 1091 1092 1092 void CodeGenerator ::postvisit( ast::ReturnStmt const * stmt ) {1093 void CodeGenerator_new::postvisit( ast::ReturnStmt const * stmt ) { 1093 1094 output << "return "; 1094 1095 if ( stmt->expr ) stmt->expr->accept( *visitor ); … … 1096 1097 } 1097 1098 1098 void CodeGenerator ::postvisit( ast::ThrowStmt const * stmt ) {1099 void CodeGenerator_new::postvisit( ast::ThrowStmt const * stmt ) { 1099 1100 assertf( !options.genC, "ThrowStmt should not reach code generation." ); 1100 1101 … … 1111 1112 } 1112 1113 1113 void CodeGenerator ::postvisit( ast::CatchClause const * stmt ) {1114 void CodeGenerator_new::postvisit( ast::CatchClause const * stmt ) { 1114 1115 assertf( !options.genC, "CatchClause should not reach code generation." ); 1115 1116 … … 1125 1126 } 1126 1127 1127 void CodeGenerator ::postvisit( ast::WaitForStmt const * stmt ) {1128 void CodeGenerator_new::postvisit( ast::WaitForStmt const * stmt ) { 1128 1129 assertf( !options.genC, "WaitforStmt should not reach code generation." ); 1129 1130 … … 1171 1172 } 1172 1173 1173 void CodeGenerator ::postvisit( ast::WithStmt const * stmt ) {1174 void CodeGenerator_new::postvisit( ast::WithStmt const * stmt ) { 1174 1175 assertf( !options.genC, "WithStmt should not reach code generation." ); 1175 1176 … … 1180 1181 } 1181 1182 1182 void CodeGenerator ::postvisit( ast::WhileDoStmt const * stmt ) {1183 void CodeGenerator_new::postvisit( ast::WhileDoStmt const * stmt ) { 1183 1184 if ( stmt->isDoWhile ) { 1184 1185 output << "do"; … … 1190 1191 output << " "; 1191 1192 1192 output << CodeGenerator ::printLabels( stmt->body->labels );1193 output << CodeGenerator_new::printLabels( stmt->body->labels ); 1193 1194 stmt->body->accept( *visitor ); 1194 1195 … … 1202 1203 } 1203 1204 1204 void CodeGenerator ::postvisit( ast::ForStmt const * stmt ) {1205 void CodeGenerator_new::postvisit( ast::ForStmt const * stmt ) { 1205 1206 // Initializer is always hoised so don't generate it. 1206 1207 // TODO: Do an assertion check? … … 1225 1226 } 1226 1227 1227 void CodeGenerator ::postvisit( ast::NullStmt const * ) {1228 void CodeGenerator_new::postvisit( ast::NullStmt const * ) { 1228 1229 output << "/* null statement */ ;"; 1229 1230 } 1230 1231 1231 void CodeGenerator ::postvisit( ast::DeclStmt const * stmt ) {1232 void CodeGenerator_new::postvisit( ast::DeclStmt const * stmt ) { 1232 1233 stmt->decl->accept( *visitor ); 1233 1234 … … 1235 1236 } 1236 1237 1237 void CodeGenerator ::postvisit( ast::ImplicitCtorDtorStmt const * stmt ) {1238 void CodeGenerator_new::postvisit( ast::ImplicitCtorDtorStmt const * stmt ) { 1238 1239 assertf( !options.genC, "ImplicitCtorCtorStmt should not reach code generation." ); 1239 1240 stmt->callStmt->accept( *visitor ); 1240 1241 } 1241 1242 1242 void CodeGenerator ::postvisit( ast::MutexStmt const * stmt ) {1243 void CodeGenerator_new::postvisit( ast::MutexStmt const * stmt ) { 1243 1244 assertf( !options.genC, "MutexStmt should not reach code generation." ); 1244 1245 // TODO: But this isn't what a mutex statement looks like.
Note:
See TracChangeset
for help on using the changeset viewer.