File:  [gforth] / gforth / environ.fs
Revision 1.33: download - view: text, annotated - select for diffs
Mon Dec 31 19:02:24 2007 UTC (12 years ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
updated copyright year after changing license notice

    1: \ environmental queries
    2: 
    3: \ Copyright (C) 1995,1996,1997,1998,2000,2003,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 3
   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, see http://www.gnu.org/licenses/.
   19: 
   20: \ wordlist constant environment-wordlist
   21: 
   22: vocabulary environment ( -- ) \ gforth
   23: \ for win32forth compatibility
   24: 
   25: ' environment >body constant environment-wordlist ( -- wid ) \ gforth
   26:   \G @i{wid} identifies the word list that is searched by environmental
   27:   \G queries.
   28: 
   29: 
   30: : environment? ( c-addr u -- false / ... true ) \ core environment-query
   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.
   35:     environment-wordlist search-wordlist if
   36: 	execute true
   37:     else
   38: 	false
   39:     endif ;
   40: 
   41: : e? name environment? 0= ABORT" environmental dependency not existing" ;
   42: 
   43: : $has? environment? 0= IF false THEN ;
   44: 
   45: : has? name $has? ;
   46: 
   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.
   54: 8 constant ADDRESS-UNIT-BITS ( -- n ) \ environment
   55: \G Size of one address unit, in bits.
   56: 
   57: 1 ADDRESS-UNIT-BITS chars lshift 1- constant MAX-CHAR ( -- u ) \ environment
   58: \G Maximum value of any character in the character set
   59: 
   60: MAX-CHAR constant /COUNTED-STRING ( -- n ) \ environment
   61: \G Maximum size of a counted string, in characters.
   62: 
   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
   76: \G True if @code{/} etc. perform floored division
   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
   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
   93: \G versions are guaranteed to be ordered lexicographically.
   94: 
   95: : return-stack-cells ( -- n ) \ environment
   96:     \G Maximum size of the return stack, in cells.
   97:     [ forthstart 6 cells + ] literal @ cell / ;
   98: 
   99: : stack-cells ( -- n ) \ environment
  100:     \G Maximum size of the data stack, in cells.
  101:     [ forthstart 4 cells + ] literal @ cell / ;
  102: 
  103: : floating-stack ( -- n ) \ environment
  104:     \G @var{n} is non-zero, showing that Gforth maintains a separate
  105:     \G floating-point stack of depth @var{n}.
  106:     [ forthstart 5 cells + ] literal @
  107:     [IFDEF] float  float  [ELSE]  [ 1 floats ] Literal [THEN] / ;
  108: 
  109: 15 constant #locals \ 1000 64 /
  110:     \ One local can take up to 64 bytes, the size of locals-buffer is 1000
  111: maxvp constant wordlists
  112: 
  113: forth definitions
  114: previous
  115: 

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