1999-09-25 23:41:09 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998, 1999 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
|
* any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this software; see the file COPYING. If not, write to
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
|
|
* Boston, MA 02111-1307 USA
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* As a special exception, the Free Software Foundation gives permission
|
|
|
|
|
|
* for additional uses of the text contained in its release of GUILE.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The exception is that, if you link the GUILE library with other files
|
|
|
|
|
|
* to produce an executable, this does not by itself cause the
|
|
|
|
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
|
|
|
|
* Your use of that executable is in no way restricted on account of
|
|
|
|
|
|
* linking the GUILE library code into it.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception does not however invalidate any other reasons why
|
|
|
|
|
|
* the executable file might be covered by the GNU General Public License.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception applies only to the code released by the
|
|
|
|
|
|
* Free Software Foundation under the name GUILE. If you copy
|
|
|
|
|
|
* code from other Free Software Foundation releases into a copy of
|
|
|
|
|
|
* GUILE, as the General Public License permits, the exception does
|
|
|
|
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
|
|
|
|
* anyone as to the status of such modified files, you must delete
|
|
|
|
|
|
* this exception notice from them.
|
|
|
|
|
|
*
|
|
|
|
|
|
* If you write modifications of your own for GUILE, it is your choice
|
|
|
|
|
|
* whether to permit this exception to apply to your modifications.
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* If you do not wish that, delete this exception notice. */
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
|
|
|
|
|
|
gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include "_scm.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
#include "stackchk.h"
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#include "dynwind.h"
|
|
|
|
|
|
#include "eval.h"
|
|
|
|
|
|
#include "smob.h"
|
|
|
|
|
|
#include "pairs.h"
|
|
|
|
|
|
#include "throw.h"
|
1997-07-18 14:35:58 +00:00
|
|
|
|
#include "fluids.h"
|
2000-03-17 16:10:13 +00:00
|
|
|
|
#include "ports.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
#include "root.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* Define this if you want to try out the stack allocation of cwdr's
|
|
|
|
|
|
jumpbuf. It works for me but I'm still worried that the dynwinds
|
|
|
|
|
|
might be able to make a mess. */
|
|
|
|
|
|
|
|
|
|
|
|
#undef USE_STACKJMPBUF
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM scm_sys_protects[SCM_NUM_PROTECTS];
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
long scm_tc16_root;
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef USE_THREADS
|
|
|
|
|
|
struct scm_root_state *scm_root;
|
|
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
static SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
mark_root (SCM root)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_root_state *s = SCM_ROOT_STATE (root);
|
1998-07-23 04:47:56 +00:00
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
scm_gc_mark (s->rootcont);
|
|
|
|
|
|
scm_gc_mark (s->dynwinds);
|
|
|
|
|
|
scm_gc_mark (s->continuation_stack);
|
|
|
|
|
|
scm_gc_mark (s->continuation_stack_ptr);
|
|
|
|
|
|
scm_gc_mark (s->progargs);
|
|
|
|
|
|
scm_gc_mark (s->exitval);
|
|
|
|
|
|
scm_gc_mark (s->cur_inp);
|
|
|
|
|
|
scm_gc_mark (s->cur_outp);
|
|
|
|
|
|
scm_gc_mark (s->cur_errp);
|
|
|
|
|
|
scm_gc_mark (s->def_inp);
|
|
|
|
|
|
scm_gc_mark (s->def_outp);
|
|
|
|
|
|
scm_gc_mark (s->def_errp);
|
1998-06-18 21:54:14 +00:00
|
|
|
|
/* No need to gc mark def_loadp */
|
1997-07-18 14:35:58 +00:00
|
|
|
|
scm_gc_mark (s->fluids);
|
1996-11-21 16:28:39 +00:00
|
|
|
|
scm_gc_mark (s->top_level_lookup_closure_var);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
scm_gc_mark (s->system_transformer);
|
|
|
|
|
|
return SCM_ROOT_STATE (root) -> parent;
|
|
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
static int
|
1999-12-12 02:36:16 +00:00
|
|
|
|
print_root (SCM exp,SCM port,scm_print_state *pstate)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
* Makefile.in: Rebuilt.
* Makefile.am (libguile_la_SOURCES): Removed extchrs.c,
mbstrings.c.
(modinclude_HEADERS): Removed extchrs.h, mbstrings.h.
* unif.c (scm_vector_set_length_x): Don't handle multibyte
strings.
* tag.c (scm_utag_mb_string, scm_utag_mb_substring): Removed.
(scm_tag): Don't handle multibyte strings.
* read.c: Don't include mbstrings.h.
(scm_lreadr): Don't handle multibyte ports.
* kw.c: Don't include mbstrings.h.
* init.c: Don't include mbstrings.h.
(scm_boot_guile_1): Don't init mbstrings module.
* hash.c (scm_hasher): Don't handle mbstrings.
* gscm.c (gscm_run_scm): Don't init mbstrings module.
* gc.c (scm_gc_mark): Don't handle mbstrings.
(scm_gc_sweep): Likewise.
* eval.c (SCM_CEVAL): Don't handle mbstrings.
* eq.c (scm_equal_p): Use SCM_TYP7S, not SCM_TYP7SD.
* tags.h (SCM_TYP7SD): Removed.
(SCM_TYP7D): Removed.
(scm_tc7_mb_string): Removed.
(scm_tc7_mb_substring): Removed.
* print.c (scm_iprin1): Handle char printing directly. Don't
handle mbstrings.
Don't include "mbstrings.h".
* symbols.c (scm_intern_obarray_soft, scm_string_to_symbol,
scm_string_to_obarray_symbol, msymbolize): Don't set symbol's
multi-byte flag.
Don't include "mbstrings.h".
* symbols.h (SCM_SYMBOL_MULTI_BYTE_STRINGP): Removed.
(SCM_SYMBOL_SLOTS): Define as 4.
(SCM_ROSTRINGP): Use SCM_TYP7S, not SCM_TYP7SD.
* arbiters.c, backtrace.c, debug.c, dynl.c, eval.c, fluids.c,
gc.c, gsubr.c, ioext.c, kw.c, mallocs.c, numbers.c, ports.c,
print.c, read.c, regex-posix.c, root.c, srcprop.c, stackchk.c,
struct.c, threads.c, throw.c, unif.c, variable.c: Use new
("gen"-less) I/O function names.
* ports.c (scm_add_to_port_table): Don't set port's
representation.
* ports.h (scm_port_representation_type): Removed.
(scm_string_representation_type): Removed.
(struct scm_port_table ): Removed representation field.
(SCM_PORT_REPRESENTATION): Removed.
(SCM_SET_PORT_REPRESENTATION): Removed.
* genio.h: Use new function names.
* genio.c: Don't include "extchrs.h".
(scm_gen_putc, scm_gen_puts, scm_gen_write, scm_get_getc):
Removed.
(scm_putc, scm_puts, scm_lfwrite): No longer static.
(scm_getc): No longer static; handle line and column changes.
(scm_ungetc): Renamed from scm_gen_ungetc.
(scm_do_read_line): Renamed from scm_gen_read_line.
* libguile.h: Don't include "extchrs.h" or "mbstrings.h"
* extchrs.h, extchrs.c, mbstrings.h, mbstrings.c: Removed.
1997-10-15 17:18:32 +00:00
|
|
|
|
scm_puts ("#<root ", port);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
scm_intprint(SCM_SEQ (SCM_ROOT_STATE (exp) -> rootcont), 16, port);
|
* Makefile.in: Rebuilt.
* Makefile.am (libguile_la_SOURCES): Removed extchrs.c,
mbstrings.c.
(modinclude_HEADERS): Removed extchrs.h, mbstrings.h.
* unif.c (scm_vector_set_length_x): Don't handle multibyte
strings.
* tag.c (scm_utag_mb_string, scm_utag_mb_substring): Removed.
(scm_tag): Don't handle multibyte strings.
* read.c: Don't include mbstrings.h.
(scm_lreadr): Don't handle multibyte ports.
* kw.c: Don't include mbstrings.h.
* init.c: Don't include mbstrings.h.
(scm_boot_guile_1): Don't init mbstrings module.
* hash.c (scm_hasher): Don't handle mbstrings.
* gscm.c (gscm_run_scm): Don't init mbstrings module.
* gc.c (scm_gc_mark): Don't handle mbstrings.
(scm_gc_sweep): Likewise.
* eval.c (SCM_CEVAL): Don't handle mbstrings.
* eq.c (scm_equal_p): Use SCM_TYP7S, not SCM_TYP7SD.
* tags.h (SCM_TYP7SD): Removed.
(SCM_TYP7D): Removed.
(scm_tc7_mb_string): Removed.
(scm_tc7_mb_substring): Removed.
* print.c (scm_iprin1): Handle char printing directly. Don't
handle mbstrings.
Don't include "mbstrings.h".
* symbols.c (scm_intern_obarray_soft, scm_string_to_symbol,
scm_string_to_obarray_symbol, msymbolize): Don't set symbol's
multi-byte flag.
Don't include "mbstrings.h".
* symbols.h (SCM_SYMBOL_MULTI_BYTE_STRINGP): Removed.
(SCM_SYMBOL_SLOTS): Define as 4.
(SCM_ROSTRINGP): Use SCM_TYP7S, not SCM_TYP7SD.
* arbiters.c, backtrace.c, debug.c, dynl.c, eval.c, fluids.c,
gc.c, gsubr.c, ioext.c, kw.c, mallocs.c, numbers.c, ports.c,
print.c, read.c, regex-posix.c, root.c, srcprop.c, stackchk.c,
struct.c, threads.c, throw.c, unif.c, variable.c: Use new
("gen"-less) I/O function names.
* ports.c (scm_add_to_port_table): Don't set port's
representation.
* ports.h (scm_port_representation_type): Removed.
(scm_string_representation_type): Removed.
(struct scm_port_table ): Removed representation field.
(SCM_PORT_REPRESENTATION): Removed.
(SCM_SET_PORT_REPRESENTATION): Removed.
* genio.h: Use new function names.
* genio.c: Don't include "extchrs.h".
(scm_gen_putc, scm_gen_puts, scm_gen_write, scm_get_getc):
Removed.
(scm_putc, scm_puts, scm_lfwrite): No longer static.
(scm_getc): No longer static; handle line and column changes.
(scm_ungetc): Renamed from scm_gen_ungetc.
(scm_do_read_line): Renamed from scm_gen_read_line.
* libguile.h: Don't include "extchrs.h" or "mbstrings.h"
* extchrs.h, extchrs.c, mbstrings.h, mbstrings.c: Removed.
1997-10-15 17:18:32 +00:00
|
|
|
|
scm_putc('>', port);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_make_root (SCM parent)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM root;
|
|
|
|
|
|
scm_root_state *root_state;
|
|
|
|
|
|
|
|
|
|
|
|
root_state = (scm_root_state *) scm_must_malloc (sizeof (scm_root_state),
|
|
|
|
|
|
"scm_make_root");
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (SCM_ROOTP (parent))
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
memcpy (root_state, SCM_ROOT_STATE (parent), sizeof (scm_root_state));
|
1997-07-18 14:35:58 +00:00
|
|
|
|
scm_copy_fluids (root_state);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
root_state->parent = parent;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
root_state->parent = SCM_BOOL_F;
|
1999-09-25 23:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
/* Initialize everything right now, in case a GC happens early. */
|
|
|
|
|
|
root_state->rootcont
|
|
|
|
|
|
= root_state->dynwinds
|
|
|
|
|
|
= root_state->continuation_stack
|
|
|
|
|
|
= root_state->continuation_stack_ptr
|
|
|
|
|
|
= root_state->progargs
|
|
|
|
|
|
= root_state->exitval
|
|
|
|
|
|
= root_state->cur_inp
|
|
|
|
|
|
= root_state->cur_outp
|
|
|
|
|
|
= root_state->cur_errp
|
|
|
|
|
|
= root_state->def_inp
|
|
|
|
|
|
= root_state->def_outp
|
|
|
|
|
|
= root_state->def_errp
|
|
|
|
|
|
= root_state->cur_loadp
|
|
|
|
|
|
= root_state->fluids
|
|
|
|
|
|
= root_state->system_transformer
|
|
|
|
|
|
= root_state->top_level_lookup_closure_var
|
|
|
|
|
|
= root_state->handle
|
|
|
|
|
|
= root_state->parent
|
|
|
|
|
|
= SCM_BOOL_F;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
SCM_REDEFER_INTS;
|
1999-07-07 09:44:01 +00:00
|
|
|
|
SCM_NEWSMOB (root, scm_tc16_root, root_state);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
root_state->handle = root;
|
|
|
|
|
|
SCM_REALLOW_INTS;
|
|
|
|
|
|
return root;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
/* {call-with-dynamic-root}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
*
|
|
|
|
|
|
* Suspending the current thread to evaluate a thunk on the
|
|
|
|
|
|
* same C stack but under a new root.
|
|
|
|
|
|
*
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
* Calls to call-with-dynamic-root return exactly once (unless
|
1997-10-02 15:00:03 +00:00
|
|
|
|
* the process is somehow exitted). */
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
1996-12-09 02:15:17 +00:00
|
|
|
|
/* Some questions about cwdr:
|
|
|
|
|
|
|
|
|
|
|
|
Couldn't the body just be a closure? Do we really need to pass
|
|
|
|
|
|
args through to it?
|
|
|
|
|
|
|
|
|
|
|
|
The semantics are a lot like catch's; in fact, we call
|
|
|
|
|
|
scm_internal_catch to take care of that part of things. Wouldn't
|
|
|
|
|
|
it be cleaner to say that uncaught throws just disappear into the
|
|
|
|
|
|
ether (or print a message to stderr), and let the caller use catch
|
|
|
|
|
|
themselves if they want to?
|
|
|
|
|
|
|
|
|
|
|
|
-JimB */
|
|
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#if 0
|
|
|
|
|
|
SCM scm_exitval; /* INUM with return value */
|
|
|
|
|
|
#endif
|
|
|
|
|
|
static int n_dynamic_roots = 0;
|
|
|
|
|
|
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* cwdr fills out both of these structures, and then passes a pointer
|
|
|
|
|
|
to them through scm_internal_catch to the cwdr_body and
|
|
|
|
|
|
cwdr_handler functions, to tell them how to behave and to get
|
|
|
|
|
|
information back from them.
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
|
|
|
|
|
A cwdr is a lot like a catch, except there is no tag (all
|
|
|
|
|
|
exceptions are caught), and the body procedure takes the arguments
|
1997-10-02 15:00:03 +00:00
|
|
|
|
passed to cwdr as A1 and ARGS. The handler is also special since
|
|
|
|
|
|
it is not directly run from scm_internal_catch. It is executed
|
|
|
|
|
|
outside the new dynamic root. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
|
|
|
|
|
struct cwdr_body_data {
|
|
|
|
|
|
/* Arguments to pass to the cwdr body function. */
|
|
|
|
|
|
SCM a1, args;
|
|
|
|
|
|
|
|
|
|
|
|
/* Scheme procedure to use as body of cwdr. */
|
|
|
|
|
|
SCM body_proc;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct cwdr_handler_data {
|
|
|
|
|
|
/* Do we need to run the handler? */
|
|
|
|
|
|
int run_handler;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* The tag and args to pass it. */
|
|
|
|
|
|
SCM tag, args;
|
1996-12-09 02:15:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Invoke the body of a cwdr, assuming that the throw handler has
|
|
|
|
|
|
already been set up. DATA points to a struct set up by cwdr that
|
* throw.c (scm_internal_catch): Make body funcs and handler funcs
use separate data pointers, to allow them to be designed
independently and reused.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message):
Renamed from catch_body, catch_handler, and uncaught_throw; made
generically useful.
(struct scm_catch_body_data): Renamed from catch_body_data; moved
to throw.h.
(scm_catch): Use the above.
(scm_throw): Don't bother printing a message for an uncaught
throw; we establish a default handler in init.
* throw.h (scm_internal_catch): Prototype updated.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message): New
decls.
(struct scm_body_thunk_data): New structure, used as data
argument to scm_body_thunk.
* init.c (struct main_func_closure): New structure, packaging up
the data to pass to the user's main function.
(scm_boot_guile): Create one. Pass it to scm_boot_guile_1.
(scm_boot_guile_1): Pass it through to invoke_main_func. Use
scm_internal_catch to establish a catch-all handler, using
scm_handle_by_message. This replaces the special-case code in
scm_throw.
(invoke_main_func): Body function for scm_internal_catch; invoke
the user's main function, using the main_func_closure pointer to
decide what to pass it.
* root.c (struct cwdr_body_data): Remove handler_proc member.
(cwdr): Use scm_handle_by_proc instead of cwdr_handler.
(cwdr_handler): Removed.
1996-12-21 04:48:21 +00:00
|
|
|
|
says what proc to call, and what args to apply it to.
|
|
|
|
|
|
|
|
|
|
|
|
With a little thought, we could replace this with scm_body_thunk,
|
|
|
|
|
|
but I don't want to mess with that at the moment. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
static SCM
|
* backtrace.c (display_error_body, display_backtrace_body),
coop-threads.c (scheme_body_bootstrip, c_body_bootstrip),
gh_eval.c (eval_str_wrapper, eval_file_wrapper), init.c
(invoke_main_func), root.c (cwdr_body), throw.c (cwss_body,
scm_body_thunk, hbpca_body): Removed the second jmpbuf arg on body
functions.
1998-02-02 15:00:14 +00:00
|
|
|
|
cwdr_body (void *data)
|
1996-12-09 02:15:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct cwdr_body_data *c = (struct cwdr_body_data *) data;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_apply (c->body_proc, c->a1, c->args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* Record the fact that the body of the cwdr has thrown. Record
|
|
|
|
|
|
enough information to invoke the handler later when the dynamic
|
|
|
|
|
|
root has been deestablished. */
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
1997-06-23 04:34:34 +00:00
|
|
|
|
static SCM
|
1997-10-02 15:00:03 +00:00
|
|
|
|
cwdr_handler (void *data, SCM tag, SCM args)
|
1997-06-23 04:34:34 +00:00
|
|
|
|
{
|
1997-10-02 15:00:03 +00:00
|
|
|
|
struct cwdr_handler_data *c = (struct cwdr_handler_data *) data;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
c->run_handler = 1;
|
|
|
|
|
|
c->tag = tag;
|
|
|
|
|
|
c->args = args;
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
1997-06-23 04:34:34 +00:00
|
|
|
|
}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
/* This is the basic code for new root creation.
|
|
|
|
|
|
*
|
|
|
|
|
|
* WARNING! The order of actions in this routine is in many ways
|
|
|
|
|
|
* critical. E. g., it is essential that an error doesn't leave Guile
|
1996-12-09 02:15:17 +00:00
|
|
|
|
* in a messed up state. */
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_internal_cwdr (scm_catch_body_t body, void *body_data,
|
|
|
|
|
|
scm_catch_handler_t handler, void *handler_data,
|
|
|
|
|
|
SCM_STACKITEM *stack_start)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#ifdef USE_STACKJMPBUF
|
2000-03-28 17:13:40 +00:00
|
|
|
|
scm_contregs static_contregs;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#endif
|
1996-10-01 03:19:14 +00:00
|
|
|
|
int old_ints_disabled = scm_ints_disabled;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
SCM old_rootcont, old_winds;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
struct cwdr_handler_data my_handler_data;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
SCM answer;
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* Create a fresh root continuation. */
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM new_rootcont;
|
|
|
|
|
|
SCM_NEWCELL (new_rootcont);
|
|
|
|
|
|
SCM_REDEFER_INTS;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#ifdef USE_STACKJMPBUF
|
2000-03-28 17:13:40 +00:00
|
|
|
|
SCM_SET_CONTREGS (new_rootcont, &static_contregs);
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#else
|
2000-03-28 17:13:40 +00:00
|
|
|
|
SCM_SET_CONTREGS (new_rootcont,
|
|
|
|
|
|
scm_must_malloc (sizeof (scm_contregs),
|
|
|
|
|
|
"inferior root continuation"));
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#endif
|
2000-04-03 08:47:51 +00:00
|
|
|
|
SCM_SET_CELL_TYPE (new_rootcont, scm_tc7_contin);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
SCM_DYNENV (new_rootcont) = SCM_EOL;
|
|
|
|
|
|
SCM_BASE (new_rootcont) = stack_start;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
SCM_SEQ (new_rootcont) = ++n_dynamic_roots;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#ifdef DEBUG_EXTENSIONS
|
|
|
|
|
|
SCM_DFRAME (new_rootcont) = 0;
|
|
|
|
|
|
#endif
|
1996-10-05 16:50:27 +00:00
|
|
|
|
old_rootcont = scm_rootcont;
|
|
|
|
|
|
scm_rootcont = new_rootcont;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
SCM_REALLOW_INTS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-10-05 16:50:27 +00:00
|
|
|
|
/* Exit caller's dynamic state.
|
|
|
|
|
|
*/
|
|
|
|
|
|
old_winds = scm_dynwinds;
|
|
|
|
|
|
scm_dowinds (SCM_EOL, scm_ilength (scm_dynwinds));
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#ifdef DEBUG_EXTENSIONS
|
1996-11-02 20:54:08 +00:00
|
|
|
|
SCM_DFRAME (old_rootcont) = scm_last_debug_frame;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
scm_last_debug_frame = 0;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#endif
|
1996-12-09 02:15:17 +00:00
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
my_handler_data.run_handler = 0;
|
* throw.c (scm_internal_catch): Make body funcs and handler funcs
use separate data pointers, to allow them to be designed
independently and reused.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message):
Renamed from catch_body, catch_handler, and uncaught_throw; made
generically useful.
(struct scm_catch_body_data): Renamed from catch_body_data; moved
to throw.h.
(scm_catch): Use the above.
(scm_throw): Don't bother printing a message for an uncaught
throw; we establish a default handler in init.
* throw.h (scm_internal_catch): Prototype updated.
(scm_body_thunk, scm_handle_by_proc, scm_handle_by_message): New
decls.
(struct scm_body_thunk_data): New structure, used as data
argument to scm_body_thunk.
* init.c (struct main_func_closure): New structure, packaging up
the data to pass to the user's main function.
(scm_boot_guile): Create one. Pass it to scm_boot_guile_1.
(scm_boot_guile_1): Pass it through to invoke_main_func. Use
scm_internal_catch to establish a catch-all handler, using
scm_handle_by_message. This replaces the special-case code in
scm_throw.
(invoke_main_func): Body function for scm_internal_catch; invoke
the user's main function, using the main_func_closure pointer to
decide what to pass it.
* root.c (struct cwdr_body_data): Remove handler_proc member.
(cwdr): Use scm_handle_by_proc instead of cwdr_handler.
(cwdr_handler): Removed.
1996-12-21 04:48:21 +00:00
|
|
|
|
answer = scm_internal_catch (SCM_BOOL_T,
|
1997-10-02 15:00:03 +00:00
|
|
|
|
body, body_data,
|
|
|
|
|
|
cwdr_handler, &my_handler_data);
|
1996-12-09 02:15:17 +00:00
|
|
|
|
}
|
1997-10-02 15:00:03 +00:00
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
scm_dowinds (old_winds, - scm_ilength (old_winds));
|
|
|
|
|
|
SCM_REDEFER_INTS;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#ifdef USE_STACKCJMPBUF
|
2000-03-28 17:13:40 +00:00
|
|
|
|
SCM_SET_CONTREGS (scm_rootcont, NULL);
|
1997-10-02 15:00:03 +00:00
|
|
|
|
#endif
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#ifdef DEBUG_EXTENSIONS
|
1996-11-02 20:54:08 +00:00
|
|
|
|
scm_last_debug_frame = SCM_DFRAME (old_rootcont);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#endif
|
1996-11-02 20:54:08 +00:00
|
|
|
|
scm_rootcont = old_rootcont;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
SCM_REALLOW_INTS;
|
|
|
|
|
|
scm_ints_disabled = old_ints_disabled;
|
1997-10-02 15:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
/* Now run the real handler iff the body did a throw. */
|
|
|
|
|
|
if (my_handler_data.run_handler)
|
|
|
|
|
|
return handler (handler_data, my_handler_data.tag, my_handler_data.args);
|
|
|
|
|
|
else
|
|
|
|
|
|
return answer;
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
1997-10-02 15:00:03 +00:00
|
|
|
|
/* The original CWDR for invoking Scheme code with a Scheme handler. */
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
cwdr (SCM proc, SCM a1, SCM args, SCM handler, SCM_STACKITEM *stack_start)
|
|
|
|
|
|
{
|
|
|
|
|
|
struct cwdr_body_data c;
|
|
|
|
|
|
|
|
|
|
|
|
c.a1 = a1;
|
|
|
|
|
|
c.args = args;
|
|
|
|
|
|
c.body_proc = proc;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_internal_cwdr (cwdr_body, &c,
|
|
|
|
|
|
scm_handle_by_proc, &handler,
|
|
|
|
|
|
stack_start);
|
|
|
|
|
|
}
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_call_with_dynamic_root, "call-with-dynamic-root", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM thunk, SCM handler),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Evaluate @var{(thunk)} in a new dynamic context, returning its value.\n\n"
|
|
|
|
|
|
"If an error occurs during evaluation, apply @var{handler} to the\n"
|
|
|
|
|
|
"arguments to the throw, just as @code{throw} would. If this happens,\n"
|
|
|
|
|
|
"@var{handler} is called outside the scope of the new root -- it is\n"
|
|
|
|
|
|
"called in the same dynamic context in which\n"
|
|
|
|
|
|
"@code{call-with-dynamic-root} was evaluated.\n\n"
|
|
|
|
|
|
"If @var{thunk} captures a continuation, the continuation is rooted at\n"
|
|
|
|
|
|
"the call to @var{thunk}. In particular, the call to\n"
|
|
|
|
|
|
"@code{call-with-dynamic-root} is not captured. Therefore,\n"
|
|
|
|
|
|
"@code{call-with-dynamic-root} always returns at most one time.\n\n"
|
|
|
|
|
|
"Before calling @var{thunk}, the dynamic-wind chain is un-wound back to\n"
|
|
|
|
|
|
"the root and a new chain started for @var{thunk}. Therefore, this call\n"
|
|
|
|
|
|
"may not do what you expect:\n\n"
|
|
|
|
|
|
"@example\n"
|
|
|
|
|
|
";; Almost certainly a bug:\n"
|
|
|
|
|
|
"(with-output-to-port\n"
|
|
|
|
|
|
" some-port\n\n"
|
|
|
|
|
|
" (lambda ()\n"
|
|
|
|
|
|
" (call-with-dynamic-root\n"
|
|
|
|
|
|
" (lambda ()\n"
|
|
|
|
|
|
" (display 'fnord)\n"
|
|
|
|
|
|
" (newline))\n"
|
|
|
|
|
|
" (lambda (errcode) errcode))))\n"
|
|
|
|
|
|
"@end example\n\n"
|
|
|
|
|
|
"The problem is, on what port will @samp{fnord\n"
|
|
|
|
|
|
"} be displayed? You\n"
|
|
|
|
|
|
"might expect that because of the @code{with-output-to-port} that\n"
|
|
|
|
|
|
"it will be displayed on the port bound to @code{some-port}. But it\n"
|
|
|
|
|
|
"probably won't -- before evaluating the thunk, dynamic winds are\n"
|
|
|
|
|
|
"unwound, including those created by @code{with-output-to-port}.\n"
|
|
|
|
|
|
"So, the standard output port will have been re-set to its default value\n"
|
|
|
|
|
|
"before @code{display} is evaluated.\n\n"
|
|
|
|
|
|
"(This function was added to Guile mostly to help calls to functions in C\n"
|
|
|
|
|
|
"libraries that can not tolerate non-local exits or calls that return\n"
|
|
|
|
|
|
"multiple times. If such functions call back to the interpreter, it should\n"
|
|
|
|
|
|
"be under a new dynamic root.)")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_call_with_dynamic_root
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_STACKITEM stack_place;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
return cwdr (thunk, SCM_EOL, SCM_EOL, handler, &stack_place);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_dynamic_root, "dynamic-root", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return an object representing the current dynamic root.\n\n"
|
|
|
|
|
|
"These objects are only useful for comparison using @code{eq?}.\n"
|
|
|
|
|
|
"They are currently represented as numbers, but your code should\n"
|
|
|
|
|
|
"in no way depend on this.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_dynamic_root
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
return scm_ulong2num (SCM_SEQ (scm_root->rootcont));
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-01 03:19:14 +00:00
|
|
|
|
|
|
|
|
|
|
SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_apply_with_dynamic_root (SCM proc, SCM a1, SCM args, SCM handler)
|
1996-10-01 03:19:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_STACKITEM stack_place;
|
1996-10-05 16:50:27 +00:00
|
|
|
|
return cwdr (proc, a1, args, handler, &stack_place);
|
1996-10-01 03:19:14 +00:00
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Call thunk(closure) underneath a top-level error handler.
|
|
|
|
|
|
* If an error occurs, pass the exitval through err_filter and return it.
|
|
|
|
|
|
* If no error occurs, return the value of thunk.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _UNICOS
|
|
|
|
|
|
typedef int setjmp_type;
|
|
|
|
|
|
#else
|
|
|
|
|
|
typedef long setjmp_type;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
SCM
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_call_catching_errors (SCM (*thunk)(), SCM (*err_filter)(), void *closure)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
setjmp_type i;
|
1996-08-23 01:21:07 +00:00
|
|
|
|
#ifdef DEBUG_EXTENSIONS
|
1996-10-05 16:50:27 +00:00
|
|
|
|
SCM_DFRAME (scm_rootcont) = scm_last_debug_frame;
|
1996-08-23 01:21:07 +00:00
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i = setjmp (SCM_JMPBUF (scm_rootcont));
|
1996-08-23 01:21:07 +00:00
|
|
|
|
scm_stack_checking_enabled_p = SCM_STACK_CHECKING_P;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
if (!i)
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_gc_heap_lock = 0;
|
|
|
|
|
|
answer = thunk (closure);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
scm_gc_heap_lock = 1;
|
|
|
|
|
|
answer = err_filter (scm_exitval, closure);
|
|
|
|
|
|
}
|
|
|
|
|
|
return answer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_root ()
|
|
|
|
|
|
{
|
1999-07-07 09:44:01 +00:00
|
|
|
|
scm_tc16_root = scm_make_smob_type_mfpe ("root", sizeof (struct scm_root_state),
|
|
|
|
|
|
mark_root, NULL, print_root, NULL);
|
|
|
|
|
|
|
1996-10-01 03:19:14 +00:00
|
|
|
|
#include "root.x"
|
|
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|