diff options
author | Andy Wingo <wingo@pobox.com> | 2010-01-05 15:20:47 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-01-05 15:33:46 +0100 |
commit | e809758a7e0f3f63162a0a9064b95bd1c1d10628 (patch) | |
tree | 4090a48ef3c228e2609b2bee7a6946172d4a91a1 /libguile/macros.h | |
parent | bab980466108c6c22d2c820213d07b3d1b18c48e (diff) | |
download | guile-e809758a7e0f3f63162a0a9064b95bd1c1d10628.tar.gz |
clean up macros.[ch]
There are some incompatible changes here, but only to interfaces that
were introduced earlier in 1.9, or interfaces which have been broken
since early in 1.9.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the macro
changes affect the interface that is called by psyntax-generated macro
definitions.
* libguile/inline.h (scm_words): New function, allocates a variable
number of contiguous scm_t_bits locations, with a given value in the
0th word, and 0 in the rest of the words.
* libguile/macros.h: Rework interface to correspond more closely, and
minimally, to the needs of memoize.c and psyntax.
(SCM_ASSYNT, SCM_MACRO_TYPE_BITS, SCM_MACRO_TYPE_MASK)
(SCM_F_MACRO_EXTENDED, SCM_MACROP, SCM_MACRO_TYPE)
(SCM_MACRO_IS_EXTENDED, SCM_BUILTIN_MACRO_P, SCM_SYNCASE_MACRO_P)
(SCM_MACRO_CODE, scm_tc16_macro): Remove CPP macros related to the
representation of Scheme macros.
(scm_i_make_primitive_macro): Renamed from scm_i_makbimacro.
(scm_i_macro_primitive): New accessor so that memoize.c can get to the
primitive syntax transformer.
(scm_make_syncase_macro, scm_make_extended_syncase_macro)
(scm_syncase_macro_type, scm_syncase_macro_binding): Removed these
functions, replaced by make-syntax-transformer and its accessors.
(scm_macro_binding): New accessor, the same as what
scm_syncase_macro_binding was.
* libguile/macros.c: All representation details of syntax transformers
are private to this file now.
(macro_print): Print macros as #<syntax-transformer ...>, or
#<primitive-syntax-transformer ...> if psyntax has not attached a
transformer of its own.
(scm_i_make_primitive_macro): Represent macros as 5-word smobs.
(scm_make_syntax_transformer): New constructor for syntax transformers
(macros), exported to scheme. Takes a name, and looks it up in the
current module to determine the previous primitive transformer, if
any.
(scm_macro_type): Instead of returning 'builtin-macro!, etc, return
the type as set by psyntax, or #f if it's a primitive.
(scm_macro_name): Return the stored macro name.
(scm_macro_transformer): Return the psyntax-set syntax transformer.
Hacky, but should help introspection somewhat.
* libguile/memoize.c (memoize_env_ref_transformer): Use the new
scm_i_macro_primitive, and adapt to other macro API changes.
* module/ice-9/psyntax.scm (put-global-definition-hook)
(get-global-definition-hook, chi-install-global): Call (and generate
calls to) the new macro constructors and accessors.
* module/ice-9/psyntax-pp.scm: Doubly regenerated.
* module/ice-9/debugging/traps.scm (trap-here): Comment out this
definition and export, while it's not working.
Diffstat (limited to 'libguile/macros.h')
-rw-r--r-- | libguile/macros.h | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/libguile/macros.h b/libguile/macros.h index 38ec2d7d3..de2496e1e 100644 --- a/libguile/macros.h +++ b/libguile/macros.h @@ -27,32 +27,20 @@ -#define SCM_ASSYNT(_cond, _msg, _subr) \ - if (!(_cond)) scm_misc_error (_subr, _msg, SCM_EOL); +typedef SCM (*scm_t_macro_primitive) (SCM, SCM); -#define SCM_MACRO_TYPE_BITS (3) -#define SCM_MACRO_TYPE_MASK ((1<<SCM_MACRO_TYPE_BITS)-1) -#define SCM_F_MACRO_EXTENDED (1<<SCM_MACRO_TYPE_BITS) - -#define SCM_MACROP(x) SCM_SMOB_PREDICATE (scm_tc16_macro, (x)) -#define SCM_MACRO_TYPE(m) (SCM_SMOB_FLAGS (m) & SCM_MACRO_TYPE_MASK) -#define SCM_MACRO_IS_EXTENDED(m) (SCM_SMOB_FLAGS (m) & SCM_F_MACRO_EXTENDED) -#define SCM_BUILTIN_MACRO_P(x) (SCM_MACROP (x) && SCM_MACRO_TYPE (x) == 3) -#define SCM_SYNCASE_MACRO_P(x) (SCM_MACROP (x) && SCM_MACRO_TYPE (x) == 4) -#define SCM_MACRO_CODE(m) SCM_SMOB_OBJECT (m) - -SCM_API scm_t_bits scm_tc16_macro; - -SCM_INTERNAL SCM scm_i_makbimacro (const char *name, SCM (*fn)(SCM,SCM)); -SCM_API SCM scm_make_syncase_macro (SCM type, SCM binding); -SCM_API SCM scm_make_extended_syncase_macro (SCM builtin, SCM type, - SCM binding); +SCM_API SCM scm_make_syntax_transformer (SCM name_or_existing_definition, + SCM type, SCM binding); SCM_API SCM scm_macro_p (SCM obj); SCM_API SCM scm_macro_type (SCM m); SCM_API SCM scm_macro_name (SCM m); +SCM_API SCM scm_macro_binding (SCM m); SCM_API SCM scm_macro_transformer (SCM m); -SCM_API SCM scm_syncase_macro_type (SCM m); -SCM_API SCM scm_syncase_macro_binding (SCM m); + +SCM_INTERNAL SCM scm_i_make_primitive_macro (const char *name, + scm_t_macro_primitive fn); +SCM_INTERNAL scm_t_macro_primitive scm_i_macro_primitive (SCM m); + SCM_INTERNAL void scm_init_macros (void); |