2012-02-14 01:54:15 -05:00
|
|
|
|
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006,
|
|
|
|
|
|
* 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
1996-08-20 17:11:59 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
1996-08-20 17:11:59 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
1996-08-20 17:11:59 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
2005-03-07 21:42:02 +00:00
|
|
|
|
#include "libguile/async.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/smob.h"
|
|
|
|
|
|
#include "libguile/alist.h"
|
|
|
|
|
|
#include "libguile/debug.h"
|
|
|
|
|
|
#include "libguile/hashtab.h"
|
|
|
|
|
|
#include "libguile/hash.h"
|
|
|
|
|
|
#include "libguile/ports.h"
|
|
|
|
|
|
#include "libguile/root.h"
|
2006-06-25 22:44:00 +00:00
|
|
|
|
#include "libguile/gc.h"
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/srcprop.h"
|
2011-05-24 21:25:11 +02:00
|
|
|
|
#include "libguile/private-options.h"
|
|
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
/* {Source Properties}
|
|
|
|
|
|
*
|
|
|
|
|
|
* Properties of source list expressions.
|
2010-09-24 16:28:33 +02:00
|
|
|
|
* Four of these have special meaning:
|
1996-08-20 17:11:59 +00:00
|
|
|
|
*
|
|
|
|
|
|
* filename string The name of the source file.
|
|
|
|
|
|
* copy list A copy of the list expression.
|
|
|
|
|
|
* line integer The source code line number.
|
|
|
|
|
|
* column integer The source code column number.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Most properties above can be set by the reader.
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2000-12-11 14:48:23 +00:00
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_filename, "filename");
|
|
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_copy, "copy");
|
|
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_line, "line");
|
|
|
|
|
|
SCM_GLOBAL_SYMBOL (scm_sym_column, "column");
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2011-05-24 22:46:09 +02:00
|
|
|
|
static SCM scm_source_whash;
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
* __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
|
|
|
|
|
2007-01-19 19:33:10 +00:00
|
|
|
|
/*
|
2007-01-22 15:57:22 +00:00
|
|
|
|
* Source properties are stored as double cells with the
|
|
|
|
|
|
* following layout:
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
2007-01-22 15:57:22 +00:00
|
|
|
|
* car = tag
|
|
|
|
|
|
* cbr = pos
|
|
|
|
|
|
* ccr = copy
|
2009-08-04 19:11:21 +01:00
|
|
|
|
* cdr = alist
|
2007-01-22 15:57:22 +00:00
|
|
|
|
*/
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
|
|
|
|
|
#define SRCPROPSP(p) (SCM_SMOB_PREDICATE (scm_tc16_srcprops, (p)))
|
2009-12-08 21:53:15 +01:00
|
|
|
|
#define SRCPROPPOS(p) (SCM_SMOB_DATA(p))
|
2007-01-19 19:33:10 +00:00
|
|
|
|
#define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12)
|
|
|
|
|
|
#define SRCPROPCOL(p) (SRCPROPPOS(p) & 0x0fffL)
|
2009-12-08 21:53:15 +01:00
|
|
|
|
#define SRCPROPCOPY(p) (SCM_SMOB_OBJECT_2(p))
|
|
|
|
|
|
#define SRCPROPALIST(p) (SCM_SMOB_OBJECT_3(p))
|
2007-01-19 19:33:10 +00:00
|
|
|
|
#define SRCPROPMAKPOS(l, c) (((l) << 12) + (c))
|
2009-12-08 21:53:15 +01:00
|
|
|
|
#define SETSRCPROPPOS(p, l, c) (SCM_SET_SMOB_DATA_1 (p, SRCPROPMAKPOS (l, c)))
|
2007-01-19 19:33:10 +00:00
|
|
|
|
#define SETSRCPROPLINE(p, l) SETSRCPROPPOS (p, l, SRCPROPCOL (p))
|
|
|
|
|
|
#define SETSRCPROPCOL(p, c) SETSRCPROPPOS (p, SRCPROPLINE (p), c)
|
2009-12-08 21:53:15 +01:00
|
|
|
|
#define SETSRCPROPCOPY(p, c) (SCM_SET_SMOB_OBJECT_2 (p, c))
|
|
|
|
|
|
#define SETSRCPROPALIST(p, l) (SCM_SET_SMOB_OBJECT_3 (p, l))
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
2009-08-04 18:54:50 +01:00
|
|
|
|
static SCM scm_srcprops_to_alist (SCM obj);
|
|
|
|
|
|
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
scm_t_bits scm_tc16_srcprops;
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2012-02-14 02:14:10 -05:00
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
|
supports_source_props (SCM obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_NIMP (obj) && !scm_is_symbol (obj) && !scm_is_keyword (obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
static int
|
2000-12-08 17:32:56 +00:00
|
|
|
|
srcprops_print (SCM obj, SCM port, scm_print_state *pstate)
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
* eval.c, numbers.h, unif.h, smob.h, srcprop.c: Added #include
"print.h"
* arbiters.c (prinarb),
async.c (print_async),
debug.c (prindebugobj, prinmemoized),
eval.c (prinprom, prinmacro),
filesys.c (scm_fd_print, scm_dir_print),
kw.c (print_kw),
mallocs.c (prinmalloc),
numbers.c, numbers.h (scm_floprint, scm_bigprint),
smob.h (scm_smobfuns),
srcprop.c (prinsrcprops),
throw.c (prinjb),
unif.c, unif.h (scm_raprin1, rapr1),
variable.c (prin_var): Changed argument `int writing' to
`scm_print_state *pstate'.
1996-09-22 22:41:10 +00:00
|
|
|
|
int writingp = SCM_WRITINGP (pstate);
|
2016-04-26 23:07:28 +02:00
|
|
|
|
scm_puts ("#<srcprops ", port);
|
* eval.c, numbers.h, unif.h, smob.h, srcprop.c: Added #include
"print.h"
* arbiters.c (prinarb),
async.c (print_async),
debug.c (prindebugobj, prinmemoized),
eval.c (prinprom, prinmacro),
filesys.c (scm_fd_print, scm_dir_print),
kw.c (print_kw),
mallocs.c (prinmalloc),
numbers.c, numbers.h (scm_floprint, scm_bigprint),
smob.h (scm_smobfuns),
srcprop.c (prinsrcprops),
throw.c (prinjb),
unif.c, unif.h (scm_raprin1, rapr1),
variable.c (prin_var): Changed argument `int writing' to
`scm_print_state *pstate'.
1996-09-22 22:41:10 +00:00
|
|
|
|
SCM_SET_WRITINGP (pstate, 1);
|
2009-08-04 18:54:50 +01:00
|
|
|
|
scm_iprin1 (scm_srcprops_to_alist (obj), port, pstate);
|
* eval.c, numbers.h, unif.h, smob.h, srcprop.c: Added #include
"print.h"
* arbiters.c (prinarb),
async.c (print_async),
debug.c (prindebugobj, prinmemoized),
eval.c (prinprom, prinmacro),
filesys.c (scm_fd_print, scm_dir_print),
kw.c (print_kw),
mallocs.c (prinmalloc),
numbers.c, numbers.h (scm_floprint, scm_bigprint),
smob.h (scm_smobfuns),
srcprop.c (prinsrcprops),
throw.c (prinjb),
unif.c, unif.h (scm_raprin1, rapr1),
variable.c (prin_var): Changed argument `int writing' to
`scm_print_state *pstate'.
1996-09-22 22:41:10 +00:00
|
|
|
|
SCM_SET_WRITINGP (pstate, writingp);
|
2016-04-26 23:01:14 +02:00
|
|
|
|
scm_putc ('>', port);
|
1996-08-20 17:11:59 +00:00
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* __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
|
|
|
|
|
2007-01-19 19:33:10 +00:00
|
|
|
|
/*
|
2009-08-04 18:54:50 +01:00
|
|
|
|
* We remember the last file name settings, so we can share that alist
|
2007-01-22 15:57:22 +00:00
|
|
|
|
* entry. This works because scm_set_source_property_x does not use
|
2009-08-04 18:54:50 +01:00
|
|
|
|
* assoc-set! for modifying the alist.
|
2007-01-22 15:57:22 +00:00
|
|
|
|
*
|
|
|
|
|
|
* This variable contains a protected cons, whose cdr is the cached
|
2009-08-04 18:54:50 +01:00
|
|
|
|
* alist
|
2007-01-19 19:33:10 +00:00
|
|
|
|
*/
|
2009-08-04 18:54:50 +01:00
|
|
|
|
static SCM scm_last_alist_filename;
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
SCM
|
2009-08-04 18:54:50 +01:00
|
|
|
|
scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM alist)
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
2007-01-19 19:33:10 +00:00
|
|
|
|
if (!SCM_UNBNDP (filename))
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
2009-08-04 18:54:50 +01:00
|
|
|
|
SCM old_alist = alist;
|
2006-06-25 22:44:00 +00:00
|
|
|
|
|
2007-01-19 19:33:10 +00:00
|
|
|
|
/*
|
|
|
|
|
|
have to extract the acons, and operate on that, for
|
|
|
|
|
|
thread safety.
|
|
|
|
|
|
*/
|
2009-08-04 18:54:50 +01:00
|
|
|
|
SCM last_acons = SCM_CDR (scm_last_alist_filename);
|
2011-05-13 13:04:49 +02:00
|
|
|
|
if (scm_is_null (old_alist)
|
|
|
|
|
|
&& scm_is_eq (SCM_CDAR (last_acons), filename))
|
2007-01-19 19:33:10 +00:00
|
|
|
|
{
|
2009-08-04 18:54:50 +01:00
|
|
|
|
alist = last_acons;
|
2007-01-19 19:33:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-08-04 18:54:50 +01:00
|
|
|
|
alist = scm_acons (scm_sym_filename, filename, alist);
|
2011-05-13 13:04:49 +02:00
|
|
|
|
if (scm_is_null (old_alist))
|
2009-08-04 18:54:50 +01:00
|
|
|
|
SCM_SETCDR (scm_last_alist_filename, alist);
|
2007-01-19 19:33:10 +00:00
|
|
|
|
}
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_RETURN_NEWSMOB3 (scm_tc16_srcprops,
|
|
|
|
|
|
SRCPROPMAKPOS (line, col),
|
2011-05-13 12:51:56 +02:00
|
|
|
|
SCM_UNPACK (copy),
|
|
|
|
|
|
SCM_UNPACK (alist));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
* __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
|
|
|
|
|
2009-08-04 18:54:50 +01:00
|
|
|
|
static SCM
|
|
|
|
|
|
scm_srcprops_to_alist (SCM obj)
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
2009-08-04 18:54:50 +01:00
|
|
|
|
SCM alist = SRCPROPALIST (obj);
|
1996-08-20 17:11:59 +00:00
|
|
|
|
if (!SCM_UNBNDP (SRCPROPCOPY (obj)))
|
2009-08-04 18:54:50 +01:00
|
|
|
|
alist = scm_acons (scm_sym_copy, SRCPROPCOPY (obj), alist);
|
|
|
|
|
|
alist = scm_acons (scm_sym_column, scm_from_int (SRCPROPCOL (obj)), alist);
|
|
|
|
|
|
alist = scm_acons (scm_sym_line, scm_from_int (SRCPROPLINE (obj)), alist);
|
|
|
|
|
|
return alist;
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-02-14 02:14:10 -05:00
|
|
|
|
SCM_DEFINE (scm_supports_source_properties_p, "supports-source-properties?", 1, 0, 0,
|
|
|
|
|
|
(SCM obj),
|
|
|
|
|
|
"Return #t if @var{obj} supports adding source properties,\n"
|
|
|
|
|
|
"otherwise return #f.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_supports_source_properties_p
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_from_bool (supports_source_props (obj));
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM obj),
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"Return the source property association list of @var{obj}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_source_properties
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
2012-02-14 01:54:15 -05:00
|
|
|
|
if (SCM_IMP (obj))
|
|
|
|
|
|
return SCM_EOL;
|
2003-08-08 22:57:28 +00:00
|
|
|
|
else
|
2012-02-14 01:54:15 -05:00
|
|
|
|
{
|
2012-02-17 10:21:50 +01:00
|
|
|
|
SCM p = scm_weak_table_refq (scm_source_whash, obj, SCM_EOL);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2012-02-14 01:54:15 -05:00
|
|
|
|
if (SRCPROPSP (p))
|
|
|
|
|
|
return scm_srcprops_to_alist (p);
|
|
|
|
|
|
else
|
|
|
|
|
|
/* list from set-source-properties!, or SCM_EOL for not found */
|
|
|
|
|
|
return p;
|
|
|
|
|
|
}
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
|
|
|
|
|
/* Perhaps this procedure should look through an alist
|
|
|
|
|
|
and try to make a srcprops-object...? */
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
|
2009-08-04 18:54:50 +01:00
|
|
|
|
(SCM obj, SCM alist),
|
|
|
|
|
|
"Install the association list @var{alist} as the source property\n"
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"list for @var{obj}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_source_properties_x
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_NIM (1, obj);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj, alist);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2009-08-04 18:54:50 +01:00
|
|
|
|
return alist;
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2011-05-24 21:25:11 +02:00
|
|
|
|
int
|
|
|
|
|
|
scm_i_has_source_properties (SCM obj)
|
|
|
|
|
|
#define FUNC_NAME "%set-source-properties"
|
|
|
|
|
|
{
|
2012-02-14 01:54:15 -05:00
|
|
|
|
if (SCM_IMP (obj))
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
else
|
2012-02-17 10:21:50 +01:00
|
|
|
|
return scm_is_true (scm_weak_table_refq (scm_source_whash, obj, SCM_BOOL_F));
|
2011-05-24 21:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_i_set_source_properties_x (SCM obj, long line, int col, SCM fname)
|
|
|
|
|
|
#define FUNC_NAME "%set-source-properties"
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_NIM (1, obj);
|
|
|
|
|
|
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj,
|
|
|
|
|
|
scm_make_srcprops (line, col, fname,
|
|
|
|
|
|
SCM_COPY_SOURCE_P
|
|
|
|
|
|
? scm_copy_tree (obj)
|
|
|
|
|
|
: SCM_UNDEFINED,
|
|
|
|
|
|
SCM_EOL));
|
2011-05-24 21:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM obj, SCM key),
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"Return the source property specified by @var{key} from\n"
|
|
|
|
|
|
"@var{obj}'s source property list.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_source_property
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM p;
|
2012-02-17 10:21:50 +01:00
|
|
|
|
|
2012-02-14 01:54:15 -05:00
|
|
|
|
if (SCM_IMP (obj))
|
|
|
|
|
|
return SCM_BOOL_F;
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2011-10-23 23:38:51 +02:00
|
|
|
|
p = scm_weak_table_refq (scm_source_whash, obj, SCM_EOL);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2002-01-10 21:11:22 +00:00
|
|
|
|
if (!SRCPROPSP (p))
|
2009-08-04 18:54:50 +01:00
|
|
|
|
goto alist;
|
2010-09-24 16:28:33 +02:00
|
|
|
|
if (scm_is_eq (scm_sym_line, key))
|
2012-02-17 10:21:50 +01:00
|
|
|
|
return scm_from_int (SRCPROPLINE (p));
|
2010-09-24 16:28:33 +02:00
|
|
|
|
else if (scm_is_eq (scm_sym_column, key))
|
2012-02-17 10:21:50 +01:00
|
|
|
|
return scm_from_int (SRCPROPCOL (p));
|
2010-09-24 16:28:33 +02:00
|
|
|
|
else if (scm_is_eq (scm_sym_copy, key))
|
2012-02-17 10:21:50 +01:00
|
|
|
|
return SRCPROPCOPY (p);
|
1996-08-20 17:11:59 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2009-08-04 18:54:50 +01:00
|
|
|
|
p = SRCPROPALIST (p);
|
|
|
|
|
|
alist:
|
1996-08-20 17:11:59 +00:00
|
|
|
|
p = scm_assoc (key, p);
|
2011-10-24 17:22:47 +02:00
|
|
|
|
return (scm_is_pair (p) ? SCM_CDR (p) : SCM_BOOL_F);
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_set_source_property_x, "set-source-property!", 3, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM obj, SCM key, SCM datum),
|
2001-01-30 14:53:20 +00:00
|
|
|
|
"Set the source property of object @var{obj}, which is specified by\n"
|
|
|
|
|
|
"@var{key} to @var{datum}. Normally, the key will be a symbol.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_set_source_property_x
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM p;
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_VALIDATE_NIM (1, obj);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_i_pthread_mutex_lock (&scm_i_misc_mutex);
|
|
|
|
|
|
p = scm_weak_table_refq (scm_source_whash, obj, SCM_EOL);
|
2010-09-24 16:28:33 +02:00
|
|
|
|
|
|
|
|
|
|
if (scm_is_eq (scm_sym_line, key))
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (SRCPROPSP (p))
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
SETSRCPROPLINE (p, scm_to_int (datum));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
else
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj,
|
|
|
|
|
|
scm_make_srcprops (scm_to_int (datum), 0,
|
|
|
|
|
|
SCM_UNDEFINED, SCM_UNDEFINED, p));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
2004-07-27 15:41:49 +00:00
|
|
|
|
else if (scm_is_eq (scm_sym_column, key))
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (SRCPROPSP (p))
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
SETSRCPROPCOL (p, scm_to_int (datum));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
else
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj,
|
|
|
|
|
|
scm_make_srcprops (0, scm_to_int (datum),
|
|
|
|
|
|
SCM_UNDEFINED, SCM_UNDEFINED, p));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
2004-07-27 15:41:49 +00:00
|
|
|
|
else if (scm_is_eq (scm_sym_copy, key))
|
1996-08-20 17:11:59 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
if (SRCPROPSP (p))
|
2008-08-26 22:47:19 -03:00
|
|
|
|
SETSRCPROPCOPY (p, datum);
|
1996-08-20 17:11:59 +00:00
|
|
|
|
else
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj,
|
|
|
|
|
|
scm_make_srcprops (0, 0, SCM_UNDEFINED, datum, p));
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2002-03-08 13:11:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (SRCPROPSP (p))
|
2009-08-04 18:54:50 +01:00
|
|
|
|
SETSRCPROPALIST (p, scm_acons (key, datum, SRCPROPALIST (p)));
|
2002-03-08 13:11:34 +00:00
|
|
|
|
else
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, obj,
|
|
|
|
|
|
scm_acons (key, datum, p));
|
2002-03-08 13:11:34 +00:00
|
|
|
|
}
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_i_pthread_mutex_unlock (&scm_i_misc_mutex);
|
2011-05-24 22:46:09 +02:00
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-08-20 17:11:59 +00:00
|
|
|
|
|
* __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
|
|
|
|
|
2009-11-27 23:12:35 +01:00
|
|
|
|
SCM_DEFINE (scm_cons_source, "cons-source", 3, 0, 0,
|
|
|
|
|
|
(SCM xorig, SCM x, SCM y),
|
|
|
|
|
|
"Create and return a new pair whose car and cdr are @var{x} and @var{y}.\n"
|
|
|
|
|
|
"Any source properties associated with @var{xorig} are also associated\n"
|
|
|
|
|
|
"with the new pair.")
|
|
|
|
|
|
#define FUNC_NAME s_scm_cons_source
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM p, z;
|
|
|
|
|
|
z = scm_cons (x, y);
|
|
|
|
|
|
/* Copy source properties possibly associated with xorig. */
|
2011-10-23 23:38:51 +02:00
|
|
|
|
p = scm_weak_table_refq (scm_source_whash, xorig, SCM_BOOL_F);
|
2009-11-27 23:12:35 +01:00
|
|
|
|
if (scm_is_true (p))
|
2011-10-23 23:38:51 +02:00
|
|
|
|
scm_weak_table_putq_x (scm_source_whash, z, p);
|
2009-11-27 23:12:35 +01:00
|
|
|
|
return z;
|
|
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-08-20 17:11:59 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_srcprop ()
|
|
|
|
|
|
{
|
2000-12-08 17:32:56 +00:00
|
|
|
|
scm_tc16_srcprops = scm_make_smob_type ("srcprops", 0);
|
|
|
|
|
|
scm_set_smob_print (scm_tc16_srcprops, srcprops_print);
|
|
|
|
|
|
|
2012-02-19 15:19:14 +01:00
|
|
|
|
scm_source_whash = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY);
|
2001-05-15 14:57:22 +00:00
|
|
|
|
scm_c_define ("source-whash", scm_source_whash);
|
2000-12-11 14:48:23 +00:00
|
|
|
|
|
2009-12-05 11:30:09 +01:00
|
|
|
|
scm_last_alist_filename = scm_cons (SCM_EOL,
|
|
|
|
|
|
scm_acons (SCM_EOL, SCM_EOL, SCM_EOL));
|
2007-01-19 19:33:10 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/srcprop.x"
|
1996-08-20 17:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|