aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorEhsan Akhgari <ehsan.akhgari@gmail.com>2012-02-09 12:15:00 -0500
committerEhsan Akhgari <ehsan.akhgari@gmail.com>2012-02-09 13:52:42 -0500
commit68755bd3af1b8121e32e7e7bbb75230dc112a772 (patch)
tree56f872f2bc499d3bcc05e9e51beca71be670dd8a /src/library.js
parent9bf8d3e6eaf327326925d17d02d60fc670c6874c (diff)
Implement std::uncaught_exception() in js
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 6385507c..86c499a7 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4392,7 +4392,7 @@ LibraryManager.library = {
__cxa_free_exception: function(ptr) {
return _free(ptr);
},
- __cxa_throw__deps: ['llvm_eh_exception'],
+ __cxa_throw__deps: ['llvm_eh_exception', '_ZSt18uncaught_exceptionv'],
__cxa_throw: function(ptr, type, destructor) {
#if EXCEPTION_DEBUG
print('Compiled code throwing an exception, ' + [ptr,type,destructor] + ', at ' + new Error().stack);
@@ -4400,6 +4400,11 @@ LibraryManager.library = {
{{{ makeSetValue('_llvm_eh_exception.buf', '0', 'ptr', 'void*') }}}
{{{ makeSetValue('_llvm_eh_exception.buf', QUANTUM_SIZE, 'type', 'void*') }}}
{{{ makeSetValue('_llvm_eh_exception.buf', 2 * QUANTUM_SIZE, 'destructor', 'void*') }}}
+ if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
+ __ZSt18uncaught_exceptionv.uncaught_exception = 1;
+ } else {
+ __ZSt18uncaught_exceptionv.uncaught_exception++;
+ }
throw ptr;
},
__cxa_rethrow__deps: ['llvm_eh_exception', '__cxa_end_catch'],
@@ -4425,7 +4430,9 @@ LibraryManager.library = {
_Unwind_Resume_or_Rethrow: function(ptr) {
throw ptr;
},
+ __cxa_begin_catch__deps: ['_ZSt18uncaught_exceptionv'],
__cxa_begin_catch: function(ptr) {
+ __ZSt18uncaught_exceptionv.uncaught_exception--;
return ptr;
},
__cxa_end_catch__deps: ['llvm_eh_exception', '__cxa_free_exception'],
@@ -4455,6 +4462,9 @@ LibraryManager.library = {
__cxa_get_exception_ptr: function(ptr) {
return ptr;
},
+ _ZSt18uncaught_exceptionv: function() { // std::uncaught_exception()
+ return !!__ZSt18uncaught_exceptionv.uncaught_exception;
+ },
__cxa_call_unexpected: function(exception) {
ABORT = true;