1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

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.
This commit is contained in:
Andy Wingo 2011-05-24 21:25:11 +02:00
parent c0937f0988
commit 26c8cc144f
3 changed files with 43 additions and 110 deletions

View file

@ -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"