duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 3094b1728c6a6b4cf91ec9055825df1cd290cce0
parent 3ecebfc0ff6fa29ed6e9fe36979b92610a453374
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 25 Jun 2022 07:01:41 -0400

Add sys/xhere

Diffstat:
Mfs/cc/cc.fs | 2+-
Mfs/cc/cc1.fs | 4++--
Mfs/init.fs | 2++
Afs/sys/xhere.fs | 27+++++++++++++++++++++++++++
4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/fs/cc/cc.fs b/fs/cc/cc.fs @@ -1,5 +1,5 @@ +\ Requires sys/scratch sys/xhere 1 value _debug -?f<< sys/scratch.fs ?f<< lib/str.fs ?f<< lib/wordtbl.fs ?f<< lib/xdict.fs diff --git a/fs/cc/cc1.fs b/fs/cc/cc1.fs @@ -4,6 +4,6 @@ \ Compiles input coming from the cc< alias (defaulting to in<) and writes the \ result to here. Aborts on error. : cc1, ( -- ) - parseast curunit _debug if dup printast nl> then - dup mapunit _debug if printmap then + xhere$ xhere[ parseast curunit _debug if dup printast nl> then + dup mapunit _debug if printmap then ]xhere gennode ; diff --git a/fs/init.fs b/fs/init.fs @@ -2,6 +2,8 @@ f<< lib/core.fs f<< lib/annotate.fs f<< sys/doc.fs +f<< sys/scratch.fs +f<< sys/xhere.fs f<< sys/rdln.fs : init S" Dusk OS" stype nl> .free rdln$ ; init diff --git a/fs/sys/xhere.fs b/fs/sys/xhere.fs @@ -0,0 +1,27 @@ +\ Extra "here" space +\ This subsystem is a preallocated buffer for transitionary data. It's very +\ similar to lib/scratch, but for written (with "," words) data. Unlike the +\ sratchpad, this is not a rolling buffer. You're expected to know when you +\ start using it, and when you stop. + +\ You initialize it with here$, and then activate it with here[. From that +\ moment, everything you write is temporary. You return to your regular "here" +\ with ]here. + +\ This is used, for example, as a temporary space for the C compiler AST and +\ mapping. Without xhere, this data is written to here and permanently uses +\ system memory. + +32 1024 * const XHERESZ +1024 const XHEREWARN + +create _buf XHERESZ allot +_buf value _ptr +0 value _oldhere + +: xhere$ _buf to _ptr ; +: xhere[ here to _oldhere _ptr to here ; +: ]xhere + here to _ptr _oldhere to here + _ptr XHEREWARN + _buf XHERESZ + > if + ." Running out of xhere space!" nl> then ;