Next: map-declaration-env, Previous: declaration-env.policy, Up: API
⇒ result-env
:everything, :bound, :free, :unknown,
or a list of normalized declaration identifiers.
:everything, :bound, :free, :unknown,
or a list of normalized declaration identifiers.
The function filter-declaration-env returns a new declaration-env containing a subset of the declaration specifiers in declenv according to a filtering constituted by the given parameters.
include specifies the declaration specifiers to be considered by the filtering. They can be specified either directly via a list of identifiers, or via a keyword representing a certain set of specifiers. These keywords are:
:bound:everything:free:unknownexclude specifies the declaration specifiers to be not considered.
affecting, if given, specifies the set of binding names that the declaration specifiers in the resulting declaration-env must affect. Consequently, only bound declaration specifiers are selected.
not-affecting, if given, specifies the set of binding names that the resulting specifiers must not affect. This possibly includes free declaration specifiers and unknown declaration specifiers
filter-function is called for each declaration specifier in declenv that satisfies the other given parameters. It should return true if this specifier should be included in the resulting declaration-env. The function is invoked with the disassembled parts of this specifier, cf. analyze-declaration-specifier.
PARSE-DECLARATIONS> (defparameter *sample-decls*
'((declare (optimize (speed 3) (safety 0)))
(declare (special *a*) (special *f*))
(declare (inline f))
(declare (author "Tobias C Rittweiler"))
(declare (type integer x y))
(declare (optimize (debug 0)))
(declare (type fixnum z))
(declare ((string 512) output))
(declare (type (vector unsigned-byte 32) chunk))
(declare (quux *a*)) ; assuming QUUX hasn't been defined as type.
(declare (float *f*))
(declare (ftype (function (number) float) f))
))
=> *SAMPLE-DECLS*
PARSE-DECLARATIONS> (defparameter *env* (parse-declarations *sample-decls*))
=> *ENV*
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :include :free))
=> ((DECLARE (OPTIMIZE (DEBUG 0))) (DECLARE (OPTIMIZE (SPEED 3) (SAFETY 0))))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :include :unknown))
=> ((DECLARE (QUUX *A*)) (DECLARE (AUTHOR "Tobias C Rittweiler")))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :affecting '(*a*)))
=> ((DECLARE (SPECIAL *A*)))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :affecting '(*f*)))
=> ((DECLARE (TYPE FLOAT *F*)) (DECLARE (SPECIAL *F*)))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :affecting '(#'f)))
=> ((DECLARE (INLINE F)) (DECLARE (FTYPE (FUNCTION (NUMBER) FLOAT) F)))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env*
:affecting '(#'f)
:exclude '(inline notinline)))
=> ((DECLARE (FTYPE (FUNCTION (NUMBER) FLOAT) F)))
PARSE-DECLARATIONS> (build-declarations 'declare (filter-declaration-env *env* :include '(type)))
=> ((DECLARE (TYPE FLOAT *F*)) (DECLARE (TYPE (VECTOR UNSIGNED-BYTE 32) CHUNK))
(DECLARE (TYPE (STRING 512) OUTPUT)) (DECLARE (TYPE FIXNUM Z))
(DECLARE (TYPE INTEGER X Y)))
Signals an error of type TYPE-ERROR if a passed argument
violates its respective entry in the “Arguments and Values” section.
declaration-env.affected-variables
map-declaration-env
If no &key parameter is given, filter-declaration-env will return a copy of the given
declaration-env. This follows from the default values of the parameters.