Annotation of gforth/environ.fs, revision 1.27

1.2       anton       1: \ environmental queries
1.1       anton       2: 
1.24      anton       3: \ Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.
1.8       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.25      anton      19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.8       anton      20: 
1.3       pazsan     21: \ wordlist constant environment-wordlist
1.1       anton      22: 
1.26      anton      23: vocabulary environment ( -- ) \ gforth
                     24: \ for win32forth compatibility
                     25: 
                     26: ' environment >body constant environment-wordlist ( -- wid ) \ gforth
1.20      crook      27:   \G @i{wid} identifies the word list that is searched by environmental
1.18      crook      28:   \G queries.
1.26      anton      29: 
1.3       pazsan     30: 
1.10      anton      31: : environment? ( c-addr u -- false / ... true ) \ core environment-query
1.20      crook      32:     \G @i{c-addr, u} specify a counted string. If the string is not
                     33:     \G recognised, return a @code{false} flag. Otherwise return a
                     34:     \G @code{true} flag and some (string-specific) information about
                     35:     \G the queried string.
1.2       anton      36:     environment-wordlist search-wordlist if
                     37:        execute true
                     38:     else
                     39:        false
                     40:     endif ;
                     41: 
1.15      jwilke     42: : e? name environment? 0= ABORT" environmental dependency not existing" ;
1.13      jwilke     43: 
1.27    ! jwilke     44: : $has? environment? 0= IF false THEN ;
1.14      jwilke     45: 
1.27    ! jwilke     46: : has? name $has? ;
1.14      jwilke     47: 
1.2       anton      48: environment-wordlist set-current
                     49: get-order environment-wordlist swap 1+ set-order
                     50: 
                     51: \ assumes that chars, cells and doubles use an integral number of aus
                     52: 
                     53: \ this should be computed in C as CHAR_BITS/sizeof(char),
                     54: \ but I don't know any machine with gcc where an au does not have 8 bits.
1.7       anton      55: 8 constant ADDRESS-UNIT-BITS ( -- n ) \ environment
1.19      crook      56: \G Size of one address unit, in bits.
1.2       anton      57: 
1.18      crook      58: 1 ADDRESS-UNIT-BITS chars lshift 1- constant MAX-CHAR ( -- u ) \ environment
                     59: \G Maximum value of any character in the character set
1.1       anton      60: 
1.18      crook      61: MAX-CHAR constant /COUNTED-STRING ( -- n ) \ environment
                     62: \G Maximum size of a counted string, in characters.
1.3       pazsan     63: 
1.18      crook      64: ADDRESS-UNIT-BITS cells 2* 2 + constant /HOLD ( -- n ) \ environment
                     65: \G Size of the pictured numeric string output buffer, in characters.
                     66: 
                     67: &84 constant /PAD ( -- n ) \ environment
                     68: \G Size of the scratch area pointed to by @code{PAD}, in characters.
                     69: 
                     70: true constant CORE ( -- f ) \ environment
                     71: \G True if the complete core word set is present. Always true for Gforth.
                     72: 
                     73: true constant CORE-EXT ( -- f ) \ environment
                     74: \G True if the complete core extension word set is present. Always true for Gforth.
                     75: 
                     76: 1 -3 mod 0< constant FLOORED ( -- f ) \ environment
1.21      anton      77: \G True if @code{/} etc. perform floored division
1.18      crook      78: 
                     79: 1 ADDRESS-UNIT-BITS cells 1- lshift 1- constant MAX-N ( -- n ) \ environment
                     80: \G Largest usable signed integer.
                     81: 
                     82: -1 constant MAX-U ( -- u ) \ environment
                     83: \G Largest usable unsigned integer.
                     84: 
                     85: -1 MAX-N 2constant MAX-D ( -- d ) \ environment
                     86: \G Largest usable signed double.
                     87: 
                     88: -1. 2constant MAX-UD ( -- ud ) \ environment
                     89: \G Largest usable unsigned double.
                     90: 
                     91: version-string 2constant gforth ( -- c-addr u ) \ gforth-environment
1.22      anton      92: \G Counted string representing a version string for this version of
                     93: \G Gforth (for versions>0.3.0).  The version strings of the various
1.23      anton      94: \G versions are guaranteed to be ordered lexicographically.
1.1       anton      95: 
1.18      crook      96: : return-stack-cells ( -- n ) \ environment
                     97:     \G Maximum size of the return stack, in cells.
1.10      anton      98:     [ forthstart 6 cells + ] literal @ cell / ;
                     99: 
1.18      crook     100: : stack-cells ( -- n ) \ environment
                    101:     \G Maximum size of the data stack, in cells.
1.10      anton     102:     [ forthstart 4 cells + ] literal @ cell / ;
                    103: 
1.18      crook     104: : floating-stack ( -- n ) \ environment
1.19      crook     105:     \G @var{n} is non-zero, showing that Gforth maintains a separate
                    106:     \G floating-point stack of depth @var{n}.
1.11      pazsan    107:     [ forthstart 5 cells + ] literal @
                    108:     [IFDEF] float  float  [ELSE]  [ 1 floats ] Literal [THEN] / ;
1.10      anton     109: 
1.5       anton     110: \ !! max-float
1.6       anton     111: 15 constant #locals \ 1000 64 /
                    112:     \ One local can take up to 64 bytes, the size of locals-buffer is 1000
1.5       anton     113: maxvp constant wordlists
1.2       anton     114: 
                    115: forth definitions
                    116: previous
1.1       anton     117: 

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