duskos

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

commit b21dad9863f7f1a1970d190a0c7451a8285d23a9
parent bab75bf92115bae8986dba3a13303c71589fe468
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Tue, 17 Jan 2023 17:06:44 -0500

Change llinsert semantics

Diffstat:
Mfs/doc/dict.txt | 6+++---
Mfs/fs/fatlo.fs | 2+-
Mfs/tests/kernel.fs | 2+-
Mfs/xcomp/bootlo.fs | 6+++---
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/doc/dict.txt b/fs/doc/dict.txt @@ -258,9 +258,9 @@ llprev tgt ll -- ll From "ll", iterate LL until we reach the element when the llappend elem ll -- Append "elem" at the end of "ll". lladd ll -- ll Write a new LL element to here, yield it, then write its address to the last element of "ll". -llinsert 'll -- ll Given a *pointer* to a LL, write a new LL to here and - replace that first element in that pointer with the new - LL element. +llinsert elem ll -- Insert "elem" between "ll" and its next element. If "ll" + is the last element of the list, this is equivalent to + "llappend". llcnt ll -- n Yield the number of elements in "ll". ## Dictionary diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs @@ -231,7 +231,7 @@ extends File struct[ FATFile 0 ( entryoff ) , : :createcursor ( fat -- hdl ) - 0 align4 dup to' FAT lastcursor llinsert ( fat newll ) + 0 align4 dup to' FAT lastcursor lladd ( fat newll ) swap :cursorsize allot ( newll ) CELLSZ + ( hdl ) 0 over to flags ( mark as "free" ) ; diff --git a/fs/tests/kernel.fs b/fs/tests/kernel.fs @@ -79,7 +79,7 @@ current .x 4 &+@ myfield here to ll 0 , 42 , ll lladd drop 54 , -to' ll llinsert drop 33 , +here 0 , 33 , to' ll llinsert ll myfield 33 #eq ll llnext myfield 42 #eq ll llnext llnext myfield 54 #eq diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -157,15 +157,15 @@ alias drop emit alias noop [then] \ Linked lists. See doc/usage. -: llnext @ ; +alias @ llnext : llend ( ll -- lastll ) begin dup llnext ?dup while nip repeat ( ll ) ; : llprev ( tgt ll -- prev ) begin 2dup llnext = not while llnext ?dup while repeat abort" llprev failed" then nip ; : llappend ( elem ll -- ) llend ! ; : lladd ( ll -- newll ) here swap llappend here 0 , ; -: llinsert ( 'll -- newll ) here over @ , ( 'll newll ) dup rot ! ; -: llcnt ( ll -- count ) 0 >r begin ?dup while 1 to+ V1 llnext repeat r> ; +: llinsert ( elem ll -- ) over swap @! swap ! ; +: llcnt ( ll -- count ) 0 >r begin ?dup not if r> neg exit then llnext next ; \ Entry metadata 1 const EMETA_DOCLINE \ a doc strings that ends with LF