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

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

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