Diff for /gforth/struct.fs between versions 1.1 and 1.3

version 1.1, 1994/02/11 16:30:47 version 1.3, 1995/02/23 20:17:25
Line 12 Line 12
 \     1 cells: field enum-method  \     1 cells: field enum-method
 \ end-struct ext-wordlist-map \ with the fields search-method,...,enum-method  \ end-struct ext-wordlist-map \ with the fields search-method,...,enum-method
   
 \ 2, 2constant and nalign should be somewhere else  
 : 2, ( w1 w2 -- )  
  here 2 cells allot 2! ;  
   
 : 2constant ( w1 w2 -- )  
     create 2,  
     does>  ( -- w1 w2 )  
         2@ ;  
   
 : nalign ( addr1 n -- addr2 )  : nalign ( addr1 n -- addr2 )
 \ addr2 is the aligned version of addr1 wrt the alignment size n  \ addr2 is the aligned version of addr1 wrt the alignment size n
  1- tuck +  swap invert and ;   1- tuck +  swap invert and ;
   
 : create-field ( offset1 align1 size align -- offset2 align2 )  : field ( offset1 align1 size align -- offset2 align2 )
 \ note: this version uses local variables  \ note: this version uses local variables
      create       Header reveal -7 ( [ :dostruc ] Literal ) cfa,
         >r rot r@ nalign  dup ,  ( align1 size offset )          >r rot r@ nalign  dup ,  ( align1 size offset )
         + swap r> nalign ;          + swap r> nalign ;
   
Line 36 Line 27
   
 0 1 chars end-struct struct  0 1 chars end-struct struct
   
 : field  ( offset1 align1 size align -- offset2 align2 )  \ : field  ( offset1 align1 size align -- offset2 align2 )
     create-field  \    create-field
     does> ( addr1 -- addr2 )  \    does> ( addr1 -- addr2 )
         @ + ;  \       @ + ;
   
 \ I don't really like the "type:" syntax. Any other ideas? - anton  \ I don't really like the "type:" syntax. Any other ideas? - anton
 \ Also, this seems to be somewhat general. It probably belongs to some  \ Also, this seems to be somewhat general. It probably belongs to some
Line 61 Line 52
 \     dfloats 1 dfloats ;  \     dfloats 1 dfloats ;
 \   \ 
 \ : sfloats: ( n -- size align )  \ : sfloats: ( n -- size align )
 \     sfloats 1 sfloats ;  
   
   \     sfloats 1 sfloats ;
   
   : struct-align ( size align -- )
       dp @ swap nalign dp !
       drop ;
   
   : struct-allot ( size align -- addr )
       over swap struct-align
       here swap allot ;
   
   : struct-allocate ( size align -- addr )
       drop allocate ;

Removed from v.1.1  
changed lines
  Added in v.1.3


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