Changeset 523e300
- Timestamp:
- Dec 20, 2023, 4:21:09 PM (12 months ago)
- Branches:
- master
- Children:
- c7ebbec
- Parents:
- 0a6d2045
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cpp
r0a6d2045 r523e300 147 147 ast::CaseClause * create_terminate_catch_case( 148 148 const ast::DeclWithType * except_obj, int index, ast::CatchClause * clause ); 149 ast::FunctionDecl * create_terminate_catch( CatchList &handlers );150 149 ast::CompoundStmt * create_single_matcher( 151 150 const ast::DeclWithType * except_obj, ast::CatchClause * modded_handler ); … … 299 298 ast::Label( location ) ), 300 299 } 301 );302 }303 304 ast::FunctionDecl * TryMutatorCore::create_terminate_catch(305 CatchList &handlers ) {306 // void catch(int index, exception * except) {307 // switch (index) { CATCH_CASE... }308 // }309 310 assert( !handlers.empty() );311 std::vector<ast::ptr<ast::CaseClause>> handler_wrappers;312 const CodeLocation & location = handlers.front()->location;313 314 const ast::DeclWithType * index_obj = make_index_object( location );315 const ast::DeclWithType * except_obj = make_exception_object( location );316 317 // Index 1..{number of handlers}318 for ( const auto & [index, handler] : enumerate( handlers ) ) {319 handler_wrappers.push_back(320 create_terminate_catch_case( except_obj, index + 1, handler ) );321 }322 // TODO: Some sort of meaningful error on default perhaps?323 324 ast::SwitchStmt * handler_lookup = new ast::SwitchStmt( location,325 new ast::VariableExpr( location, index_obj ),326 std::move(handler_wrappers)327 );328 ast::CompoundStmt * body = new ast::CompoundStmt( location, {handler_lookup} );329 330 // void (*catch)(int, exception_t *) `body`331 return new ast::FunctionDecl(332 location,333 "catch",334 { index_obj, except_obj },335 {}, //return void336 body,337 ast::Storage::Classes{},338 ast::Linkage::Cforall339 300 ); 340 301 }
Note: See TracChangeset
for help on using the changeset viewer.