| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | USING: compiler.tree.builder compiler.tree.recursive | 
					
						
							|  |  |  | compiler.tree.normalization | 
					
						
							|  |  |  | compiler.tree.normalization.introductions | 
					
						
							|  |  |  | compiler.tree.normalization.renaming | 
					
						
							| 
									
										
										
										
											2008-08-22 04:12:15 -04:00
										 |  |  | compiler.tree compiler.tree.checker | 
					
						
							|  |  |  | sequences accessors tools.test kernel math ;
 | 
					
						
							| 
									
										
										
										
											2009-08-13 20:21:44 -04:00
										 |  |  | IN: compiler.tree.normalization.tests | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-27 23:47:40 -04:00
										 |  |  | [ 3 ] [ [ 3drop 1 2 3 ] build-tree count-introductions ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-27 23:47:40 -04:00
										 |  |  | [ 4 ] [ [ 3drop 1 2 3 3drop drop ] build-tree count-introductions ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-27 23:47:40 -04:00
										 |  |  | [ 3 ] [ [ [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-27 23:47:40 -04:00
										 |  |  | [ 2 ] [ [ 3 [ drop ] [ 2drop 3 ] if ] build-tree count-introductions ] unit-test | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-09 02:46:20 -05:00
										 |  |  | : foo ( ..a quot: ( ..a -- ..b ) -- ..b ) call ; inline recursive
 | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : recursive-inputs ( nodes -- n )
 | 
					
						
							|  |  |  |     [ #recursive? ] find nip child>> first in-d>> length ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-17 16:50:03 -04:00
										 |  |  | [ 1 3 ] [ | 
					
						
							|  |  |  |     [ [ swap ] foo ] build-tree | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  |     [ recursive-inputs ] | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  |     [ analyze-recursive normalize recursive-inputs ] bi
 | 
					
						
							| 
									
										
										
										
											2008-07-27 21:25:42 -04:00
										 |  |  | ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-10 00:00:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | : test-normalization ( quot -- )
 | 
					
						
							|  |  |  |     build-tree analyze-recursive normalize check-nodes ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ [ [ 1 ] [ 2 ] if + * ] test-normalization ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | DEFER: bbb | 
					
						
							| 
									
										
										
										
											2009-04-17 13:46:04 -04:00
										 |  |  | : aaa ( obj x -- obj ) dup [ dup [ bbb ] dip aaa ] [ drop ] if ; inline recursive
 | 
					
						
							|  |  |  | : bbb ( obj x -- obj ) [ drop 0 ] dip aaa ; inline recursive
 | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | [ ] [ [ bbb ] test-normalization ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-17 13:46:04 -04:00
										 |  |  | : ccc ( obj -- 1 ) ccc drop 1 ; inline recursive
 | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | [ ] [ [ ccc ] test-normalization ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | DEFER: eee | 
					
						
							| 
									
										
										
										
											2009-04-17 13:46:04 -04:00
										 |  |  | : ddd ( a b -- a b ) eee ; inline recursive
 | 
					
						
							|  |  |  | : eee ( a b -- a b ) swap ddd ; inline recursive
 | 
					
						
							| 
									
										
										
										
											2008-08-15 05:09:23 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | [ ] [ [ eee ] test-normalization ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-22 04:12:15 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : call-recursive-5 ( -- ) call-recursive-5 ; inline recursive
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-09-12 06:17:27 -04:00
										 |  |  | [ ] [ [ call-recursive-5 swap ] test-normalization ] unit-test |