File:  [gforth] / gforth / kernel / vars.fs
Revision 1.16: download - view: text, annotated - select for diffs
Wed May 5 12:04:41 1999 UTC (22 years, 3 months ago) by jwilke
Branches: MAIN
CVS tags: HEAD
cell is only defeined if it doesnt exist

    1: \ VARS.FS      Kernal variables
    2: 
    3: \ Copyright (C) 1995,1996,1997,1998 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., 675 Mass Ave, Cambridge, MA 02139, USA.
   20: 
   21: hex \ everything now hex!                               11may93jaw
   22: 
   23: \ important constants                                  17dec92py
   24: 
   25: \ dpANS6 (sect 3.1.3.1) says 
   26: \ "a true flag ... [is] a single-cell value with all bits set"
   27: \ better definition: 0 0= constant true ( no dependence on 2's compl)
   28:  -1 Constant true ( -- f ) \ core-ext
   29: \G CONSTANT: @var{f} is a cell with all bits set.
   30: \ see starts looking for primitives after this word!
   31: 
   32:   0 Constant false ( -- f ) \ core-ext
   33: \G CONSTANT: @var{f} is a cell with all bits clear.
   34: 
   35: [IFUNDEF] cell 
   36: 1 cells Constant cell ( -- u ) \ gforth
   37: [THEN]
   38: 1 floats Constant float ( -- u ) \ gforth
   39: 
   40: 20 Constant bl ( -- c-char ) \ core
   41: \G @var{c-char} is the character value for a space.
   42: \ used by docon:, must be constant
   43: 
   44: FF Constant /line
   45: 
   46: 40 Constant c/l
   47: 10 Constant l/s
   48: 400 Constant chars/block
   49: 
   50: $20 8 2* cells + 2 + cell+ constant word-pno-size ( -- u )
   51: create holdbuf word-pno-size chars allot
   52: holdbuf word-pno-size chars + aconstant holdbuf-end
   53: avariable holdptr holdbuf-end holdptr a!
   54: avariable holdend holdbuf-end holdend a!
   55: 
   56: 84 constant pad-minsize ( -- u )
   57: 
   58: 
   59: \ that's enough so long
   60: 
   61: \ User variables                                       13feb93py
   62: 
   63: \ initialized by COLD
   64: 
   65: Create main-task  has? OS [IF] 100 [ELSE] 40 [THEN] cells allot
   66: 
   67: \ set user-pointer from cross-compiler right
   68: main-task 
   69: UNLOCK tup ! LOCK
   70: 
   71: Variable udp \ user area size? -anton
   72: 
   73: AUser next-task        main-task next-task !
   74: AUser prev-task        main-task prev-task !
   75: AUser save-task        0 save-task !
   76: AUser sp0 ( -- a-addr ) \ gforth
   77: \G USER VARIABLE: Initial value of the data stack pointer.
   78: \ sp0 is used by douser:, must be user
   79:     ' sp0 Alias s0 ( -- a-addr ) \ gforth
   80: \G OBSOLETE alias of @code{sp0}
   81: 
   82: AUser rp0 ( -- a-addr ) \ gforth
   83: \G USER VARIABLE: Initial value of the return stack pointer.
   84:     ' rp0 Alias r0 ( -- a-addr ) \ gforth
   85: \G OBSOLETE alias of @code{rp0}
   86: 
   87: AUser fp0 ( -- a-addr ) \ gforth
   88: \G USER VARIABLE: Initial value of the floating-point stack pointer.
   89: \ no f0, because this leads to unexpected results when using hex
   90: 
   91: AUser lp0 ( -- a-addr ) \ gforth
   92: \G USER VARIABLE: Initial value of the locals stack pointer.
   93:     ' lp0 Alias l0 ( -- a-addr ) \ gforth
   94: \G OBSOLETE alias of @code{lp0}
   95: 
   96: AUser handler	\ pointer to last throw frame
   97: User backtrace-empty \ true if the next THROW should store a backtrace
   98: AUser backtrace-rp0 \ rp at last call of interpret
   99: \ AUser output
  100: \ AUser input
  101: 
  102: AUser errorhandler
  103: 
  104: AUser "error            0 "error !
  105: 
  106: [IFUNDEF] #tib		\ in ec-Version we may define this ourself
  107:  User tibstack		\ saves >tib in execute
  108:  User >tib		\ pointer to terminal input buffer
  109:  User #tib ( -- a-addr ) \ core-ext
  110:  \G USER VARIABLE: @var{a-addr} is the address of a cell containing
  111:  \G the number of characters in the terminal input buffer.
  112:  \G OBSOLESCENT: @code{source} superceeds the function of this word.
  113: 
  114:  User >in ( -- a-addr ) \ core
  115:  \G USER VARIABLE: @var{a-addr} is the address of a cell containing the
  116:  \G char offset from the start of the terminal input buffer to the
  117:  \G start of the parse area.
  118:                         0 >in ! \ char number currently processed in tib
  119: [THEN]
  120: has? file [IF]
  121:  User blk ( -- a-addr ) \ block
  122:  \G USER VARIABLE: @var{a-addr} is the address of a cell containing zero
  123:  \G (in which case the input source is not a block and can be identified
  124:  \G by @code{source-id}) or the number of the block currently being
  125:  \G interpreted. A Standard program should not alter @code{blk} directly.
  126: 			0 blk !
  127: 
  128:  User loadfile          0 loadfile !
  129: 
  130:  User loadfilename#	0 loadfilename# !
  131: 
  132:  User loadline          \ number of the currently interpreted
  133:                         \ (in TIB) line if the interpretation
  134:                         \ is in a textfile
  135:                         \ the first line is 1
  136: 
  137: 2User linestart         \ starting file postition of
  138:                         \ the current interpreted line (in TIB)
  139: [THEN]
  140: 
  141:  User base ( -- a-addr ) \ core
  142:  \G USER VARIABLE: @var{a-addr} is the address of a cell that stores the
  143:  \G number base used by default for number conversion during input and output.
  144:                         A base !
  145:  User dpl               -1 dpl !
  146: 
  147:  User state ( -- a-addr ) \ core,tools-ext
  148:  \G Recommended reading: @cite{@code{State}-smartness--Why it is evil
  149:  \G and how to exorcise it},
  150:  \G @url{http://www.complang.tuwien.ac.at/papers/ertl98.ps.gz}; short
  151:  \G version: Don't use @code{state}! @xref{Interpretation and
  152:  \G Compilation Semantics} for an alternative. USER VARIABLE: @var{a-addr}
  153:  \G is the address of a cell containing the compilation state flag. 0
  154:  \G => interpreting, -1 => compiling.  A program shall not directly
  155:  \G alter the value of @code{state}. The following Standard words
  156:  \G alter the value in @code{state}: @code{:} (colon) @code{;}
  157:  \G (semicolon) @code{abort} @code{quit} @code{:noname} @code{[}
  158:  \G (left-bracket) @code{]} (right-bracket) @code{;code}
  159: 			0 state !
  160: 
  161: AUser normal-dp		\ the usual dictionary pointer
  162: AUser dpp		normal-dp dpp !
  163: 			\ the pointer to the current dictionary pointer
  164:                         \ ist reset to normal-dp on (doerror)
  165:                         \  (i.e. any throw caught by quit)
  166: AUser LastCFA
  167: AUser Last
  168: 
  169: has? glocals [IF]
  170: User locals-size \ this is the current size of the locals stack
  171: 		 \ frame of the current word
  172: [THEN]
  173: 

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