Diff for /gforth/struct.fs between versions 1.14 and 1.15

version 1.14, 1999/02/22 21:39:42 version 1.15, 1999/03/23 20:24:20
Line 19 Line 19
 \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   
 : naligned ( addr1 n -- addr2 ) \ gforth  : naligned ( addr1 n -- addr2 ) \ gforth
 \g @code{addr2} is the aligned version of @code{addr1} wrt the  \g @var{addr2} is the aligned version of @var{addr1} with respect to the
 \g alignment @code{n}.  \g alignment @var{n}.
  1- tuck +  swap invert and ;   1- tuck +  swap invert and ;
   
 ' naligned alias nalign \ old name, obsolete  ' naligned alias nalign \ old name, obsolete
Line 44  does> ( name execution: -- ) Line 44  does> ( name execution: -- )
     create field, ;      create field, ;
   
 : field ( align1 offset1 align size "name" --  align2 offset2 ) \ gforth  : field ( align1 offset1 align size "name" --  align2 offset2 ) \ gforth
     \G name execution: ( addr1 -- addr2 )      \G @code{name} execution: @var{addr1} -- @var{addr2}.
     2 pick       2 pick 
     if \ field offset <> 0      if \ field offset <> 0
         [IFDEF]  (Field)          [IFDEF]  (Field)
Line 58  does> ( name execution: -- ) Line 58  does> ( name execution: -- )
     field, ;      field, ;
   
 : end-struct ( align size "name" -- ) \ gforth  : end-struct ( align size "name" -- ) \ gforth
 \g @code{name} execution: @code{addr1 -- addr1+offset1}@*  \g @code{name} execution: @var{addr1} -- @var{addr1+offset1}@*
 \g create a field @code{name} with offset @code{offset1}, and the type  \g Create a field @var{name} with offset @var{offset1}, and the type
 \g given by @code{size align}. @code{offset2} is the offset of the  \g given by @var{size align}. @var{offset2} is the offset of the
 \g next field, and @code{align2} is the alignment of all fields.  \g next field, and @var{align2} is the alignment of all fields.
     over nalign \ pad size to full alignment      over nalign \ pad size to full alignment
     2constant ;      2constant ;
   
 1 chars 0 end-struct struct ( -- align size ) \ gforth  1 chars 0 end-struct struct ( -- align size ) \ gforth
 \g an empty structure, used to start a structure definition.  \g An empty structure, used to start a structure definition.
   
 \ type descriptors  \ type descriptors
 1 aligned   1 cells   2constant cell% ( -- align size ) \ gforth  1 aligned   1 cells   2constant cell% ( -- align size ) \ gforth
Line 78  cell% 2*              2constant double% Line 78  cell% 2*              2constant double%
   
 \ memory allocation words  \ memory allocation words
 ' drop alias %alignment ( align size -- align ) \ gforth  ' drop alias %alignment ( align size -- align ) \ gforth
 \g the alignment of the structure  \g The alignment of the structure.
 ' nip alias %size ( align size -- size ) \ gforth  ' nip alias %size ( align size -- size ) \ gforth
 \g the size of the structure  \g The size of the structure.
   
 : %align ( align size -- ) \ gforth  : %align ( align size -- ) \ gforth
     \G align the data space pointer to the alignment @code{align}.       \G Align the data space pointer to the alignment @var{align}. 
     drop here swap nalign here - allot ;      drop here swap nalign here - allot ;
   
 : %allot ( align size -- addr ) \ gforth  : %allot ( align size -- addr ) \ gforth
     \g allot @code{size} address units of data space with alignment      \g Allot @var{size} address units of data space with alignment
     \g @code{align}; the resulting block of data is found at      \g @var{align}; the resulting block of data is found at
     \g @code{addr}.      \g @var{addr}.
     tuck %align      tuck %align
     here swap allot ;      here swap allot ;
   
 : %allocate ( align size -- addr ior ) \ gforth  : %allocate ( align size -- addr ior ) \ gforth
     \g allocate @code{size} address units with alignment @code{align},      \g Allocate @var{size} address units with alignment @var{align},
     \g similar to @code{allocate}.      \g similar to @code{allocate}.
     nip allocate ;      nip allocate ;
   
 : %alloc ( size align -- addr ) \ gforth  : %alloc ( size align -- addr ) \ gforth
     \g allocate @code{size} address units with alignment @code{align},      \g Allocate @var{size} address units with alignment @var{align},
     \g giving a data block at @code{addr}; @code{throw}s an ior code      \g giving a data block at @var{addr}; @code{throw} an ior code
     \g if not successful.      \g if not successful.
     %allocate throw ;      %allocate throw ;

Removed from v.1.14  
changed lines
  Added in v.1.15


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