2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! Copyright (C) 2008, 2010 Slava Pestov.
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! See http://factorcode.org/license.txt for BSD license.
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-30 19:02:37 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								USING: accessors arrays assocs classes classes.private
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-02 20:18:42 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								classes.tuple.private continuations definitions generic
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								hash-sets init kernel kernel.private math namespaces sequences
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								sets source-files.errors vocabs words ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: compiler.units
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-25 21:02:03 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PRIMITIVE: modify-code-heap ( alist update-existing? reset-pics? -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								SYMBOL: old-definitions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								SYMBOL: new-definitions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								TUPLE: redefine-error def ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-23 20:14:53 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: throw-redefine-error ( definition -- )
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-02 23:16:22 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    redefine-error boa throw-continue ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								<PRIVATE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: add-once ( key set -- )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-24 01:13:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dupd ?adjoin [ drop ] [ throw-redefine-error ] if ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: (remember-definition) ( definition loc set -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-11-02 04:10:27 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ over set-where ] dip add-once ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PRIVATE>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: remember-definition ( definition loc -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    new-definitions get first (remember-definition) ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-07 01:42:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: fake-definition ( definition -- )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    old-definitions get [ delete ] with each ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-07 01:42:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: remember-class ( class loc -- )
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-09 14:04:11 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    new-definitions get first2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ dupd in? [ dup throw-redefine-error ] when ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ (remember-definition) ] bi-curry* bi* ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: forward-reference? ( word -- ? )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dup old-definitions get [ in? ] with any? [
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-14 14:56:31 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        new-definitions get [ in? ] with none?
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] [ drop f ] if ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-13 20:39:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								SYMBOL: compiler-impl
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								HOOK: update-call-sites compiler-impl ( class generic -- words )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 16:25:53 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: changed-call-sites ( class generic -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    update-call-sites [ changed-definition ] each ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								M: generic update-generic ( class generic -- )
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 16:25:53 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ changed-call-sites ]
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ remake-generic drop ]
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-29 11:10:10 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ changed-conditionally drop ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    2tri ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								M: sequence update-methods ( class seq -- )
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-29 03:53:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    implementors [ update-generic ] with each ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-13 20:39:32 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								HOOK: recompile compiler-impl ( words -- alist )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-08 07:08:04 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								HOOK: to-recompile compiler-impl ( -- words )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								HOOK: process-forgotten-words compiler-impl ( words -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: compile ( words -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    recompile t f modify-code-heap ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-12-05 02:55:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: filter-word-defs ( defset -- words )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    members [ word? ] filter ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-03-15 20:15:28 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! Non-optimizing compiler
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								M: f update-call-sites
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    2drop { } ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-08 07:08:04 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								M: f to-recompile
							 | 
						
					
						
							
								
									
										
										
										
											2016-12-05 02:55:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    changed-definitions get filter-word-defs ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-20 10:23:20 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								M: f recompile
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ dup def>> ] { } map>assoc ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-08 07:08:04 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								M: f process-forgotten-words drop ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-05-01 06:52:05 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: without-optimizer ( quot -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ f compiler-impl ] dip with-variable ; inline
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: <definitions> ( -- pair ) { HS{ } HS{ } } [ clone ] map ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								SYMBOL: definition-observers
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								GENERIC: definitions-changed ( set obj -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								[ V{ } clone definition-observers set-global ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-19 22:17:02 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"compiler.units" add-startup-hook
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-05-01 09:21:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! This goes here because vocabs cannot depend on init
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								[ V{ } clone vocab-observers set-global ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-19 22:17:02 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"vocabs" add-startup-hook
							 | 
						
					
						
							
								
									
										
										
										
											2009-05-01 09:21:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: add-definition-observer ( obj -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-02-25 20:37:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    definition-observers get push ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: remove-definition-observer ( obj -- )
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 01:23:08 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    definition-observers get remove-eq! drop ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: notify-definition-observers ( set -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    definition-observers get
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 17:36:30 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ definitions-changed ] with each ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								! Incremented each time stack effects potentially changed, used
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! by compiler.tree.propagation.call-effect for call( and execute(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								! inline caching
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-02 15:54:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: effect-counter ( -- n ) REDEFINITION-COUNTER special-object ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-29 03:53:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								GENERIC: always-bump-effect-counter? ( defspec -- ? )
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-29 03:53:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								M: object always-bump-effect-counter? drop f ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<PRIVATE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: changed-vocabs ( set -- vocabs )
							 | 
						
					
						
							
								
									
										
										
										
											2016-12-05 02:55:32 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    filter-word-defs [ vocabulary>> dup [ lookup-vocab ] when ] map ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: updated-definitions ( -- set )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    forgotten-definitions get union!
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 21:04:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    new-definitions get first union!
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    new-definitions get second union!
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    changed-definitions get union!
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    maybe-changed get union!
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    dup changed-vocabs over adjoin-all ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 12:04:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: process-forgotten-definitions ( forgotten-definitions -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    members
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-08 07:08:04 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ [ word? ] filter process-forgotten-words ]
							 | 
						
					
						
							
								
									
										
										
										
											2009-04-15 01:27:02 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ [ delete-definition-errors ] each ]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    bi ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-06-11 03:58:38 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: bump-effect-counter? ( -- ? )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    changed-effects get members
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    maybe-changed get members
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 12:04:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    changed-definitions get members
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ always-bump-effect-counter? ] filter
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    3array combine new-words get [ in? not ] curry any? ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: bump-effect-counter ( -- )
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-13 00:08:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    bump-effect-counter? [
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-02 15:54:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        REDEFINITION-COUNTER special-object 0 or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        1 + REDEFINITION-COUNTER set-special-object
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-13 00:08:18 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] when ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: notify-observers ( -- )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    updated-definitions dup null?
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ drop ] [ notify-definition-observers notify-error-observers ] if ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								: update-existing? ( defs -- ? )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    new-words get [ in? not ] curry any? ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: reset-pics? ( -- ? )
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    outdated-generics get null? not ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: finish-compilation-unit ( -- )
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-27 09:02:54 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ ] [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        remake-generics
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        to-recompile [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            recompile
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 12:04:12 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            outdated-tuples get update-tuples
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            forgotten-definitions get process-forgotten-definitions
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-01 08:49:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ] keep update-existing? reset-pics? modify-code-heap
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-27 09:02:54 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        bump-effect-counter
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        notify-observers
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] if-bootstrapping ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-09 13:30:05 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								TUPLE: nesting-observer { new-words hash-set } ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-03 09:20:48 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 12:11:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								M: nesting-observer definitions-changed
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-10 19:12:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ members ] dip new-words>> [ delete ] curry each ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-03 09:20:48 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: add-nesting-observer ( -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    new-words get nesting-observer boa
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-29 20:14:42 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ nesting-observer namespaces:set ] [ add-definition-observer ] bi ;
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-03 09:20:48 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: remove-nesting-observer ( -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    nesting-observer get remove-definition-observer ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-13 04:52:14 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								PRIVATE>
							 | 
						
					
						
							
								
									
										
										
										
											2008-05-28 20:34:18 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: with-nested-compilation-unit ( quot -- )
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-02 20:18:42 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    H{ } clone
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone changed-definitions pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone maybe-changed pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone changed-effects pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone outdated-generics pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    H{ } clone outdated-tuples pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone new-words pick set-at [
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-03 09:20:48 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        add-nesting-observer
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remove-nesting-observer
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            finish-compilation-unit
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-22 10:49:05 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        ] finally
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-02 20:18:42 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] with-variables ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-01-09 04:52:08 -05:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: with-compilation-unit ( quot -- )
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-02 20:18:42 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    H{ } clone
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <definitions> new-definitions pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    <definitions> old-definitions pick set-at
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HS{ } clone forgotten-definitions pick set-at [
							 | 
						
					
						
							
								
									
										
										
										
											2010-02-03 09:20:48 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        with-nested-compilation-unit
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-02 20:18:42 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ] with-variables ; inline
							 |