factor/basis/macros/macros.factor

39 lines
938 B
Factor
Raw Normal View History

! Copyright (C) 2007, 2010 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2014-12-16 14:09:47 -05:00
USING: accessors combinators compiler.units definitions effects
effects.parser fry kernel memoize words ;
2007-09-20 18:09:08 -04:00
IN: macros
2009-02-06 11:22:09 -05:00
<PRIVATE
: real-macro-effect ( effect -- effect' )
2009-03-23 01:34:02 -04:00
in>> { "quot" } <effect> ;
2008-01-09 17:52:37 -05:00
2009-02-06 11:22:09 -05:00
PRIVATE>
: define-macro ( word definition effect -- )
real-macro-effect {
[
[ '[ _ _ call-effect ] ] keep
[ memoize-quot '[ @ call ] ] keep
define-declared
]
[ drop "macro" set-word-prop ]
[ 2drop changed-effect ]
} 3cleave ;
2007-09-20 18:09:08 -04:00
SYNTAX: MACRO: (:) define-macro ;
2007-09-20 18:09:08 -04:00
2008-03-26 19:23:19 -04:00
PREDICATE: macro < word "macro" word-prop >boolean ;
2007-09-20 18:09:08 -04:00
M: macro make-inline cannot-be-inline ;
2007-09-20 18:09:08 -04:00
M: macro definer drop \ MACRO: \ ; ;
M: macro definition "macro" word-prop ;
2007-09-20 18:09:08 -04:00
M: macro reset-word
[ call-next-method ] [ f "macro" set-word-prop ] bi ;
M: macro always-bump-effect-counter? drop t ;