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