@@ -4010,28 +4010,27 @@ LibraryManager.library = {
4010
4010
if ( throwntype == - 1 ) throwntype = { { { makeGetValue ( 'header' , 0 , 'void*' ) } } } ;
4011
4011
var typeArray = Array . prototype . slice . call ( arguments , 2 ) ;
4012
4012
4013
- // If throwntype is a pointer, this means a pointer has been
4014
- // thrown. When a pointer is thrown, actually what's thrown
4015
- // is a pointer to the pointer. We'll dereference it.
4016
- var thrownPtr = thrown ;
4017
- if ( throwntype != 0 && Module [ '___cxa_is_pointer_type' ] ( throwntype ) ) {
4018
- var throwntypeInfoAddr= { { { makeGetValue ( 'throwntype' , '0' , '*' ) } } } - { { { Runtime . QUANTUM_SIZE * 2 } } } ;
4019
- var throwntypeInfo = { { { makeGetValue ( 'throwntypeInfoAddr' , '0' , '*' ) } } } ;
4020
- if ( throwntypeInfo == 0 )
4021
- thrown = { { { makeGetValue ( 'thrown' , '0' , '*' ) } } } ;
4022
- }
4013
+ assert ( throwntype ) ;
4014
+
4015
+ var pointer = Module [ '___cxa_is_pointer_type' ] ( throwntype ) ;
4016
+ // can_catch receives a **, add indirection
4017
+ if ( ! ___cxa_find_matching_catch . buffer ) ___cxa_find_matching_catch . buffer = _malloc ( 4 ) ;
4018
+ { { { makeSetValue ( '___cxa_find_matching_catch.buffer' , '0' , 'thrown' , '*' ) } } } ;
4019
+ thrown = ___cxa_find_matching_catch . buffer ;
4023
4020
// The different catch blocks are denoted by different types.
4024
4021
// Due to inheritance, those types may not precisely match the
4025
4022
// type of the thrown object. Find one which matches, and
4026
4023
// return the type of the catch block which should be called.
4027
4024
for ( var i = 0 ; i < typeArray . length ; i ++ ) {
4028
- if ( typeArray [ i ] && Module [ '___cxa_can_catch' ] ( typeArray [ i ] , throwntype , thrown ) ) { // XXX thrown should be an out ptr
4025
+ if ( typeArray [ i ] && Module [ '___cxa_can_catch' ] ( typeArray [ i ] , throwntype , thrown ) ) {
4026
+ thrown = { { { makeGetValue ( 'thrown' , '0' , '*' ) } } } ; // undo indirection
4029
4027
{ { { makeStructuralReturn ( [ 'thrown' , 'typeArray[i]' ] ) } } } ;
4030
4028
}
4031
4029
}
4032
4030
// Shouldn't happen unless we have bogus data in typeArray
4033
4031
// or encounter a type for which emscripten doesn't have suitable
4034
4032
// typeinfo defined. Best-efforts match just in case.
4033
+ thrown = { { { makeGetValue ( 'thrown' , '0' , '*' ) } } } ; // undo indirection
4035
4034
{ { { makeStructuralReturn ( [ 'thrown' , 'throwntype' ] ) } } } ;
4036
4035
} ,
4037
4036
0 commit comments