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