diff options
Diffstat (limited to 'libguile/syntax.c')
-rw-r--r-- | libguile/syntax.c | 63 |
1 files changed, 5 insertions, 58 deletions
diff --git a/libguile/syntax.c b/libguile/syntax.c index 2f416d173..6e298e5e9 100644 --- a/libguile/syntax.c +++ b/libguile/syntax.c @@ -1,4 +1,4 @@ -/* Copyright 2017-2018,2021 +/* Copyright 2017-2018,2021,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -31,7 +31,6 @@ #include "modules.h" #include "pairs.h" #include "ports.h" -#include "srcprop.h" #include "threads.h" #include "variable.h" #include "vectors.h" @@ -41,12 +40,6 @@ -/* The source field was added to syntax objects in Guile 3.0.6. However - there can be older syntax objects present in compiled files that - don't have the source field. If a syntax object has a source field, - its tag will have HAS_SOURCE_WORD_FLAG set. */ -#define HAS_SOURCE_WORD_FLAG 0x100 - enum { TAG_WORD, @@ -76,40 +69,17 @@ SCM_DEFINE (scm_syntax_p, "syntax?", 1, 0, 0, } #undef FUNC_NAME -static SCM -sourcev_to_props (SCM v) -{ - SCM props = scm_acons (scm_sym_line, scm_c_vector_ref (v, 1), - scm_acons (scm_sym_column, scm_c_vector_ref (v, 2), - SCM_EOL)); - if (scm_is_true (scm_c_vector_ref (v, 0))) - props = scm_acons (scm_sym_filename, scm_c_vector_ref (v, 0), props); - return props; -} - -static SCM -props_to_sourcev (SCM props) -{ - SCM v = scm_c_make_vector (3, SCM_BOOL_F); - scm_c_vector_set_x (v, 0, scm_assq_ref (props, scm_sym_filename)); - scm_c_vector_set_x (v, 1, scm_assq_ref (props, scm_sym_line)); - scm_c_vector_set_x (v, 2, scm_assq_ref (props, scm_sym_column)); - return v; -} - SCM_DEFINE (scm_make_syntax, "make-syntax", 3, 1, 0, (SCM exp, SCM wrap, SCM module, SCM source), "Make a new syntax object.") #define FUNC_NAME s_scm_make_syntax { if (SCM_UNBNDP (source)) - source = scm_source_properties (exp); - if (scm_is_pair (source)) - source = props_to_sourcev (source); - if (!scm_is_vector (source)) source = SCM_BOOL_F; + else if (!scm_is_eq (source, SCM_BOOL_F)) + SCM_VALIDATE_VECTOR (1, source); - SCM ret = scm_words (scm_tc7_syntax | HAS_SOURCE_WORD_FLAG, WORD_COUNT); + SCM ret = scm_words (scm_tc7_syntax, WORD_COUNT); SCM_SET_CELL_OBJECT (ret, EXPR_WORD, exp); SCM_SET_CELL_OBJECT (ret, WRAP_WORD, wrap); SCM_SET_CELL_OBJECT (ret, MODULE_WORD, module); @@ -158,30 +128,7 @@ SCM_DEFINE (scm_syntax_source, "syntax-source", 1, 0, 0, #define FUNC_NAME s_scm_syntax_source { SCM_VALIDATE_SYNTAX (1, obj); - if (!(SCM_CELL_WORD (obj, TAG_WORD) & HAS_SOURCE_WORD_FLAG)) - return SCM_BOOL_F; - SCM src = SCM_CELL_OBJECT (obj, SOURCE_WORD); - if (scm_is_vector (src)) - src = sourcev_to_props (src); - return src; -} -#undef FUNC_NAME - -SCM_DEFINE (scm_syntax_sourcev, "syntax-sourcev", 1, 0, 0, - (SCM obj), - "Return the source location information for syntax object\n" - "@var{obj}, as a vector of @code{#(@var{filename} @var{line}\n" - "@var{column})}, or @code{#f} if no source properties are\n" - "available.") -#define FUNC_NAME s_scm_syntax_sourcev -{ - SCM_VALIDATE_SYNTAX (1, obj); - if (!(SCM_CELL_WORD (obj, TAG_WORD) & HAS_SOURCE_WORD_FLAG)) - return SCM_BOOL_F; - SCM src = SCM_CELL_OBJECT (obj, SOURCE_WORD); - if (scm_is_null (src) || scm_is_pair (src)) - src = props_to_sourcev (src); - return src; + return SCM_CELL_OBJECT (obj, SOURCE_WORD); } #undef FUNC_NAME |