[gforth] / gforth / kernel / comp.fs  

gforth: gforth/kernel/comp.fs


1 : pazsan 1.1 \ compiler definitions 14sep97jaw
2 :    
3 : anton 1.28 \ Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.
4 : anton 1.6
5 :     \ This file is part of Gforth.
6 :    
7 :     \ Gforth is free software; you can redistribute it and/or
8 :     \ modify it under the terms of the GNU General Public License
9 :     \ as published by the Free Software Foundation; either version 2
10 :     \ of the License, or (at your option) any later version.
11 :    
12 :     \ This program is distributed in the hope that it will be useful,
13 :     \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     \ GNU General Public License for more details.
16 :    
17 :     \ You should have received a copy of the GNU General Public License
18 :     \ along with this program; if not, write to the Free Software
19 : anton 1.29 \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 : anton 1.6
21 : pazsan 1.1 \ \ Revisions-Log
22 :    
23 :     \ put in seperate file 14sep97jaw
24 :    
25 :     \ \ here allot , c, A, 17dec92py
26 :    
27 : jwilke 1.14 [IFUNDEF] allot
28 :     [IFUNDEF] forthstart
29 :     : allot ( n -- ) \ core
30 :     dup unused u> -8 and throw
31 :     dp +! ;
32 :     [THEN]
33 :     [THEN]
34 :    
35 :     \ we default to this version if we have nothing else 05May99jaw
36 :     [IFUNDEF] allot
37 : pazsan 1.1 : allot ( n -- ) \ core
38 : anton 1.23 \G Reserve @i{n} address units of data space without
39 :     \G initialization. @i{n} is a signed number, passing a negative
40 :     \G @i{n} releases memory. In ANS Forth you can only deallocate
41 :     \G memory from the current contiguous region in this way. In
42 :     \G Gforth you can deallocate anything in this way but named words.
43 :     \G The system does not check this restriction.
44 : anton 1.12 here +
45 :     dup 1- usable-dictionary-end forthstart within -8 and throw
46 :     dp ! ;
47 : jwilke 1.14 [THEN]
48 : pazsan 1.1
49 : crook 1.22 : c, ( c -- ) \ core c-comma
50 : crook 1.15 \G Reserve data space for one char and store @i{c} in the space.
51 : pazsan 1.1 here 1 chars allot c! ;
52 :    
53 : crook 1.22 : , ( w -- ) \ core comma
54 : crook 1.15 \G Reserve data space for one cell and store @i{w} in the space.
55 : pazsan 1.1 here cell allot ! ;
56 :    
57 :     : 2, ( w1 w2 -- ) \ gforth
58 : crook 1.15 \G Reserve data space for two cells and store the double @i{w1
59 : anton 1.24 \G w2} there, @i{w2} first (lower address).
60 : pazsan 1.1 here 2 cells allot 2! ;
61 :    
62 :     \ : aligned ( addr -- addr' ) \ core
63 :     \ [ cell 1- ] Literal + [ -1 cells ] Literal and ;
64 :    
65 :     : align ( -- ) \ core
66 : crook 1.15 \G If the data-space pointer is not aligned, reserve enough space to align it.
67 : pazsan 1.1 here dup aligned swap ?DO bl c, LOOP ;
68 :    
69 : crook 1.22 \ : faligned ( addr -- f-addr ) \ float f-aligned
70 : pazsan 1.1 \ [ 1 floats 1- ] Literal + [ -1 floats ] Literal and ;
71 :    
72 : crook 1.22 : falign ( -- ) \ float f-align
73 : crook 1.15 \G If the data-space pointer is not float-aligned, reserve
74 :     \G enough space to align it.
75 : pazsan 1.1 here dup faligned swap
76 :     ?DO
77 :     bl c,
78 :     LOOP ;
79 :    
80 : anton 1.9 : maxalign ( -- ) \ gforth
81 : anton 1.23 \G Align data-space pointer for all alignment requirements.
82 : pazsan 1.1 here dup maxaligned swap
83 :     ?DO
84 :     bl c,
85 :     LOOP ;
86 :    
87 :     \ the code field is aligned if its body is maxaligned
88 :     ' maxalign Alias cfalign ( -- ) \ gforth
89 : anton 1.24 \G Align data-space pointer for code field requirements (i.e., such
90 :     \G that the corresponding body is maxaligned).
91 : pazsan 1.1
92 :     ' , alias A, ( addr -- ) \ gforth
93 :    
94 :     ' NOOP ALIAS const
95 :    
96 :     \ \ Header 23feb93py
97 :    
98 :     \ input-stream, nextname and noname are quite ugly (passing
99 :     \ information through global variables), but they are useful for dealing
100 :     \ with existing/independent defining words
101 :    
102 :     defer (header)
103 :     defer header ( -- ) \ gforth
104 :     ' (header) IS header
105 :    
106 :     : string, ( c-addr u -- ) \ gforth
107 :     \G puts down string as cstring
108 :     dup c, here swap chars dup allot move ;
109 :    
110 : anton 1.30 : longstring, ( c-addr u -- ) \ gforth
111 :     \G puts down string as cstring
112 :     dup , here swap chars dup allot move ;
113 :    
114 : pazsan 1.1 : header, ( c-addr u -- ) \ gforth
115 :     name-too-long?
116 :     align here last !
117 :     current @ 1 or A, \ link field; before revealing, it contains the
118 :     \ tagged reveal-into wordlist
119 : anton 1.30 longstring, cfalign
120 : pazsan 1.1 alias-mask lastflags cset ;
121 :    
122 :     : input-stream-header ( "name" -- )
123 :     name name-too-short? header, ;
124 :    
125 :     : input-stream ( -- ) \ general
126 :     \G switches back to getting the name from the input stream ;
127 :     ['] input-stream-header IS (header) ;
128 :    
129 :     ' input-stream-header IS (header)
130 :    
131 : anton 1.32 2variable nextname-string
132 : pazsan 1.1
133 : pazsan 1.33 has? OS [IF]
134 : pazsan 1.1 : nextname-header ( -- )
135 : anton 1.32 nextname-string 2@ header,
136 :     nextname-string free-mem-var
137 : pazsan 1.1 input-stream ;
138 : pazsan 1.33 [THEN]
139 : pazsan 1.1
140 :     \ the next name is given in the string
141 :    
142 : pazsan 1.33 has? OS [IF]
143 : pazsan 1.1 : nextname ( c-addr u -- ) \ gforth
144 : anton 1.19 \g The next defined word will have the name @var{c-addr u}; the
145 :     \g defining word will leave the input stream alone.
146 : pazsan 1.1 name-too-long?
147 : anton 1.32 nextname-string free-mem-var
148 :     save-mem nextname-string 2!
149 : pazsan 1.1 ['] nextname-header IS (header) ;
150 : pazsan 1.33 [THEN]
151 : pazsan 1.1
152 :     : noname-header ( -- )
153 :     0 last ! cfalign
154 :     input-stream ;
155 :    
156 :     : noname ( -- ) \ gforth
157 : anton 1.19 \g The next defined word will be anonymous. The defining word will
158 :     \g leave the input stream alone. The xt of the defined word will
159 :     \g be given by @code{lastxt}.
160 : pazsan 1.1 ['] noname-header IS (header) ;
161 :    
162 :     : lastxt ( -- xt ) \ gforth
163 : crook 1.15 \G @i{xt} is the execution token of the last word defined.
164 : crook 1.13 \ The main purpose of this word is to get the xt of words defined using noname
165 : pazsan 1.1 lastcfa @ ;
166 :    
167 :     \ \ literals 17dec92py
168 :    
169 :     : Literal ( compilation n -- ; run-time -- n ) \ core
170 : anton 1.27 \G Compilation semantics: compile the run-time semantics.@*
171 :     \G Run-time Semantics: push @i{n}.@*
172 :     \G Interpretation semantics: undefined.
173 : jwilke 1.14 [ [IFDEF] lit, ]
174 :     lit,
175 :     [ [ELSE] ]
176 : anton 1.27 postpone lit ,
177 : jwilke 1.14 [ [THEN] ] ; immediate restrict
178 : pazsan 1.1
179 :     : ALiteral ( compilation addr -- ; run-time -- addr ) \ gforth
180 : jwilke 1.14 [ [IFDEF] alit, ]
181 :     alit,
182 :     [ [ELSE] ]
183 :     postpone lit A,
184 :     [ [THEN] ] ; immediate restrict
185 : pazsan 1.1
186 : crook 1.8 : char ( '<spaces>ccc' -- c ) \ core
187 : crook 1.15 \G Skip leading spaces. Parse the string @i{ccc} and return @i{c}, the
188 :     \G display code representing the first character of @i{ccc}.
189 : pazsan 1.1 bl word char+ c@ ;
190 :    
191 : crook 1.8 : [char] ( compilation '<spaces>ccc' -- ; run-time -- c ) \ core bracket-char
192 : crook 1.10 \G Compilation: skip leading spaces. Parse the string
193 : crook 1.15 \G @i{ccc}. Run-time: return @i{c}, the display code
194 :     \G representing the first character of @i{ccc}. Interpretation
195 : crook 1.10 \G semantics for this word are undefined.
196 : pazsan 1.1 char postpone Literal ; immediate restrict
197 :    
198 :     \ \ threading 17mar93py
199 :    
200 :     : cfa, ( code-address -- ) \ gforth cfa-comma
201 :     here
202 :     dup lastcfa !
203 :     0 A, 0 , code-address! ;
204 :    
205 : jwilke 1.14 [IFUNDEF] compile,
206 : anton 1.34 defer compile, ( xt -- ) \ core-ext compile-comma
207 :     \G Compile the word represented by the execution token @i{xt}
208 :     \G into the current definition.
209 :    
210 :     ' , is compile,
211 : jwilke 1.14 [THEN]
212 : pazsan 1.1
213 : anton 1.34 : peephole-compile, ( xt -- )
214 :     last-compiled @ ?dup if
215 :     @ over peeptable peephole-opt ?dup if
216 :     last-compiled @ ! drop EXIT
217 :     then
218 :     then
219 :     here last-compiled !
220 :     , ;
221 :    
222 :     ' peephole-compile, IS compile,
223 :    
224 : pazsan 1.1 : !does ( addr -- ) \ gforth store-does
225 :     lastxt does-code! ;
226 :    
227 :     : (does>) ( R: addr -- )
228 :     r> cfaligned /does-handler + !does ;
229 :    
230 :     : dodoes, ( -- )
231 :     cfalign here /does-handler allot does-handler! ;
232 :    
233 :     : (compile) ( -- ) \ gforth
234 :     r> dup cell+ >r @ compile, ;
235 :    
236 :     \ \ ticks
237 :    
238 :     : name>comp ( nt -- w xt ) \ gforth
239 : crook 1.15 \G @i{w xt} is the compilation token for the word @i{nt}.
240 : pazsan 1.1 (name>comp)
241 :     1 = if
242 :     ['] execute
243 :     else
244 :     ['] compile,
245 :     then ;
246 :    
247 :     : [(')] ( compilation "name" -- ; run-time -- nt ) \ gforth bracket-paren-tick
248 :     (') postpone ALiteral ; immediate restrict
249 :    
250 :     : ['] ( compilation. "name" -- ; run-time. -- xt ) \ core bracket-tick
251 : crook 1.15 \g @i{xt} represents @i{name}'s interpretation
252 :     \g semantics. Perform @code{-14 throw} if the word has no
253 : pazsan 1.1 \g interpretation semantics.
254 :     ' postpone ALiteral ; immediate restrict
255 :    
256 : anton 1.5 : COMP' ( "name" -- w xt ) \ gforth comp-tick
257 : crook 1.15 \g Compilation token @i{w xt} represents @i{name}'s compilation semantics.
258 : pazsan 1.1 (') name>comp ;
259 :    
260 :     : [COMP'] ( compilation "name" -- ; run-time -- w xt ) \ gforth bracket-comp-tick
261 : crook 1.15 \g Compilation token @i{w xt} represents @i{name}'s compilation semantics.
262 : pazsan 1.1 COMP' swap POSTPONE Aliteral POSTPONE ALiteral ; immediate restrict
263 :    
264 : jwilke 1.18 : postpone, ( w xt -- ) \ gforth postpone-comma
265 : anton 1.26 \g Compile the compilation semantics represented by the
266 :     \g compilation token @i{w xt}.
267 : jwilke 1.18 dup ['] execute =
268 :     if
269 :     drop compile,
270 :     else
271 :     dup ['] compile, =
272 :     if
273 :     drop POSTPONE (compile) a,
274 :     else
275 :     swap POSTPONE aliteral compile,
276 :     then
277 :     then ;
278 :    
279 :     : POSTPONE ( "name" -- ) \ core
280 :     \g Compiles the compilation semantics of @i{name}.
281 :     COMP' postpone, ; immediate restrict
282 :    
283 : pazsan 1.1 \ \ recurse 17may93jaw
284 :    
285 :     : recurse ( compilation -- ; run-time ?? -- ?? ) \ core
286 : crook 1.10 \g Call the current definition.
287 : pazsan 1.1 lastxt compile, ; immediate restrict
288 :    
289 :     \ \ compiler loop
290 :    
291 :     : compiler ( c-addr u -- )
292 :     2dup find-name dup
293 :     if ( c-addr u nt )
294 :     nip nip name>comp execute
295 :     else
296 :     drop
297 :     2dup snumber? dup
298 :     IF
299 :     0>
300 :     IF
301 :     swap postpone Literal
302 :     THEN
303 :     postpone Literal
304 :     2drop
305 :     ELSE
306 :     drop compiler-notfound
307 :     THEN
308 :     then ;
309 :    
310 : crook 1.22 : [ ( -- ) \ core left-bracket
311 : crook 1.8 \G Enter interpretation state. Immediate word.
312 : pazsan 1.1 ['] interpreter IS parser state off ; immediate
313 :    
314 :     : ] ( -- ) \ core right-bracket
315 : crook 1.8 \G Enter compilation state.
316 : pazsan 1.1 ['] compiler IS parser state on ;
317 :    
318 :     \ \ Strings 22feb93py
319 :    
320 :     : ," ( "string"<"> -- ) [char] " parse
321 :     here over char+ allot place align ;
322 :    
323 :     : SLiteral ( Compilation c-addr1 u ; run-time -- c-addr2 u ) \ string
324 : crook 1.15 \G Compilation: compile the string specified by @i{c-addr1},
325 :     \G @i{u} into the current definition. Run-time: return
326 :     \G @i{c-addr2 u} describing the address and length of the
327 : crook 1.10 \G string.
328 : pazsan 1.1 postpone (S") here over char+ allot place align ;
329 :     immediate restrict
330 :    
331 :     \ \ abort" 22feb93py
332 :    
333 :     : abort" ( compilation 'ccc"' -- ; run-time f -- ) \ core,exception-ext abort-quote
334 : crook 1.15 \G If any bit of @i{f} is non-zero, perform the function of @code{-2 throw},
335 :     \G displaying the string @i{ccc} if there is no exception frame on the
336 : crook 1.10 \G exception stack.
337 : pazsan 1.1 postpone (abort") ," ; immediate restrict
338 :    
339 :     \ \ Header states 23feb93py
340 :    
341 :     : cset ( bmask c-addr -- )
342 : anton 1.30 tuck @ or swap ! ;
343 : pazsan 1.1
344 :     : creset ( bmask c-addr -- )
345 : anton 1.30 tuck @ swap invert and swap ! ;
346 : pazsan 1.1
347 :     : ctoggle ( bmask c-addr -- )
348 : anton 1.30 tuck @ xor swap ! ;
349 : pazsan 1.1
350 :     : lastflags ( -- c-addr )
351 :     \ the address of the flags byte in the last header
352 :     \ aborts if the last defined word was headerless
353 :     last @ dup 0= abort" last word was headerless" cell+ ;
354 :    
355 :     : immediate ( -- ) \ core
356 : crook 1.10 \G Make the compilation semantics of a word be to @code{execute}
357 :     \G the execution semantics.
358 : pazsan 1.1 immediate-mask lastflags cset ;
359 :    
360 :     : restrict ( -- ) \ gforth
361 : crook 1.10 \G A synonym for @code{compile-only}
362 : pazsan 1.1 restrict-mask lastflags cset ;
363 : jwilke 1.18
364 : pazsan 1.1 ' restrict alias compile-only ( -- ) \ gforth
365 : crook 1.10 \G Remove the interpretation semantics of a word.
366 : pazsan 1.1
367 :     \ \ Create Variable User Constant 17mar93py
368 :    
369 : crook 1.15 : Alias ( xt "name" -- ) \ gforth
370 : pazsan 1.1 Header reveal
371 :     alias-mask lastflags creset
372 :     dup A, lastcfa ! ;
373 :    
374 :     doer? :dovar [IF]
375 :    
376 :     : Create ( "name" -- ) \ core
377 :     Header reveal dovar: cfa, ;
378 :     [ELSE]
379 :    
380 :     : Create ( "name" -- ) \ core
381 :     Header reveal here lastcfa ! 0 A, 0 , DOES> ;
382 :     [THEN]
383 :    
384 :     : Variable ( "name" -- ) \ core
385 :     Create 0 , ;
386 :    
387 :     : AVariable ( "name" -- ) \ gforth
388 :     Create 0 A, ;
389 :    
390 : crook 1.22 : 2Variable ( "name" -- ) \ double two-variable
391 : pazsan 1.1 create 0 , 0 , ;
392 :    
393 : crook 1.21 : uallot ( n -- ) \ gforth
394 :     udp @ swap udp +! ;
395 : pazsan 1.1
396 :     doer? :douser [IF]
397 :    
398 :     : User ( "name" -- ) \ gforth
399 :     Header reveal douser: cfa, cell uallot , ;
400 :    
401 :     : AUser ( "name" -- ) \ gforth
402 :     User ;
403 :     [ELSE]
404 :    
405 :     : User Create cell uallot , DOES> @ up @ + ;
406 :    
407 :     : AUser User ;
408 :     [THEN]
409 :    
410 :     doer? :docon [IF]
411 :     : (Constant) Header reveal docon: cfa, ;
412 :     [ELSE]
413 :     : (Constant) Create DOES> @ ;
414 :     [THEN]
415 :    
416 :     : Constant ( w "name" -- ) \ core
417 : crook 1.15 \G Define a constant @i{name} with value @i{w}.
418 : pazsan 1.1 \G
419 : crook 1.15 \G @i{name} execution: @i{-- w}
420 : pazsan 1.1 (Constant) , ;
421 :    
422 :     : AConstant ( addr "name" -- ) \ gforth
423 :     (Constant) A, ;
424 :    
425 :     : Value ( w "name" -- ) \ core-ext
426 :     (Constant) , ;
427 :    
428 : crook 1.22 : 2Constant ( w1 w2 "name" -- ) \ double two-constant
429 : pazsan 1.1 Create ( w1 w2 "name" -- )
430 :     2,
431 :     DOES> ( -- w1 w2 )
432 :     2@ ;
433 :    
434 :     doer? :dofield [IF]
435 :     : (Field) Header reveal dofield: cfa, ;
436 :     [ELSE]
437 :     : (Field) Create DOES> @ + ;
438 :     [THEN]
439 :     \ IS Defer What's Defers TO 24feb93py
440 :    
441 :     doer? :dodefer [IF]
442 :    
443 :     : Defer ( "name" -- ) \ gforth
444 :     \ !! shouldn't it be initialized with abort or something similar?
445 :     Header Reveal dodefer: cfa,
446 :     ['] noop A, ;
447 : jwilke 1.18
448 : pazsan 1.1 [ELSE]
449 :    
450 :     : Defer ( "name" -- ) \ gforth
451 :     Create ['] noop A,
452 :     DOES> @ execute ;
453 : jwilke 1.18
454 : pazsan 1.1 [THEN]
455 :    
456 : anton 1.25 : Defers ( compilation "name" -- ; run-time ... -- ... ) \ gforth
457 :     \G Compiles the present contents of the deferred word @i{name}
458 :     \G into the current definition. I.e., this produces static
459 :     \G binding as if @i{name} was not deferred.
460 : pazsan 1.1 ' >body @ compile, ; immediate
461 : jwilke 1.18
462 :     :noname
463 :     dodoes, here !does ]
464 :     defstart :-hook ;
465 :     :noname
466 :     ;-hook ?struc
467 :     [ has? xconds [IF] ] exit-like [ [THEN] ]
468 :     postpone (does>) dodoes,
469 :     defstart :-hook ;
470 :     interpret/compile: DOES> ( compilation colon-sys1 -- colon-sys2 ; run-time nest-sys -- ) \ core does
471 :    
472 : anton 1.20 : <IS> ( "name" xt -- ) \ gforth
473 :     \g Changes the @code{defer}red word @var{name} to execute @var{xt}.
474 :     ' >body ! ;
475 :    
476 :     : [IS] ( compilation "name" -- ; run-time xt -- ) \ gforth bracket-is
477 :     \g At run-time, changes the @code{defer}red word @var{name} to
478 :     \g execute @var{xt}.
479 : jwilke 1.18 ' >body postpone ALiteral postpone ! ; immediate restrict
480 :    
481 : anton 1.20 ' <IS>
482 : jwilke 1.18 ' [IS]
483 :     interpret/compile: IS ( xt "name" -- ) \ gforth
484 : crook 1.21 \G A combined word made up from @code{<IS>} and @code{[IS]}.
485 : jwilke 1.18
486 : anton 1.20 ' <IS>
487 :     ' [IS]
488 :     interpret/compile: TO ( w "name" -- ) \ core-ext
489 : jwilke 1.18
490 :     :noname ' >body @ ;
491 :     :noname ' >body postpone ALiteral postpone @ ;
492 : anton 1.25 interpret/compile: What's ( interpretation "name" -- xt; compilation "name" -- ; run-time -- xt ) \ gforth
493 :     \G @i{Xt} is the XT that is currently assigned to @i{name}.
494 : jwilke 1.18
495 :     \ \ interpret/compile:
496 :    
497 :     struct
498 :     >body
499 :     cell% field interpret/compile-int
500 :     cell% field interpret/compile-comp
501 :     end-struct interpret/compile-struct
502 :    
503 :     : interpret/compile: ( interp-xt comp-xt "name" -- ) \ gforth
504 :     Create immediate swap A, A,
505 :     DOES>
506 :     abort" executed primary cfa of an interpret/compile: word" ;
507 :     \ state @ IF cell+ THEN perform ;
508 :    
509 :     : interpret/compile? ( xt -- flag )
510 :     >does-code ['] DOES> >does-code = ;
511 : pazsan 1.1
512 :     \ \ : ; 24feb93py
513 :    
514 :     defer :-hook ( sys1 -- sys2 )
515 :    
516 :     defer ;-hook ( sys2 -- sys1 )
517 :    
518 : jwilke 1.16 0 Constant defstart
519 :    
520 : jwilke 1.14 [IFDEF] docol,
521 :     : (:noname) ( -- colon-sys )
522 :     \ common factor of : and :noname
523 : anton 1.34 docol, ]comp
524 : jwilke 1.14 [ELSE]
525 : anton 1.7 : (:noname) ( -- colon-sys )
526 :     \ common factor of : and :noname
527 : anton 1.34 docol: cfa,
528 : jwilke 1.14 [THEN]
529 : anton 1.34 0 last-compiled ! defstart ] :-hook ;
530 : anton 1.7
531 : pazsan 1.1 : : ( "name" -- colon-sys ) \ core colon
532 : anton 1.7 Header (:noname) ;
533 :    
534 :     : :noname ( -- xt colon-sys ) \ core-ext colon-no-name
535 :     0 last !
536 :     cfalign here (:noname) ;
537 : pazsan 1.1
538 : jwilke 1.14 [IFDEF] fini,
539 :     : ; ( compilation colon-sys -- ; run-time nest-sys ) \ core semicolon
540 :     ;-hook ?struc fini, comp[ reveal postpone [ ; immediate restrict
541 :     [ELSE]
542 : pazsan 1.1 : ; ( compilation colon-sys -- ; run-time nest-sys ) \ core semicolon
543 :     ;-hook ?struc postpone exit reveal postpone [ ; immediate restrict
544 : jwilke 1.14 [THEN]
545 : pazsan 1.1
546 :     \ \ Search list handling: reveal words, recursive 23feb93py
547 :    
548 :     : last? ( -- false / nfa nfa )
549 :     last @ ?dup ;
550 :    
551 :     : (reveal) ( nt wid -- )
552 : pazsan 1.3 wordlist-id dup >r
553 : pazsan 1.1 @ over ( name>link ) !
554 :     r> ! ;
555 :    
556 :     \ make entry in wordlist-map
557 :     ' (reveal) f83search reveal-method !
558 :    
559 :     Variable warnings ( -- addr ) \ gforth
560 :     G -1 warnings T !
561 :    
562 :     : check-shadow ( addr count wid -- )
563 : pazsan 1.2 \G prints a warning if the string is already present in the wordlist
564 :     >r 2dup 2dup r> (search-wordlist) warnings @ and ?dup if
565 :     >stderr
566 :     ." redefined " name>string 2dup type
567 :     compare 0<> if
568 :     ." with " type
569 :     else
570 :     2drop
571 :     then
572 :     space space EXIT
573 :     then
574 :     2drop 2drop ;
575 : pazsan 1.1
576 :     : reveal ( -- ) \ gforth
577 :     last?
578 :     if \ the last word has a header
579 :     dup ( name>link ) @ 1 and
580 :     if \ it is still hidden
581 :     dup ( name>link ) @ 1 xor ( nt wid )
582 :     2dup >r name>string r> check-shadow ( nt wid )
583 :     dup wordlist-map @ reveal-method perform
584 :     else
585 :     drop
586 :     then
587 :     then ;
588 :    
589 :     : rehash ( wid -- )
590 :     dup wordlist-map @ rehash-method perform ;
591 :    
592 :     ' reveal alias recursive ( compilation -- ; run-time -- ) \ gforth
593 : crook 1.10 \g Make the current definition visible, enabling it to call itself
594 : pazsan 1.1 \g recursively.
595 :     immediate restrict

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help