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