summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorJoshua Pritikin <joshua.pritikin@db.com>1998-06-14 10:03:15 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-15 05:32:01 +0000
commit1163b5c41f1e1e2856ca82fef1598bfbb6c54d72 (patch)
tree5b79b14d3fdae82835bb4e3561173110803f64d4 /scope.c
parentf55ee38a033ce570145fdd38bb9f09acf59d37cd (diff)
downloadperl-1163b5c41f1e1e2856ca82fef1598bfbb6c54d72.tar.gz
added patch, fixed typo, reworked documentation
Message-Id: <H00000e500071aa3@MHS> Subject: [PATCH 5.004_66] JMPENV! p4raw-id: //depot/perl@1135
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/scope.c b/scope.c
index 5958aba3f5..c0924d83f2 100644
--- a/scope.c
+++ b/scope.c
@@ -15,6 +15,17 @@
#include "EXTERN.h"
#include "perl.h"
+static void setjmp_tryblock _((CPERLarg_ TRYVTBL *vtbl, void *locals));
+
+void
+install_tryblock_method(tryblock_f fn)
+{
+ if (fn)
+ tryblock_function = fn;
+ else
+ tryblock_function = setjmp_tryblock;
+}
+
SV**
stack_grow(SV **sp, SV **p, int n)
{
@@ -906,3 +917,69 @@ cx_dump(PERL_CONTEXT *cx)
}
#endif /* DEBUGGING */
}
+
+#include "XSUB.h"
+
+/* make 'static' once JMPENV_PUSH is no longer used (see scope.h) XXX */
+void
+setjmp_jump(CPERLarg)
+{
+ dTHR;
+ PerlProc_longjmp(((SETJMPENV*)top_env)->je_buf, 1);
+}
+
+static void
+setjmp_tryblock(CPERLarg_ TRYVTBL *vtbl, void *locals)
+{
+ dTHR;
+ int jmpstat;
+ SETJMPENV je;
+ JMPENV_INIT(je, setjmp_jump);
+ PerlProc_setjmp(je.je_buf, 1);
+ JMPENV_TRY(je);
+ jmpstat = JMPENV_STAT(je);
+ switch (jmpstat) {
+ case JMP_NORMAL:
+ assert(vtbl->try_normal[0]);
+ (*vtbl->try_normal[0])(PERL_OBJECT_THIS_ locals);
+ break;
+ case JMP_EXCEPTION:
+ if (vtbl->try_exception[0])
+ (*vtbl->try_exception[0])(PERL_OBJECT_THIS_ locals);
+ break;
+ case JMP_MYEXIT:
+ if (vtbl->try_myexit[0])
+ (*vtbl->try_myexit[0])(PERL_OBJECT_THIS_ locals);
+ break;
+ default:
+ if (jmpstat != JMP_ABNORMAL)
+ PerlIO_printf(PerlIO_stderr(),
+ "JMPENV_JUMP(%d) is bogus\n", jmpstat);
+ if (vtbl->try_abnormal[0])
+ (*vtbl->try_abnormal[0])(PERL_OBJECT_THIS_ locals);
+ break;
+ }
+ JMPENV_POP_JE(je);
+ switch (JMPENV_STAT(je)) {
+ case JMP_NORMAL:
+ if (vtbl->try_normal[1])
+ (*vtbl->try_normal[1])(PERL_OBJECT_THIS_ locals);
+ break;
+ case JMP_EXCEPTION:
+ if (vtbl->try_exception[1])
+ (*vtbl->try_exception[1])(PERL_OBJECT_THIS_ locals);
+ break;
+ case JMP_MYEXIT:
+ if (vtbl->try_myexit[1])
+ (*vtbl->try_myexit[1])(PERL_OBJECT_THIS_ locals);
+ break;
+ default:
+ if (jmpstat != JMP_ABNORMAL)
+ PerlIO_printf(PerlIO_stderr(),
+ "JMPENV_JUMP(%d) is bogus\n", jmpstat);
+ if (vtbl->try_abnormal[1])
+ (*vtbl->try_abnormal[1])(PERL_OBJECT_THIS_ locals);
+ break;
+ }
+}
+