File:  [gforth] / gforth / struct0x.fs
Revision 1.1: download - view: text, annotated - select for diffs
Sun Jun 24 21:45:45 2007 UTC (16 years, 9 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Implemented and documented X:structures

    1: \ implementation of Forth 200x structures
    2: 
    3: \ Copyright (C) 2007 Free Software Foundation, Inc.
    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
   19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21: : +field ( n1 n2 "name" -- n3 ) \ X:structures plus-field
   22:     over if
   23:         (field) over ,
   24:     else
   25:         create dozerofield
   26:     then
   27:     + ;
   28: 
   29: : begin-structure ( "name" -- struct-sys 0 ) \ X:structures
   30:     0 value lastxt >body 0 ;
   31: 
   32: : end-structure ( struct-sys +n -- ) \ X:structures
   33:     swap ! ;
   34: 
   35: : cfield: ( u1 "name" -- u2 ) \ X:structures
   36:     1 +field ;
   37: 
   38: : field: ( u1 "name" -- u2 ) \ X:structures
   39:     aligned cell +field ;
   40: 
   41: : 2field: ( u1 "name" -- u2 ) \ gforth
   42:     aligned 2 cells +field ;
   43: 
   44: : ffield: ( u1 "name" -- u2 ) \ X:structures
   45:     faligned 1 floats +field ;
   46: 
   47: : sffield: ( u1 "name" -- u2 ) \ X:structures
   48:     sfaligned 1 sfloats +field ;
   49: 
   50: : dffield: ( u1 "name" -- u2 ) \ X:structures
   51:     dfaligned 1 dfloats +field ;

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