duskos

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

commit c729d36fca3ef36e2da3e795c480bbd04f109ff1
parent 2da6bd68de8b688cb03bc8bfb942084d14183b7d
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed,  8 Jun 2022 07:37:15 -0400

Change what a String is in Duck OS

See fs/doc/terms.txt. Conversion underway.

Diffstat:
Mboot.fs | 2+-
Mdusk.asm | 15+++++++--------
Mfs/cc/ast.fs | 8++++----
Mfs/cc/gen.fs | 2+-
Afs/doc/terms.txt | 27+++++++++++++++++++++++++++
Mfs/init.fs | 2+-
Mfs/lib/core.fs | 6+++---
Mfs/sys/rdln.fs | 2+-
8 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/boot.fs b/boot.fs @@ -46,7 +46,7 @@ create _ $100 allot create _ 'C' c, 'a' c, 'n' c, ''' c, 't' c, $20 c, 'o' c, 'p' c, 'e' c, 'n' c, : fopen ( sa sl -- fd ) tocstr 5 ( open ) swap 0 0 ( open cstr noflag O_RDONLY ) lnxcall - dup 0< if _ 10 stype abort then ; + dup 0< if _ 10 rtype abort then ; create _ 1 allot : fread ( fd -- c-or-0 ) 3 ( read ) swap _ 1 lnxcall 1 = if _ c@ else 0 then ; diff --git a/dusk.asm b/dusk.asm @@ -68,7 +68,6 @@ compiling: resd 1 curword: resb 0x20 ; 1b len, then contents iinrd: resd 1 ; iin< inrd: resd 1 ; in< -stype: resd 1 resd PS_SZ ps_top: resd RS_SZ @@ -555,11 +554,11 @@ defword 'move,', 5, word_movewrite rep movsb ret -; ( -- sa sl ) -defword 'stype', 5, word_stype +; ( a u -- ) +defword 'rtype', 5, word_rtype pspop ecx pspop esi -_stype_loop: +_rtype_loop: xor eax, eax mov al, [esi] pspush eax @@ -570,16 +569,16 @@ _stype_loop: pop esi inc esi dec ecx - jnz _stype_loop + jnz _rtype_loop ret ; ( -- ) defword '(wnf)', 5, word_wnf call word_curword - call word_stype + call word_rtype mov ecx, 15 mov esi, wnfstr - call _stype_loop + call _rtype_loop jmp word_abort defword 'stack?', 6, word_stackcond @@ -587,7 +586,7 @@ defword 'stack?', 6, word_stackcond jna _ret mov ecx, 15 mov esi, uflwstr - call _stype_loop + call _rtype_loop jmp word_abort ; ( -- sa sl ) diff --git a/fs/cc/ast.fs b/fs/cc/ast.fs @@ -71,7 +71,7 @@ create astidnames : _[ '[' emit ; : _] ']' emit ; -: _s _[ dup strdata stype _] ; +: _s _[ dup strdata rtype _] ; : _i _[ dup intdata .x _] ; ASTIDCNT wordtbl astdatatbl ( node -- node ) @@ -85,11 +85,11 @@ ASTIDCNT wordtbl astdatatbl ( node -- node ) 'w noop ( Expression ) :w ( UnaryOp ) _[ dup 'data @ uopchar emit _] ; 'w noop ( Factor ) -:w ( BinaryOp ) _[ dup 'data @ boptoken stype _] ; +:w ( BinaryOp ) _[ dup 'data @ boptoken rtype _] ; : printast ( node -- ) ?dup not if ." null" exit then - dup astid idname stype + dup astid idname rtype astdatatbl over astid wexec firstchild ?dup if '(' emit begin @@ -119,7 +119,7 @@ ASTIDCNT wordtbl astdatatbl ( node -- node ) : BinaryOp ( opid -- node ) 2 AST_BINARYOP newnode , ; : _err ( ta tl -- ) - stype spc> + rtype spc> activenode ?dup if astid .x1 spc> then abort" parsing error" ; : _assert ( ta tl f -- ) not if _err then ; diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs @@ -66,7 +66,7 @@ ASTIDCNT wordtbl gentbl ( node -- ) 'w _err 'w genchildren ( Unit ) :w ( Function ) - _debug if ." debugging: " dup strdata stype nl> then + _debug if ." debugging: " dup strdata rtype nl> then dup strdata entry genchildren _debug if current here current - spit nl> then ; :w ( Return ) genchildren diff --git a/fs/doc/terms.txt b/fs/doc/terms.txt @@ -0,0 +1,27 @@ +# Terminology + +Some words in Dusk OS refer to particular concepts that we try to keep +consistent across the code and documentation. + +# Range + +A range is an area of memory with a definite start address and size. On PS, it +is represented as two elements, starting with the address, and then the size. + +Words like "move" operate on ranges. + +In word signatures, a range will often look like ( a u -- ), but sometimes, +letters are added to "a" to indicate the type of data in the range. For example, +an "unpacked" string (a string upon which we're read the first length byte) +will be shown as ( sa sl -- ), for "string address" and "string length". This is +a range too. + +# String + +Strings in Dusk OS are ranges where the first byte of the range contains its +length. On PS, they are passed around as a single element, the address of the +length byte. It will often look like ( str -- ) or ( s -- ). + +NOTE: At this moment, String and Range terminology across Dusk OS code is messed +up. String started out as Range and there's work underway to harmonize this. +Ranges are often referred to as strings. diff --git a/fs/init.fs b/fs/init.fs @@ -1,5 +1,5 @@ \ Initialization layer. Called at the end of boot.fs f<< lib/core.fs f<< sys/rdln.fs -: init S" Dusk OS" stype rdln$ ; +: init S" Dusk OS" rtype rdln$ ; init diff --git a/fs/lib/core.fs b/fs/lib/core.fs @@ -13,7 +13,7 @@ $08 value BS $04 value EOF : ," begin in< dup '"' = if drop exit then c, again ; : S" compile (s) here 1 allot here ," here -^ ( 'len len ) swap c! ; immediate -: ." [compile] S" compile stype ; immediate +: ." [compile] S" compile rtype ; immediate : abort" [compile] ." compile abort ; immediate : [c]? ( c a u -- i ) @@ -31,5 +31,5 @@ create _ ," 0123456789abcdef" scnt >A begin dup .x spc> >r scnt not until begin r> scnt A> = until ; : .S ( -- ) - S" SP " stype scnt .x1 spc> S" RS " stype rcnt .x1 spc> - S" -- " stype stack? psdump ; + S" SP " rtype scnt .x1 spc> S" RS " rtype rcnt .x1 spc> + S" -- " rtype stack? psdump ; diff --git a/fs/sys/rdln.fs b/fs/sys/rdln.fs @@ -13,7 +13,7 @@ in) value in> dup emitv dup rot c!+ ( c ptr+1 ) dup in) = rot SPC < or ( ptr+1 f ) then ; : rdln - in( LNSZ SPC fill S" ok" stype nl> + in( LNSZ SPC fill S" ok" rtype nl> in( begin key lntype until drop nl> ; : rdln<? ( -- c-or-0 ) in> in) < if in> c@+ swap to in> else 0 then ;