summaryrefslogtreecommitdiff
path: root/Zend/zend_execute_API.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2004-02-03 12:17:09 +0000
committerZeev Suraski <zeev@php.net>2004-02-03 12:17:09 +0000
commit9e60cb553fdff09dcff192d96884d75a9998bb73 (patch)
treeec9f7577dc55f3fdfc348bec94a194e783fbff9f /Zend/zend_execute_API.c
parent330d9f6352f4a8af90e1b053399e4ab17b3b00b1 (diff)
downloadphp-git-9e60cb553fdff09dcff192d96884d75a9998bb73.tar.gz
Rewrote exception support. Fixes a few limitations and bugs in the old
implementation, and allows exceptions to 'fire' much earlier than before. Instructions on how to use the new mechanism will follow on internals@ shortly... Note - this (most probably) breaks the current implementation of set_exception_handler()
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r--Zend/zend_execute_API.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 6cf4a2ebcb..086bde4b27 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -783,6 +783,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(scope) = current_scope;
EG(This) = current_this;
EG(current_execute_data) = EX(prev_execute_data);
+
+ if (EG(exception)) {
+ zend_throw_exception_internal(NULL TSRMLS_CC);
+ }
return SUCCESS;
}
@@ -1188,6 +1192,38 @@ check_fetch_type:
return *pce;
}
+void zend_throw_exception_internal(zval *exception TSRMLS_DC)
+{
+ if (exception != NULL) {
+ if (EG(exception)) {
+ /* FIXME: bail out? */
+ return;
+ }
+ EG(exception) = exception;
+ }
+ if ((EG(current_execute_data)->opline+1)->opcode == ZEND_HANDLE_EXCEPTION) {
+ /* no need to rethrow the exception */
+ return;
+ }
+ EG(opline_before_exception) = EG(current_execute_data)->opline;
+ EG(current_execute_data)->opline = &EG(active_op_array)->opcodes[EG(active_op_array)->last-1-1];
+}
+
+
+ZEND_API void zend_clear_exception(TSRMLS_D)
+{
+ if (!EG(exception)) {
+ return;
+ }
+ zval_ptr_dtor(&EG(exception));
+ EG(exception) = NULL;
+ EG(current_execute_data)->opline = EG(opline_before_exception);
+#if ZEND_DEBUG
+ EG(opline_before_exception) = NULL;
+#endif
+}
+
+
/*
* Local variables:
* tab-width: 4