#include "libguile/ports.h"
#include "libguile/root.h"
#include "libguile/weaks.h"
+#include "libguile/gc.h"
#include "libguile/validate.h"
#include "libguile/srcprop.h"
scm_t_bits scm_tc16_srcprops;
-static SCM
-srcprops_mark (SCM obj)
-{
- scm_gc_mark (SRCPROPCOPY (obj));
- return SRCPROPALIST (obj);
-}
-
static int
srcprops_print (SCM obj, SCM port, scm_print_state *pstate)
{
#undef FUNC_NAME
+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. */
+ p = scm_whash_lookup (scm_source_whash, xorig);
+ if (scm_is_true (p))
+ scm_whash_insert (scm_source_whash, z, p);
+ return z;
+}
+#undef FUNC_NAME
+
+
void
scm_init_srcprop ()
{
scm_tc16_srcprops = scm_make_smob_type ("srcprops", 0);
- scm_set_smob_mark (scm_tc16_srcprops, srcprops_mark);
scm_set_smob_print (scm_tc16_srcprops, srcprops_print);
scm_source_whash = scm_make_weak_key_hash_table (scm_from_int (2047));