Annotation of gforth/kernel/vars.fs, revision 1.42

1.1       anton       1: \ VARS.FS      Kernal variables
                      2: 
1.34      anton       3: \ Copyright (C) 1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc.
1.1       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.24      anton      19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.1       anton      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)
1.10      crook      28:  -1 Constant true ( -- f ) \ core-ext
1.19      crook      29: \G @code{Constant} -- @i{f} is a cell with all bits set.
1.10      crook      30: \ see starts looking for primitives after this word!
                     31: 
                     32:   0 Constant false ( -- f ) \ core-ext
1.19      crook      33: \G @code{Constant} -- @i{f} is a cell with all bits clear.
1.1       anton      34: 
1.16      jwilke     35: [IFUNDEF] cell 
1.1       anton      36: 1 cells Constant cell ( -- u ) \ gforth
1.22      anton      37: \G @code{Constant} -- @code{1 cells}
1.16      jwilke     38: [THEN]
1.17      crook      39: 
1.25      pazsan     40: has? floating [IF]
1.1       anton      41: 1 floats Constant float ( -- u ) \ gforth
1.19      crook      42: \G @code{Constant} -- the number of address units corresponding to a floating-point number.
1.25      pazsan     43: [THEN]
1.1       anton      44: 
1.20      crook      45: 20 Constant bl ( -- c-char ) \ core b-l
1.17      crook      46: \G @i{c-char} is the character value for a space.
1.10      crook      47: \ used by docon:, must be constant
1.1       anton      48: 
1.42    ! pazsan     49: has? EC [IF] 40 [ELSE] FF [THEN] Constant /line
1.1       anton      50: 
1.39      pazsan     51: has? file [IF]
1.1       anton      52: 40 Constant c/l
                     53: 10 Constant l/s
                     54: 400 Constant chars/block
1.38      pazsan     55: [THEN]
1.1       anton      56: 
1.18      jwilke     57: 20 8 2* cells + 2 + cell+ constant word-pno-size ( -- u )
1.40      pazsan     58: 
                     59: has? EC 0= [IF]
1.11      anton      60: create holdbuf word-pno-size chars allot
                     61: holdbuf word-pno-size chars + aconstant holdbuf-end
                     62: avariable holdptr holdbuf-end holdptr a!
1.12      anton      63: avariable holdend holdbuf-end holdend a!
1.40      pazsan     64: [THEN]
1.11      anton      65: 
1.2       anton      66: 84 constant pad-minsize ( -- u )
1.11      anton      67: 
1.25      pazsan     68: $400 Value def#tib
                     69: \G default size of terminal input buffer. Default size is 1K
1.2       anton      70: 
1.1       anton      71: \ that's enough so long
                     72: 
                     73: \ User variables                                       13feb93py
                     74: 
                     75: \ initialized by COLD
                     76: 
1.38      pazsan     77: has? no-userspace 0= [IF]
1.35      jwilke     78: Create main-task  has? OS [IF] 100 [ELSE] 40 [THEN] cells dup allot
1.3       jwilke     79: 
                     80: \ set user-pointer from cross-compiler right
                     81: main-task 
1.35      jwilke     82: UNLOCK swap region user-region user-region setup-region LOCK
1.1       anton      83: 
1.19      crook      84: Variable udp ( -- a-addr ) \ gforth
1.28      pazsan     85: \G user area size
1.1       anton      86: 
                     87: AUser next-task        main-task next-task !
                     88: AUser prev-task        main-task prev-task !
                     89: AUser save-task        0 save-task !
1.38      pazsan     90: [THEN]
1.10      crook      91: AUser sp0 ( -- a-addr ) \ gforth
1.19      crook      92: \G @code{User} variable -- initial value of the data stack pointer.
1.10      crook      93: \ sp0 is used by douser:, must be user
1.38      pazsan     94: \    ' sp0 Alias s0 ( -- a-addr ) \ gforth
1.10      crook      95: \G OBSOLETE alias of @code{sp0}
                     96: 
                     97: AUser rp0 ( -- a-addr ) \ gforth
1.19      crook      98: \G @code{User} variable -- initial value of the return stack pointer.
1.38      pazsan     99: \    ' rp0 Alias r0 ( -- a-addr ) \ gforth
1.10      crook     100: \G OBSOLETE alias of @code{rp0}
                    101: 
1.25      pazsan    102: has? floating [IF]
1.10      crook     103: AUser fp0 ( -- a-addr ) \ gforth
1.19      crook     104: \G @code{User} variable -- initial value of the floating-point stack pointer.
1.10      crook     105: \ no f0, because this leads to unexpected results when using hex
1.25      pazsan    106: [THEN]
1.10      crook     107: 
1.25      pazsan    108: has? glocals [IF]
1.10      crook     109: AUser lp0 ( -- a-addr ) \ gforth
1.19      crook     110: \G @code{User} variable -- initial value of the locals stack pointer.
1.38      pazsan    111: \    ' lp0 Alias l0 ( -- a-addr ) \ gforth
1.10      crook     112: \G OBSOLETE alias of @code{lp0}
1.25      pazsan    113: [THEN]
1.10      crook     114: 
1.3       jwilke    115: AUser handler  \ pointer to last throw frame
1.18      jwilke    116: has? backtrace [IF]
1.13      anton     117: User backtrace-empty \ true if the next THROW should store a backtrace
                    118: AUser backtrace-rp0 \ rp at last call of interpret
1.18      jwilke    119: [THEN]
1.1       anton     120: \ AUser output
                    121: \ AUser input
                    122: 
                    123: AUser errorhandler
                    124: 
                    125: AUser "error            0 "error !
                    126: 
1.25      pazsan    127: has? new-input [IF]
                    128:     User current-input
                    129: [ELSE]
                    130:     [IFUNDEF] #tib             \ in ec-Version we may define this ourself
                    131:        User tibstack           \ saves >tib in execute
                    132:        User >tib               \ pointer to terminal input buffer
                    133:        User #tib ( -- a-addr ) \ core-ext number-t-i-b
                    134:        \G @code{User} variable -- @i{a-addr} is the address of a cell containing
                    135:        \G the number of characters in the terminal input buffer.
                    136:        \G OBSOLESCENT: @code{source} superceeds the function of this word.
                    137:        
                    138:        User >in ( -- a-addr ) \ core to-in
                    139:        \G @code{User} variable -- @i{a-addr} is the address of a cell containing the
                    140:        \G char offset from the start of the input buffer to the start of the
                    141:        \G parse area.
                    142:        0 >in ! \ char number currently processed in tib
                    143:     [THEN]
                    144: 
1.7       pazsan    145: has? file [IF]
1.20      crook     146:  User blk ( -- a-addr ) \ block b-l-k
1.19      crook     147:  \G @code{User} variable -- @i{a-addr} is the address of a cell containing zero
1.10      crook     148:  \G (in which case the input source is not a block and can be identified
                    149:  \G by @code{source-id}) or the number of the block currently being
                    150:  \G interpreted. A Standard program should not alter @code{blk} directly.
                    151:                        0 blk !
                    152: 
1.1       anton     153:  User loadfile          0 loadfile !
                    154: 
1.32      anton     155:  2user loadfilename    0 0 loadfilename 2! \ addr u for sourcefilename
1.37      anton     156:      
1.1       anton     157:  User loadline          \ number of the currently interpreted
                    158:                         \ (in TIB) line if the interpretation
                    159:                         \ is in a textfile
                    160:                         \ the first line is 1
                    161: 
                    162: 2User linestart         \ starting file postition of
                    163:                         \ the current interpreted line (in TIB)
1.25      pazsan    164: [THEN]
1.7       pazsan    165: [THEN]
1.37      anton     166: 
                    167:  2user includefilename  0 0 includefilename 2! \ innermost included file
                    168: 
1.1       anton     169: 
1.26      anton     170: User base ( -- a-addr ) \ core
                    171: \G @code{User} variable -- @i{a-addr} is the address of a cell that stores the
                    172: \G number base used by default for number conversion during input and output.
                    173:                        A base !
                    174: User dpl ( -- a-addr ) \ gforth
                    175: \G @code{User} variable -- @i{a-addr} is the address of a cell that stores the                 
                    176: \G position of the decimal point in the most recent numeric conversion.
                    177: \G Initialised to -1. After the conversion of a number containing no
1.36      anton     178: \G decimal point, @code{dpl} is -1. After the conversion of @code{2.} it holds
1.26      anton     179: \G 0. After the conversion of 234123.9 it contains 1, and so forth.
                    180: -1 dpl !
1.1       anton     181: 
1.26      anton     182: User state ( -- a-addr ) \ core,tools-ext
                    183: \G @code{User} variable -- @i{a-addr} is the address of a cell
                    184: \G containing the compilation state flag. 0 => interpreting, -1 =>
                    185: \G compiling.  A program shall not directly alter the value of
                    186: \G @code{state}. The following Standard words alter the value in
                    187: \G @code{state}: @code{:} (colon) @code{;} (semicolon) @code{abort}
                    188: \G @code{quit} @code{:noname} @code{[} (left-bracket) @code{]}
                    189: \G (right-bracket) @code{;code}. Don't use @code{state}! For an
                    190: \G alternative see @ref{Interpretation and Compilation Semantics}.
                    191: \ Recommended reading: @cite{@code{State}-smartness--Why it is evil
                    192: \ and how to exorcise it},
                    193: \ @url{http://www.complang.tuwien.ac.at/papers/ertl98.ps.gz}; short
                    194: \ version: Don't use @code{state}!
                    195: 0 state !
1.10      crook     196: 
1.1       anton     197: AUser normal-dp                \ the usual dictionary pointer
                    198: AUser dpp              normal-dp dpp !
                    199:                        \ the pointer to the current dictionary pointer
                    200:                         \ ist reset to normal-dp on (doerror)
                    201:                         \  (i.e. any throw caught by quit)
                    202: AUser LastCFA
                    203: AUser Last
1.26      anton     204: 
1.41      pazsan    205: has? flash [IF]
                    206:     AUser flash-dp
                    207:     : rom  flash-dp dpp ! ;
                    208:     : ram  normal-dp dpp ! ;
                    209: [THEN]
                    210: 
1.33      anton     211: User max-name-length \ maximum length of all names defined yet
                    212: 32 max-name-length !
                    213:     
                    214: \  has? peephole  [IF]
                    215: \  0 value peeptable \ initialized in boot
                    216: \  [THEN]
1.1       anton     217: 
1.7       pazsan    218: has? glocals [IF]
1.1       anton     219: User locals-size \ this is the current size of the locals stack
                    220:                 \ frame of the current word
1.7       pazsan    221: [THEN]
1.1       anton     222: 

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