[uim-commit] r1791 - branches/r5rs/sigscheme

kzk at freedesktop.org kzk at freedesktop.org
Mon Oct 3 23:18:06 PDT 2005


Author: kzk
Date: 2005-10-03 23:18:04 -0700 (Mon, 03 Oct 2005)
New Revision: 1791

Modified:
   branches/r5rs/sigscheme/config.h
   branches/r5rs/sigscheme/error.c
   branches/r5rs/sigscheme/operations-srfi34.c
   branches/r5rs/sigscheme/sigscheme.c
   branches/r5rs/sigscheme/sigschemeinternal.h
Log:
* sigscheme/sigschemeinternal.h
  - (CURRENT_EXCEPTION_HANDLER,
     PUSH_EXCEPTION_HANDLER,
     POP_EXCEPTION_HANDLER,
     CURRENT_CONTINUATION_HANDLER,
     PUSH_EXCEPTION_CONTINUATION,
     POP_EXCEPTION_CONTINUATION): moved from operations-srfi34.c
* sigscheme/config.h
  - (SCM_EXCEPTION_HANDLING): new option which depends on
    SRFI-34
* sigscheme/error.c
  - (throw_exception): new func
  - (SigScm_Error, SigScm_ErrorObj, Scm_Error): change to use
    throw_exception
* sigscheme/operations-srfi34.c
  - (CURRENT_EXCEPTION_HANDLER,
     PUSH_EXCEPTION_HANDLER,
     POP_EXCEPTION_HANDLER,
     CURRENT_CONTINUATION_HANDLER,
     PUSH_EXCEPTION_CONTINUATION,
     POP_EXCEPTION_CONTINUATION): moved to sigschemeinternal.h
* sigscheme/sigscheme.c
  - (SigScm_Initialize_internal): call "use" when
    SCM_EXCEPTION_HANDLING is enabled


Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h	2005-10-04 06:12:17 UTC (rev 1790)
+++ branches/r5rs/sigscheme/config.h	2005-10-04 06:18:04 UTC (rev 1791)
@@ -68,6 +68,7 @@
 #define SCM_ACCESSOR_ASSERT     0  /* enable strict type check with accessor */
 #define SCM_USE_VALUECONS       1  /* use experimental values passing */
 #define SCM_VOLATILE_OUTPUT     0  /* always flush files on write */
+#define SCM_EXCEPTION_HANDLING  1  /* use SRFI-34 base exception handling */
 
 #define SCM_GCC4_READY_GC       1  /* use experimental gcc4-ready stack protection */
 
@@ -93,4 +94,9 @@
 #define SCM_COMPAT_SIOD_BUGS    0
 #endif /* SCM_COMPAT_SIOD */
 
+#if SCM_EXCEPTION_HANDLING
+#undef SCM_USE_SRFI34
+#define SCM_USE_SRFI34          1
+#endif /* SCM_EXCEPTION_HANDLING */
+
 #endif /* __SIGSCHEME_CONFIG_H */

Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c	2005-10-04 06:12:17 UTC (rev 1790)
+++ branches/r5rs/sigscheme/error.c	2005-10-04 06:18:04 UTC (rev 1791)
@@ -64,7 +64,27 @@
 /*=======================================
   File Local Function Declarations
 =======================================*/
+static void throw_exception(ScmObj errorobj)
+{
+#if SCM_EXCEPTION_HANDLING
+    if (FALSEP(CURRENT_EXCEPTION_HANDLER())) {
+        /* outermost exception handler */
+        if (SigScm_DebugCategories() & SCM_DBG_BACKTRACE)
+            SigScm_ShowBacktrace();
 
+        exit(EXIT_FAILURE);
+    } else {
+        /* throw an exception */
+        ScmOp_SRFI34_raise(errorobj);
+    }
+#else
+    if (SigScm_DebugCategories() & SCM_DBG_BACKTRACE)
+        SigScm_ShowBacktrace();
+
+    exit(EXIT_FAILURE);
+#endif    
+}
+
 /*=======================================
   Function Implementations
 =======================================*/
@@ -97,12 +117,8 @@
         SigScm_ErrorNewline();
     }
 
-    /* FIXME: backtrace should be printed by outermost exception handler */
-    if (SigScm_DebugCategories() & SCM_DBG_BACKTRACE)
-        SigScm_ShowBacktrace();
-
-    /* FIXME: throw an exception instead of exiting */
-    exit(EXIT_FAILURE);
+    /* FIXME: this errorobj is OK? */
+    throw_exception(Scm_NewStringCopying("ERROR"));
 }
 
 /* Obsolete. */
@@ -114,13 +130,9 @@
         SigScm_WriteToPort(scm_current_error_port, obj);
         SigScm_ErrorNewline();
     }
-   
-    /* FIXME: backtrace should be printed by outermost exception handler */
-    if (SigScm_DebugCategories() & SCM_DBG_BACKTRACE)
-        SigScm_ShowBacktrace();
- 
-    /* FIXME: throw an exception instead of exiting */
-    exit(EXIT_FAILURE);
+
+    /* FIXME: this errorobj is OK? */
+    throw_exception(Scm_NewStringCopying("ERROR"));
 }
 
 /* This function obsoletes SigScm_ErrorObj(). */
@@ -133,12 +145,8 @@
         SigScm_ErrorNewline();
     }
 
-    /* FIXME: backtrace should be printed by outermost exception handler */
-    if (SigScm_DebugCategories() & SCM_DBG_BACKTRACE)
-        SigScm_ShowBacktrace();
- 
-    /* FIXME: throw an exception instead of exiting */
-    exit(EXIT_FAILURE);
+    /* FIXME: this errorobj is OK? */
+    throw_exception(Scm_NewStringCopying("ERROR"));
 }
 
 void SigScm_ShowBacktrace(void)

Modified: branches/r5rs/sigscheme/operations-srfi34.c
===================================================================
--- branches/r5rs/sigscheme/operations-srfi34.c	2005-10-04 06:12:17 UTC (rev 1790)
+++ branches/r5rs/sigscheme/operations-srfi34.c	2005-10-04 06:18:04 UTC (rev 1791)
@@ -50,20 +50,6 @@
 /*=======================================
   File Local Macro Declarations
 =======================================*/
-#define CURRENT_EXCEPTION_HANDLER()             \
-    (CAR(scm_exception_handlers))
-#define PUSH_EXCEPTION_HANDLER(handler)                                 \
-    (scm_exception_handlers = CONS((handler), scm_exception_handlers))
-#define POP_EXCEPTION_HANDLER()                 \
-    (scm_exception_handlers = CDR(scm_exception_handlers))
-
-#define CURRENT_EXCEPTION_CONTINUATION()        \
-    (CAR(scm_exception_continuations))
-#define PUSH_EXCEPTION_CONTINUATION(cont)                               \
-    (scm_exception_continuations = CONS((cont), scm_exception_continuations))
-#define POP_EXCEPTION_CONTINUATION()            \
-    (scm_exception_continuations = CDR(scm_exception_continuations))
-
 #define CONTINUATION_JMPENV     SCM_CONTINUATION_OPAQUE0
 #define CONTINUATION_SET_JMPENV SCM_CONTINUATION_SET_OPAQUE0
 

Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c	2005-10-04 06:12:17 UTC (rev 1790)
+++ branches/r5rs/sigscheme/sigscheme.c	2005-10-04 06:18:04 UTC (rev 1791)
@@ -390,6 +390,10 @@
     ScmExp_use(Scm_Intern("srfi-60"), SCM_INTERACTION_ENV);
     ScmExp_use(Scm_Intern("siod"), SCM_INTERACTION_ENV);
 #endif
+
+#if SCM_EXCEPTION_HANDLING
+    ScmExp_use(Scm_Intern("srfi-34"), SCM_INTERACTION_ENV);
+#endif
 }
 
 void SigScm_Finalize()

Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h	2005-10-04 06:12:17 UTC (rev 1790)
+++ branches/r5rs/sigscheme/sigschemeinternal.h	2005-10-04 06:18:04 UTC (rev 1791)
@@ -82,12 +82,6 @@
 extern ScmObj SigScm_null_values;
 #endif
 
-/* operations-srfi34.c */
-#if SCM_USE_SRFI34
-extern ScmObj scm_exception_handlers;
-extern ScmObj scm_exception_continuations;
-#endif
-
 /*=======================================
    Macro Declarations
 =======================================*/
@@ -340,7 +334,27 @@
 #define ASSERT_PROCEDUREP(obj) ASSERT_TYPE(PROCEDUREP, "procedure", (obj))
 #define ASSERT_ENVP(obj)     ASSERT_TYPE(ENVP, "environment specifier", (obj))
 
+#if SCM_USE_SRFI34
+/* Macros and Variables For Handling Exception Handlers based on SRFI-34 */
+extern ScmObj scm_exception_handlers;
+extern ScmObj scm_exception_continuations;
 
+#define CURRENT_EXCEPTION_HANDLER()                             \
+    (FALSEP(scm_exception_handlers)                             \
+     ? scm_exception_handlers : CAR(scm_exception_handlers))
+#define PUSH_EXCEPTION_HANDLER(handler)                                 \
+    (scm_exception_handlers = CONS((handler), scm_exception_handlers))
+#define POP_EXCEPTION_HANDLER()                 \
+    (scm_exception_handlers = CDR(scm_exception_handlers))
+
+#define CURRENT_EXCEPTION_CONTINUATION()        \
+    (FALSEP(scm_exception_continuations) ? scm_exception_continuations : CAR(scm_exception_continuations))
+#define PUSH_EXCEPTION_CONTINUATION(cont)                               \
+    (scm_exception_continuations = CONS((cont), scm_exception_continuations))
+#define POP_EXCEPTION_CONTINUATION()            \
+    (scm_exception_continuations = CDR(scm_exception_continuations))
+#endif /* SCM_USE_SRFI34 */
+
 /*=======================================
    Function Declarations
 =======================================*/



More information about the uim-commit mailing list