Diff for /gforth/glocals.fs between versions 1.4 and 1.13

version 1.4, 1994/07/08 15:00:43 version 1.13, 1995/10/07 17:38:15
Line 61 Line 61
 \ Currently locals may only be  \ Currently locals may only be
 \ defined at the outer level and TO is not supported.  \ defined at the outer level and TO is not supported.
   
 include float.fs  
 include search-order.fs  include search-order.fs
   include float.fs
   
 : compile-@local ( n -- )  : compile-@local ( n -- ) \ new compile-fetch-local
  case   case
     0 of postpone @local0 endof      0       of postpone @local0 endof
     4 of postpone @local4 endof      1 cells of postpone @local1 endof
     8 of postpone @local8 endof      2 cells of postpone @local2 endof
    12 of postpone @local12 endof      3 cells of postpone @local3 endof
    ( otherwise ) dup postpone @local# ,     ( otherwise ) dup postpone @local# ,
  endcase ;   endcase ;
   
 : compile-f@local ( n -- )  : compile-f@local ( n -- ) \ new compile-f-fetch-local
  case   case
     0 of postpone f@local0 endof      0        of postpone f@local0 endof
     8 of postpone f@local8 endof      1 floats of postpone f@local1 endof
    ( otherwise ) dup postpone f@local# ,     ( otherwise ) dup postpone f@local# ,
  endcase ;   endcase ;
   
Line 87  include search-order.fs Line 87  include search-order.fs
 \ lp must have the strictest alignment (usually float) across calls;  \ lp must have the strictest alignment (usually float) across calls;
 \ for simplicity we align it strictly for every group.  \ for simplicity we align it strictly for every group.
   
   slowvoc @
   slowvoc on \ we want a linked list for the vocabulary locals
 vocabulary locals \ this contains the local variables  vocabulary locals \ this contains the local variables
 ' locals >body ' locals-list >body !  ' locals >body ' locals-list >body !
   slowvoc !
   
 create locals-buffer 1000 allot \ !! limited and unsafe  create locals-buffer 1000 allot \ !! limited and unsafe
     \ here the names of the local variables are stored      \ here the names of the local variables are stored
Line 131  variable locals-dp \ so here's the speci Line 134  variable locals-dp \ so here's the speci
     postpone lp@ postpone c! ;      postpone lp@ postpone c! ;
   
 : create-local ( " name" -- a-addr )  : create-local ( " name" -- a-addr )
         \ defines the local "name"; the offset of the local shall be stored in a-addr      \ defines the local "name"; the offset of the local shall be
       \ stored in a-addr
     create      create
         immediate          immediate restrict
         here 0 , ( place for the offset ) ;          here 0 , ( place for the offset ) ;
   
 : lp-offset ( n1 -- n2 )  : lp-offset ( n1 -- n2 )
Line 260  locals-types definitions Line 264  locals-types definitions
   
 : -- ( addr wid 0 ... -- )  : -- ( addr wid 0 ... -- )
     }      }
     [char] } word drop ;      [char] } parse 2drop ;
   
 forth definitions  forth definitions
   
Line 471  forth definitions Line 475  forth definitions
 : definer! ( definer xt -- )  : definer! ( definer xt -- )
     \ gives the word represented by xt the behaviour associated with definer      \ gives the word represented by xt the behaviour associated with definer
     over 1 and if      over 1 and if
         does-code!          swap [ 1 invert ] literal and does-code!
     else      else
         code-address!          code-address!
     then ;      then ;
Line 494  forth definitions Line 498  forth definitions
      OF POSTPONE laddr# >body @ lp-offset, POSTPONE d! ENDOF       OF POSTPONE laddr# >body @ lp-offset, POSTPONE d! ENDOF
      [ ' flocal >definer ] literal       [ ' flocal >definer ] literal
      OF POSTPONE laddr# >body @ lp-offset, POSTPONE f! ENDOF       OF POSTPONE laddr# >body @ lp-offset, POSTPONE f! ENDOF
      abort" can only store TO value or local value"       -&32 throw
    endcase     endcase
  else   else
    [ ' locals-wordlist >definer ] literal =     [ ' locals-wordlist >definer ] literal =
    if     if
      >body !       >body !
    else     else
      abort" can only store TO value"       -&32 throw
    endif     endif
  endif ; immediate   endif ; immediate
   
 \ : locals|  : locals|
 \ !! should lie around somewhere      BEGIN
           name 2dup s" |" compare 0<>
       WHILE
           (local)
       REPEAT
       drop 0 (local) ;  immediate restrict

Removed from v.1.4  
changed lines
  Added in v.1.13


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>