duskos

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

commit ba300dc8c4b2110fdf777db69ba79a1e7e200905
parent 269aec12f9553fda9a261723fa5cff13f10a8718
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Tue, 13 Sep 2022 15:29:26 -0400

Move a bunch of words from bootlo into a new lib/meta

Diffstat:
Mfs/cc/vm/i386.fs | 3+++
Mfs/drv/pc/pci.fs | 1+
Mfs/lib/btrace.fs | 3++-
Afs/lib/meta.fs | 22++++++++++++++++++++++
Mfs/xcomp/bootlo.fs | 20--------------------
5 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/fs/cc/vm/i386.fs b/fs/cc/vm/i386.fs @@ -168,6 +168,9 @@ create registers AX c, BX c, CX c, DX c, SI c, DI c, VM_*CONSTANT optype = if oparg VM_NONE optype! else opAsm then abs>rel call, opdeinit ; +\ TODO: copy forth VM's TOS argtype and logic to all VMs. This could save quite +\ a few back-and-forth operations. + \ Allocate a new register for active op and pop 4b from PS into it. : vmpspop, noop# VM_REGISTER optype! regallot dup oparg! r! bp 0 d) mov, diff --git a/fs/drv/pc/pci.fs b/fs/drv/pc/pci.fs @@ -3,6 +3,7 @@ ?f<< /lib/nfmt.fs ?f<< /lib/bit.fs ?f<< /lib/wordtbl.fs +?f<< /lib/meta.fs \ PCI registers \ Data from PCI registers are always fetched in 4 bytes wide chunks, but the diff --git a/fs/lib/btrace.fs b/fs/lib/btrace.fs @@ -1,4 +1,5 @@ -?f<< lib/nfmt.fs +?f<< /lib/nfmt.fs +?f<< /lib/meta.fs : raddr>entry ( a -- w ) sysdict begin 2dup < while llnext repeat nip e>w ; : .raddr ( a -- ) dup .x raddr>entry ?dup if spc> .word then ; : _abort ( 'oldabort -- ) nl> begin rcnt while r> .raddr nl> repeat execute ; diff --git a/fs/lib/meta.fs b/fs/lib/meta.fs @@ -0,0 +1,22 @@ +\ Utilities around dictionary metadata + +\ Dictionary +-9 &+@ emeta +-9 &+ 'emeta +: wordlen ( w -- len ) 1- c@ $3f and ; +: wordname[] ( w -- sa sl ) + dup wordlen swap 9 - over - ( sl sa ) swap ; +: .word ( w -- ) wordname[] rtype ; +: words ( -- ) + sysdict begin dup while dup e>w .word spc> llnext repeat drop ; + +\ Entry metadata +4 &+@ emetatype +8 &+ 'emetadata +: findemeta ( typeid ll -- ll-or-0 ) begin ( typeid ll ) + dup while 2dup emetatype = not while llnext repeat + ( success ) then ( typeid ll-or-0 ) nip ; + +: .doc ( w -- ) emeta begin ( ll ) + EMETA_DOCLINE swap findemeta ?dup while ( ll ) + dup 'emetadata begin c@+ dup emit LF = until drop llnext repeat ; diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -178,30 +178,10 @@ alias noop [then] : llinsert ( 'll -- newll ) here over @ , ( 'll newll ) dup rot ! ; : llcnt ( ll -- count ) 0 >r begin ?dup while 1 to+ V1 llnext repeat r> ; -\ Dictionary --9 &+@ emeta --9 &+ 'emeta -: wordlen ( w -- len ) 1- c@ $3f and ; -: wordname[] ( w -- sa sl ) - dup wordlen swap 9 - over - ( sl sa ) swap ; -: .word ( w -- ) wordname[] rtype ; -: words ( -- ) - sysdict begin dup while dup e>w .word spc> llnext repeat drop ; - -\ Entry metadata -4 &+@ emetatype -8 &+ 'emetadata -: findemeta ( typeid ll -- ll-or-0 ) begin ( typeid ll ) - dup while 2dup emetatype = not while llnext repeat - ( success ) then ( typeid ll-or-0 ) nip ; - \ Docstrings 1 const EMETA_DOCLINE \ a doc strings that ends with LF \ a \\ comment goes before the creation of the word it comments : \\ nextmeta lladd drop EMETA_DOCLINE , begin IN< @ execute dup c, LF = until ; -: .doc ( w -- ) emeta begin ( ll ) - EMETA_DOCLINE swap findemeta ?dup while ( ll ) - dup 'emetadata begin c@+ dup emit LF = until drop llnext repeat ; \ Alias chaining. See doc/usage. : _ ( 'target 'alias -- )