| 
									
										
										
										
											2010-01-27 03:00:10 -05:00
										 |  |  | ! 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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-21 04:17:35 -04:00
										 |  |  | : real-macro-effect ( effect -- effect' )
 | 
					
						
							| 
									
										
										
										
											2009-03-23 01:34:02 -04:00
										 |  |  |     in>> { "quot" } <effect> ;
 | 
					
						
							| 
									
										
										
										
											2008-01-09 17:52:37 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-19 14:16:19 -04:00
										 |  |  | : check-macro-effect ( word effect -- )
 | 
					
						
							|  |  |  |     [ real-macro-effect ] keep 2dup effect= | 
					
						
							|  |  |  |     [ 3drop ] [ bad-stack-effect ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-06 11:22:09 -05:00
										 |  |  | PRIVATE>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-01 11:50:13 -05:00
										 |  |  | : define-macro ( word definition effect -- )
 | 
					
						
							| 
									
										
										
										
											2015-07-19 14:16:19 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ nip check-macro-effect ] | 
					
						
							| 
									
										
										
										
											2010-02-01 12:56:13 -05:00
										 |  |  |         [ | 
					
						
							|  |  |  |             [ '[ _ _ call-effect ] ] keep
 | 
					
						
							| 
									
										
										
										
											2015-07-19 14:38:02 -04:00
										 |  |  |             [ memoize-quot '[ @ call ] ] keep
 | 
					
						
							| 
									
										
										
										
											2010-02-01 12:56:13 -05:00
										 |  |  |             define-declared | 
					
						
							|  |  |  |         ] | 
					
						
							| 
									
										
										
										
											2010-02-01 11:50:13 -05:00
										 |  |  |         [ drop "macro" set-word-prop ] | 
					
						
							|  |  |  |         [ 2drop changed-effect ] | 
					
						
							|  |  |  |     } 3cleave ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-21 02:27:50 -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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-13 19:13:05 -04:00
										 |  |  | M: macro make-inline cannot-be-inline ;
 | 
					
						
							| 
									
										
										
										
											2010-01-27 03:00:10 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | M: macro definer drop \ MACRO: \ ; ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-01 11:50:13 -05:00
										 |  |  | M: macro definition "macro" word-prop ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-01 11:50:13 -05:00
										 |  |  | M: macro reset-word | 
					
						
							|  |  |  |     [ call-next-method ] [ f "macro" set-word-prop ] bi ;
 | 
					
						
							| 
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-29 08:58:39 -05:00
										 |  |  | M: macro always-bump-effect-counter? drop t ;
 |