Annotation of gforth/kernel/comp.fs, revision 1.58
1.1 pazsan 1: \ compiler definitions 14sep97jaw
2:
1.54 anton 3: \ Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc.
1.6 anton 4:
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
1.29 anton 19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.6 anton 20:
1.1 pazsan 21: \ \ Revisions-Log
22:
23: \ put in seperate file 14sep97jaw
24:
25: \ \ here allot , c, A, 17dec92py
26:
1.14 jwilke 27: [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
1.1 pazsan 37: : allot ( n -- ) \ core
1.23 anton 38: \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.
1.12 anton 44: here +
45: dup 1- usable-dictionary-end forthstart within -8 and throw
46: dp ! ;
1.14 jwilke 47: [THEN]
1.1 pazsan 48:
1.22 crook 49: : c, ( c -- ) \ core c-comma
1.15 crook 50: \G Reserve data space for one char and store @i{c} in the space.
1.1 pazsan 51: here 1 chars allot c! ;
52:
1.22 crook 53: : , ( w -- ) \ core comma
1.15 crook 54: \G Reserve data space for one cell and store @i{w} in the space.
1.1 pazsan 55: here cell allot ! ;
56:
57: : 2, ( w1 w2 -- ) \ gforth
1.15 crook 58: \G Reserve data space for two cells and store the double @i{w1
1.24 anton 59: \G w2} there, @i{w2} first (lower address).
1.1 pazsan 60: here 2 cells allot 2! ;
61:
62: \ : aligned ( addr -- addr' ) \ core
63: \ [ cell 1- ] Literal + [ -1 cells ] Literal and ;
64:
65: : align ( -- ) \ core
1.15 crook 66: \G If the data-space pointer is not aligned, reserve enough space to align it.
1.1 pazsan 67: here dup aligned swap ?DO bl c, LOOP ;
68:
1.22 crook 69: \ : faligned ( addr -- f-addr ) \ float f-aligned
1.1 pazsan 70: \ [ 1 floats 1- ] Literal + [ -1 floats ] Literal and ;
71:
1.22 crook 72: : falign ( -- ) \ float f-align
1.15 crook 73: \G If the data-space pointer is not float-aligned, reserve
74: \G enough space to align it.
1.1 pazsan 75: here dup faligned swap
76: ?DO
77: bl c,
78: LOOP ;
79:
1.9 anton 80: : maxalign ( -- ) \ gforth
1.23 anton 81: \G Align data-space pointer for all alignment requirements.
1.1 pazsan 82: 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
1.24 anton 89: \G Align data-space pointer for code field requirements (i.e., such
90: \G that the corresponding body is maxaligned).
1.1 pazsan 91:
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:
1.30 anton 110: : longstring, ( c-addr u -- ) \ gforth
1.55 anton 111: \G puts down string as longcstring
1.30 anton 112: dup , here swap chars dup allot move ;
113:
1.1 pazsan 114: : header, ( c-addr u -- ) \ gforth
115: name-too-long?
1.53 anton 116: dup max-name-length @ max max-name-length !
1.1 pazsan 117: align here last !
118: current @ 1 or A, \ link field; before revealing, it contains the
119: \ tagged reveal-into wordlist
1.30 anton 120: longstring, cfalign
1.1 pazsan 121: alias-mask lastflags cset ;
122:
123: : input-stream-header ( "name" -- )
124: name name-too-short? header, ;
125:
126: : input-stream ( -- ) \ general
127: \G switches back to getting the name from the input stream ;
128: ['] input-stream-header IS (header) ;
129:
130: ' input-stream-header IS (header)
131:
1.32 anton 132: 2variable nextname-string
1.1 pazsan 133:
1.33 pazsan 134: has? OS [IF]
1.1 pazsan 135: : nextname-header ( -- )
1.32 anton 136: nextname-string 2@ header,
137: nextname-string free-mem-var
1.1 pazsan 138: input-stream ;
1.33 pazsan 139: [THEN]
1.1 pazsan 140:
141: \ the next name is given in the string
142:
1.33 pazsan 143: has? OS [IF]
1.1 pazsan 144: : nextname ( c-addr u -- ) \ gforth
1.19 anton 145: \g The next defined word will have the name @var{c-addr u}; the
146: \g defining word will leave the input stream alone.
1.1 pazsan 147: name-too-long?
1.32 anton 148: nextname-string free-mem-var
149: save-mem nextname-string 2!
1.1 pazsan 150: ['] nextname-header IS (header) ;
1.33 pazsan 151: [THEN]
1.1 pazsan 152:
153: : noname-header ( -- )
154: 0 last ! cfalign
155: input-stream ;
156:
157: : noname ( -- ) \ gforth
1.19 anton 158: \g The next defined word will be anonymous. The defining word will
159: \g leave the input stream alone. The xt of the defined word will
1.56 anton 160: \g be given by @code{latestxt}.
1.1 pazsan 161: ['] noname-header IS (header) ;
162:
1.56 anton 163: : latestxt ( -- xt ) \ gforth
1.15 crook 164: \G @i{xt} is the execution token of the last word defined.
1.13 crook 165: \ The main purpose of this word is to get the xt of words defined using noname
1.1 pazsan 166: lastcfa @ ;
167:
1.56 anton 168: ' latestxt alias lastxt \ gforth-obsolete
169: \G old name for @code{latestxt}.
170:
171: : latest ( -- nt ) \ gforth
172: \G @var{nt} is the name token of the last word defined; it is 0 if the
173: \G last word has no name.
174: last @ ;
175:
1.1 pazsan 176: \ \ literals 17dec92py
177:
178: : Literal ( compilation n -- ; run-time -- n ) \ core
1.27 anton 179: \G Compilation semantics: compile the run-time semantics.@*
180: \G Run-time Semantics: push @i{n}.@*
181: \G Interpretation semantics: undefined.
1.14 jwilke 182: [ [IFDEF] lit, ]
183: lit,
184: [ [ELSE] ]
1.27 anton 185: postpone lit ,
1.14 jwilke 186: [ [THEN] ] ; immediate restrict
1.1 pazsan 187:
188: : ALiteral ( compilation addr -- ; run-time -- addr ) \ gforth
1.14 jwilke 189: [ [IFDEF] alit, ]
190: alit,
191: [ [ELSE] ]
192: postpone lit A,
193: [ [THEN] ] ; immediate restrict
1.1 pazsan 194:
1.8 crook 195: : char ( '<spaces>ccc' -- c ) \ core
1.15 crook 196: \G Skip leading spaces. Parse the string @i{ccc} and return @i{c}, the
197: \G display code representing the first character of @i{ccc}.
1.1 pazsan 198: bl word char+ c@ ;
199:
1.8 crook 200: : [char] ( compilation '<spaces>ccc' -- ; run-time -- c ) \ core bracket-char
1.10 crook 201: \G Compilation: skip leading spaces. Parse the string
1.15 crook 202: \G @i{ccc}. Run-time: return @i{c}, the display code
203: \G representing the first character of @i{ccc}. Interpretation
1.10 crook 204: \G semantics for this word are undefined.
1.1 pazsan 205: char postpone Literal ; immediate restrict
206:
207: \ \ threading 17mar93py
208:
209: : cfa, ( code-address -- ) \ gforth cfa-comma
210: here
211: dup lastcfa !
212: 0 A, 0 , code-address! ;
213:
1.14 jwilke 214: [IFUNDEF] compile,
1.34 anton 215: defer compile, ( xt -- ) \ core-ext compile-comma
216: \G Compile the word represented by the execution token @i{xt}
217: \G into the current definition.
218:
219: ' , is compile,
1.14 jwilke 220: [THEN]
1.1 pazsan 221:
1.40 anton 222: defer basic-block-end ( -- )
223:
1.48 anton 224: :noname ( -- )
1.58 ! anton 225: ;
1.48 anton 226: is basic-block-end
1.40 anton 227:
1.36 pazsan 228: has? peephole [IF]
1.40 anton 229:
230: \ dynamic only
1.49 anton 231: : peephole-compile, ( xt -- )
232: \ compile xt, appending its code to the current dynamic superinstruction
233: here swap , compile-prim1 ;
1.38 anton 234:
1.35 anton 235: : compile-to-prims, ( xt -- )
236: \G compile xt to use primitives (and their peephole optimization)
237: \G instead of ","-ing the xt.
238: \ !! all POSTPONEs here postpone primitives; this can be optimized
1.39 pazsan 239: dup >does-code if
240: POSTPONE does-exec , EXIT
1.41 anton 241: \ dup >body POSTPONE literal POSTPONE call >does-code , EXIT
1.35 anton 242: then
243: dup >code-address CASE
1.47 anton 244: docon: OF >body POSTPONE lit@ , EXIT ENDOF
245: \ docon: OF >body POSTPONE literal POSTPONE @ EXIT ENDOF
1.42 anton 246: \ docon is also used by VALUEs, so don't @ at compile time
1.35 anton 247: docol: OF >body POSTPONE call , EXIT ENDOF
248: dovar: OF >body POSTPONE literal EXIT ENDOF
249: douser: OF >body @ POSTPONE useraddr , EXIT ENDOF
1.42 anton 250: dodefer: OF >body POSTPONE lit-perform , EXIT ENDOF
1.47 anton 251: dofield: OF >body @ POSTPONE lit+ , EXIT ENDOF
252: \ dofield: OF >body @ POSTPONE literal POSTPONE + EXIT ENDOF
1.48 anton 253: \ code words and ;code-defined words (code words could be optimized):
254: dup in-dictionary? IF drop POSTPONE literal POSTPONE execute EXIT THEN
1.35 anton 255: ENDCASE
1.49 anton 256: peephole-compile, ;
1.35 anton 257:
258: ' compile-to-prims, IS compile,
1.36 pazsan 259: [ELSE]
260: ' , is compile,
261: [THEN]
1.34 anton 262:
1.1 pazsan 263: : !does ( addr -- ) \ gforth store-does
1.56 anton 264: latestxt does-code! ;
1.1 pazsan 265:
266: : (does>) ( R: addr -- )
267: r> cfaligned /does-handler + !does ;
268:
269: : dodoes, ( -- )
270: cfalign here /does-handler allot does-handler! ;
271:
272: : (compile) ( -- ) \ gforth
273: r> dup cell+ >r @ compile, ;
274:
275: \ \ ticks
276:
277: : name>comp ( nt -- w xt ) \ gforth
1.15 crook 278: \G @i{w xt} is the compilation token for the word @i{nt}.
1.1 pazsan 279: (name>comp)
280: 1 = if
281: ['] execute
282: else
283: ['] compile,
284: then ;
285:
286: : [(')] ( compilation "name" -- ; run-time -- nt ) \ gforth bracket-paren-tick
287: (') postpone ALiteral ; immediate restrict
288:
289: : ['] ( compilation. "name" -- ; run-time. -- xt ) \ core bracket-tick
1.15 crook 290: \g @i{xt} represents @i{name}'s interpretation
291: \g semantics. Perform @code{-14 throw} if the word has no
1.1 pazsan 292: \g interpretation semantics.
293: ' postpone ALiteral ; immediate restrict
294:
1.5 anton 295: : COMP' ( "name" -- w xt ) \ gforth comp-tick
1.15 crook 296: \g Compilation token @i{w xt} represents @i{name}'s compilation semantics.
1.1 pazsan 297: (') name>comp ;
298:
299: : [COMP'] ( compilation "name" -- ; run-time -- w xt ) \ gforth bracket-comp-tick
1.15 crook 300: \g Compilation token @i{w xt} represents @i{name}'s compilation semantics.
1.1 pazsan 301: COMP' swap POSTPONE Aliteral POSTPONE ALiteral ; immediate restrict
302:
1.18 jwilke 303: : postpone, ( w xt -- ) \ gforth postpone-comma
1.26 anton 304: \g Compile the compilation semantics represented by the
305: \g compilation token @i{w xt}.
1.18 jwilke 306: dup ['] execute =
307: if
308: drop compile,
309: else
310: dup ['] compile, =
311: if
312: drop POSTPONE (compile) a,
313: else
314: swap POSTPONE aliteral compile,
315: then
316: then ;
317:
318: : POSTPONE ( "name" -- ) \ core
319: \g Compiles the compilation semantics of @i{name}.
1.48 anton 320: COMP' postpone, ; immediate
1.18 jwilke 321:
1.1 pazsan 322: \ \ recurse 17may93jaw
323:
324: : recurse ( compilation -- ; run-time ?? -- ?? ) \ core
1.10 crook 325: \g Call the current definition.
1.56 anton 326: latestxt compile, ; immediate restrict
1.1 pazsan 327:
328: \ \ compiler loop
329:
330: : compiler ( c-addr u -- )
331: 2dup find-name dup
332: if ( c-addr u nt )
333: nip nip name>comp execute
334: else
335: drop
336: 2dup snumber? dup
337: IF
338: 0>
339: IF
340: swap postpone Literal
341: THEN
342: postpone Literal
343: 2drop
344: ELSE
345: drop compiler-notfound
346: THEN
347: then ;
348:
1.22 crook 349: : [ ( -- ) \ core left-bracket
1.8 crook 350: \G Enter interpretation state. Immediate word.
1.1 pazsan 351: ['] interpreter IS parser state off ; immediate
352:
353: : ] ( -- ) \ core right-bracket
1.8 crook 354: \G Enter compilation state.
1.1 pazsan 355: ['] compiler IS parser state on ;
356:
357: \ \ Strings 22feb93py
358:
1.44 anton 359: : S, ( addr u -- )
1.45 anton 360: \ allot string as counted string
1.44 anton 361: here over char+ allot place align ;
1.45 anton 362:
363: : mem, ( addr u -- )
364: \ allot the memory block HERE (do alignment yourself)
365: here over allot swap move ;
1.1 pazsan 366:
1.44 anton 367: : ," ( "string"<"> -- )
368: [char] " parse s, ;
1.1 pazsan 369:
370: \ \ Header states 23feb93py
371:
372: : cset ( bmask c-addr -- )
1.30 anton 373: tuck @ or swap ! ;
1.1 pazsan 374:
375: : creset ( bmask c-addr -- )
1.30 anton 376: tuck @ swap invert and swap ! ;
1.1 pazsan 377:
378: : ctoggle ( bmask c-addr -- )
1.30 anton 379: tuck @ xor swap ! ;
1.1 pazsan 380:
381: : lastflags ( -- c-addr )
382: \ the address of the flags byte in the last header
383: \ aborts if the last defined word was headerless
1.56 anton 384: latest dup 0= abort" last word was headerless" cell+ ;
1.1 pazsan 385:
386: : immediate ( -- ) \ core
1.10 crook 387: \G Make the compilation semantics of a word be to @code{execute}
388: \G the execution semantics.
1.1 pazsan 389: immediate-mask lastflags cset ;
390:
391: : restrict ( -- ) \ gforth
1.10 crook 392: \G A synonym for @code{compile-only}
1.1 pazsan 393: restrict-mask lastflags cset ;
1.18 jwilke 394:
1.1 pazsan 395: ' restrict alias compile-only ( -- ) \ gforth
1.10 crook 396: \G Remove the interpretation semantics of a word.
1.1 pazsan 397:
398: \ \ Create Variable User Constant 17mar93py
399:
1.15 crook 400: : Alias ( xt "name" -- ) \ gforth
1.1 pazsan 401: Header reveal
402: alias-mask lastflags creset
403: dup A, lastcfa ! ;
404:
405: doer? :dovar [IF]
406:
407: : Create ( "name" -- ) \ core
408: Header reveal dovar: cfa, ;
409: [ELSE]
410:
411: : Create ( "name" -- ) \ core
412: Header reveal here lastcfa ! 0 A, 0 , DOES> ;
413: [THEN]
414:
415: : Variable ( "name" -- ) \ core
416: Create 0 , ;
417:
418: : AVariable ( "name" -- ) \ gforth
419: Create 0 A, ;
420:
1.22 crook 421: : 2Variable ( "name" -- ) \ double two-variable
1.1 pazsan 422: create 0 , 0 , ;
423:
1.21 crook 424: : uallot ( n -- ) \ gforth
425: udp @ swap udp +! ;
1.1 pazsan 426:
427: doer? :douser [IF]
428:
429: : User ( "name" -- ) \ gforth
430: Header reveal douser: cfa, cell uallot , ;
431:
432: : AUser ( "name" -- ) \ gforth
433: User ;
434: [ELSE]
435:
436: : User Create cell uallot , DOES> @ up @ + ;
437:
438: : AUser User ;
439: [THEN]
440:
441: doer? :docon [IF]
442: : (Constant) Header reveal docon: cfa, ;
443: [ELSE]
444: : (Constant) Create DOES> @ ;
445: [THEN]
446:
447: : Constant ( w "name" -- ) \ core
1.15 crook 448: \G Define a constant @i{name} with value @i{w}.
1.1 pazsan 449: \G
1.15 crook 450: \G @i{name} execution: @i{-- w}
1.1 pazsan 451: (Constant) , ;
452:
453: : AConstant ( addr "name" -- ) \ gforth
454: (Constant) A, ;
455:
456: : Value ( w "name" -- ) \ core-ext
457: (Constant) , ;
458:
1.37 jwilke 459: : AValue ( w "name" -- ) \ core-ext
460: (Constant) A, ;
461:
1.22 crook 462: : 2Constant ( w1 w2 "name" -- ) \ double two-constant
1.1 pazsan 463: Create ( w1 w2 "name" -- )
464: 2,
465: DOES> ( -- w1 w2 )
466: 2@ ;
467:
468: doer? :dofield [IF]
469: : (Field) Header reveal dofield: cfa, ;
470: [ELSE]
471: : (Field) Create DOES> @ + ;
472: [THEN]
1.39 pazsan 473:
474: \ \ interpret/compile:
475:
476: struct
477: >body
478: cell% field interpret/compile-int
479: cell% field interpret/compile-comp
480: end-struct interpret/compile-struct
481:
482: : interpret/compile: ( interp-xt comp-xt "name" -- ) \ gforth
483: Create immediate swap A, A,
484: DOES>
485: abort" executed primary cfa of an interpret/compile: word" ;
486: \ state @ IF cell+ THEN perform ;
487:
1.1 pazsan 488: \ IS Defer What's Defers TO 24feb93py
489:
490: doer? :dodefer [IF]
491:
492: : Defer ( "name" -- ) \ gforth
493: \ !! shouldn't it be initialized with abort or something similar?
494: Header Reveal dodefer: cfa,
495: ['] noop A, ;
1.18 jwilke 496:
1.1 pazsan 497: [ELSE]
498:
499: : Defer ( "name" -- ) \ gforth
500: Create ['] noop A,
501: DOES> @ execute ;
1.18 jwilke 502:
1.1 pazsan 503: [THEN]
504:
1.25 anton 505: : Defers ( compilation "name" -- ; run-time ... -- ... ) \ gforth
506: \G Compiles the present contents of the deferred word @i{name}
507: \G into the current definition. I.e., this produces static
508: \G binding as if @i{name} was not deferred.
1.1 pazsan 509: ' >body @ compile, ; immediate
1.18 jwilke 510:
511: :noname
512: dodoes, here !does ]
513: defstart :-hook ;
514: :noname
515: ;-hook ?struc
516: [ has? xconds [IF] ] exit-like [ [THEN] ]
517: postpone (does>) dodoes,
518: defstart :-hook ;
519: interpret/compile: DOES> ( compilation colon-sys1 -- colon-sys2 ; run-time nest-sys -- ) \ core does
520:
1.20 anton 521: : <IS> ( "name" xt -- ) \ gforth
522: \g Changes the @code{defer}red word @var{name} to execute @var{xt}.
523: ' >body ! ;
524:
525: : [IS] ( compilation "name" -- ; run-time xt -- ) \ gforth bracket-is
526: \g At run-time, changes the @code{defer}red word @var{name} to
527: \g execute @var{xt}.
1.18 jwilke 528: ' >body postpone ALiteral postpone ! ; immediate restrict
529:
1.20 anton 530: ' <IS>
1.18 jwilke 531: ' [IS]
532: interpret/compile: IS ( xt "name" -- ) \ gforth
1.21 crook 533: \G A combined word made up from @code{<IS>} and @code{[IS]}.
1.18 jwilke 534:
1.20 anton 535: ' <IS>
536: ' [IS]
537: interpret/compile: TO ( w "name" -- ) \ core-ext
1.18 jwilke 538:
539: :noname ' >body @ ;
540: :noname ' >body postpone ALiteral postpone @ ;
1.25 anton 541: interpret/compile: What's ( interpretation "name" -- xt; compilation "name" -- ; run-time -- xt ) \ gforth
542: \G @i{Xt} is the XT that is currently assigned to @i{name}.
1.18 jwilke 543:
544: : interpret/compile? ( xt -- flag )
545: >does-code ['] DOES> >does-code = ;
1.1 pazsan 546:
547: \ \ : ; 24feb93py
548:
549: defer :-hook ( sys1 -- sys2 )
550:
551: defer ;-hook ( sys2 -- sys1 )
552:
1.16 jwilke 553: 0 Constant defstart
554:
1.14 jwilke 555: [IFDEF] docol,
556: : (:noname) ( -- colon-sys )
557: \ common factor of : and :noname
1.34 anton 558: docol, ]comp
1.14 jwilke 559: [ELSE]
1.7 anton 560: : (:noname) ( -- colon-sys )
561: \ common factor of : and :noname
1.34 anton 562: docol: cfa,
1.14 jwilke 563: [THEN]
1.40 anton 564: defstart ] :-hook ;
1.7 anton 565:
1.1 pazsan 566: : : ( "name" -- colon-sys ) \ core colon
1.7 anton 567: Header (:noname) ;
568:
569: : :noname ( -- xt colon-sys ) \ core-ext colon-no-name
570: 0 last !
571: cfalign here (:noname) ;
1.1 pazsan 572:
1.14 jwilke 573: [IFDEF] fini,
574: : ; ( compilation colon-sys -- ; run-time nest-sys ) \ core semicolon
575: ;-hook ?struc fini, comp[ reveal postpone [ ; immediate restrict
576: [ELSE]
1.1 pazsan 577: : ; ( compilation colon-sys -- ; run-time nest-sys ) \ core semicolon
1.57 pazsan 578: ;-hook ?struc [compile] exit
579: [ has? peephole [IF] ] finish-code [ [THEN] ]
580: reveal postpone [ ; immediate restrict
1.14 jwilke 581: [THEN]
1.1 pazsan 582:
583: \ \ Search list handling: reveal words, recursive 23feb93py
584:
585: : last? ( -- false / nfa nfa )
1.56 anton 586: latest ?dup ;
1.1 pazsan 587:
588: : (reveal) ( nt wid -- )
1.3 pazsan 589: wordlist-id dup >r
1.1 pazsan 590: @ over ( name>link ) !
591: r> ! ;
592:
593: \ make entry in wordlist-map
594: ' (reveal) f83search reveal-method !
595:
596: Variable warnings ( -- addr ) \ gforth
597: G -1 warnings T !
598:
599: : check-shadow ( addr count wid -- )
1.2 pazsan 600: \G prints a warning if the string is already present in the wordlist
601: >r 2dup 2dup r> (search-wordlist) warnings @ and ?dup if
602: >stderr
603: ." redefined " name>string 2dup type
1.43 anton 604: str= 0= if
1.2 pazsan 605: ." with " type
606: else
607: 2drop
608: then
609: space space EXIT
610: then
611: 2drop 2drop ;
1.1 pazsan 612:
613: : reveal ( -- ) \ gforth
614: last?
615: if \ the last word has a header
616: dup ( name>link ) @ 1 and
617: if \ it is still hidden
618: dup ( name>link ) @ 1 xor ( nt wid )
619: 2dup >r name>string r> check-shadow ( nt wid )
620: dup wordlist-map @ reveal-method perform
621: else
622: drop
623: then
624: then ;
625:
626: : rehash ( wid -- )
627: dup wordlist-map @ rehash-method perform ;
628:
629: ' reveal alias recursive ( compilation -- ; run-time -- ) \ gforth
1.10 crook 630: \g Make the current definition visible, enabling it to call itself
1.1 pazsan 631: \g recursively.
632: immediate restrict
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>