]> gitweb.factorcode.org Git - factor.git/blob - basis/macros/macros.factor
windows.types: fix definition of wchar_t* as { char* utf16n }
[factor.git] / basis / macros / macros.factor
1 ! Copyright (C) 2007, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser kernel sequences words effects combinators assocs
4 definitions quotations namespaces memoize accessors fry
5 compiler.units ;
6 IN: macros
7
8 <PRIVATE
9
10 : real-macro-effect ( effect -- effect' )
11     in>> { "quot" } <effect> ;
12
13 PRIVATE>
14
15 : define-macro ( word definition effect -- )
16     real-macro-effect {
17         [
18             [ '[ _ _ call-effect ] ] keep
19             [ memoize-quot '[ @ call ] ] keep
20             define-declared
21         ]
22         [ drop "macro" set-word-prop ]
23         [ 2drop changed-effect ]
24     } 3cleave ;
25
26 SYNTAX: MACRO: (:) define-macro ;
27
28 PREDICATE: macro < word "macro" word-prop >boolean ;
29
30 M: macro make-inline cannot-be-inline ;
31
32 M: macro definer drop \ MACRO: \ ; ;
33
34 M: macro definition "macro" word-prop ;
35
36 M: macro reset-word
37     [ call-next-method ] [ f "macro" set-word-prop ] bi ;
38
39 M: macro always-bump-effect-counter? drop t ;