summaryrefslogtreecommitdiff
path: root/libguile/srcprop.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-05-24 21:25:11 +0200
committerAndy Wingo <wingo@pobox.com>2011-05-24 22:41:11 +0200
commit26c8cc144f4d58871098347df7462ea60b72a72c (patch)
tree11ade9f795d50a63afda6d25593f2a3146448813 /libguile/srcprop.c
parentc0937f0988d202d1062fea6e5b61d68d387d1542 (diff)
downloadguile-26c8cc144f4d58871098347df7462ea60b72a72c.tar.gz
read + source properties simplification
* libguile/srcprop.h: Remove internal scm_source_whash declaration. * libguile/srcprop.c (scm_i_set_source_properties_x) (scm_i_has_source_properties): New helpers. (scm_source_whash): Make static. * libguile/read.c (scm_read_sexp): Remove register declarations here; let's trust the compiler. Remove code to incrementally build up a copy; instead let's let scm_i_set_source_properties_x handle copying the expression if needed. (scm_read_quote, scm_read_syntax): Use scm_i_set_source_properties_x. (recsexpr): Remove this helper from 1996. (scm_read_sharp_extension): Instead of trying to recursively label sharp-read subforms with source properties, just label the outside form and rely on the macro-expander to propagate it down.
Diffstat (limited to 'libguile/srcprop.c')
-rw-r--r--libguile/srcprop.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/libguile/srcprop.c b/libguile/srcprop.c
index 4eb1ccaac..64b39fdfc 100644
--- a/libguile/srcprop.c
+++ b/libguile/srcprop.c
@@ -38,6 +38,8 @@
#include "libguile/validate.h"
#include "libguile/srcprop.h"
+#include "libguile/private-options.h"
+
/* {Source Properties}
*
@@ -57,7 +59,7 @@ 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");
-SCM scm_source_whash;
+static SCM scm_source_whash;
@@ -186,6 +188,32 @@ SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
}
#undef FUNC_NAME
+int
+scm_i_has_source_properties (SCM obj)
+#define FUNC_NAME "%set-source-properties"
+{
+ SCM_VALIDATE_NIM (1, obj);
+
+ return scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
+}
+#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);
+
+ scm_hashq_set_x (scm_source_whash, obj,
+ scm_make_srcprops (line, col, fname,
+ SCM_COPY_SOURCE_P
+ ? scm_copy_tree (obj)
+ : SCM_UNDEFINED,
+ SCM_EOL));
+}
+#undef FUNC_NAME
+
SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
(SCM obj, SCM key),
"Return the source property specified by @var{key} from\n"