duskos

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

commit 10bc993f0109fe515f7b7727b9daea33834275fd
parent ec74406cecccf4e7ac41d351ff635d8b835f61d4
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Wed, 10 Aug 2022 11:20:54 -0400

De-value-ize sysdict and nextmeta

This allows us to remove "to" from the kernel. This will also enable the other
change I'm about to commit.

Diffstat:
Mfs/cc/gen.fs | 2+-
Mfs/lib/xdict.fs | 4++--
Mfs/xcomp/bootlo.fs | 17+++++++++--------
Mfs/xcomp/i386.fs | 10+++++-----
Mposix/vm.c | 27+++++++++------------------
5 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs @@ -206,7 +206,7 @@ ASTIDCNT wordtbl gentbl ( node -- ) parentnode dup ast.func.locsize swap to ast.func.cursf ; :w ( Ident ) dup identfind ?dup if ( inode dnode ) nip decl>op else ( inode ) - ast.ident.name sysdict find ?dup _assert mem>op then ; + ast.ident.name sysdict @ find ?dup _assert mem>op then ; :w ( UnaryOp ) _debug if ." unaryop: " dup printast nl> .ops then dup genchildren diff --git a/fs/lib/xdict.fs b/fs/lib/xdict.fs @@ -18,8 +18,8 @@ 0 value dictbkp : newxdict create 4 allot0 ; -: xdict[ ( 'dict -- ) sysdict to dictbkp @ to sysdict ; -: ]xdict ( 'dict -- ) sysdict swap ! dictbkp to sysdict ; +: xdict[ ( 'dict -- ) sysdict @ to dictbkp @ sysdict ! ; +: ]xdict ( 'dict -- ) sysdict @ swap ! dictbkp sysdict ! ; : xdictproxy ( w -- ) doer , does> ( 'dict 'w -- ) over xdict[ swap >r @ execute r> ]xdict ; ' ' xdictproxy x' diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs @@ -1,17 +1,18 @@ -," w>e" 0 , sysdict , 3 c, here 5 - to sysdict ] +," w>e" 0 , sysdict @ , 3 c, here 5 - sysdict ! ] 5 - [ exit, -," ;" 0 , sysdict , $81 c, here w>e to sysdict +," ;" 0 , sysdict @ , $81 c, here w>e sysdict ! ' [ execute, ' exit, execute, exit, -," dict," 0 , sysdict , 5 c, here w>e to sysdict ] +," dict," 0 , sysdict @ , 5 c, here w>e sysdict ! ] dup 1+ swap c@ tuck move, rot> , , c, ; -," entry" 0 , sysdict , 5 c, here w>e to sysdict ] - sysdict nextmeta rot dict, here w>e to sysdict 0 to nextmeta ; -," :" 0 , sysdict , 1 c, here w>e to sysdict ] +," entry" 0 , sysdict @ , 5 c, here w>e sysdict ! ] + sysdict @ nextmeta @ rot dict, here w>e sysdict ! 0 nextmeta ! ; +," :" 0 , sysdict @ , 1 c, here w>e sysdict ! ] word entry ] ; : e>w 5 + ; -: current sysdict e>w ; +: current sysdict @ e>w ; : immediate current 1- dup c@ $80 or swap c! ; : ['] ' litn ; immediate +: to ['] ! [to] ; : to+ ['] +! [to] ; : to' ['] noop [to] ; : to@ ['] @ [to] ; @@ -156,7 +157,7 @@ alias noop [then] \ Docstrings 1 const EMETA_DOCLINE \ a doc strings that ends with LF \ a \\ comment goes before the creation of the word it comments -: \\ to' nextmeta lladd drop EMETA_DOCLINE , begin in< dup c, LF = until ; +: \\ nextmeta lladd drop EMETA_DOCLINE , begin in< 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 ; diff --git a/fs/xcomp/i386.fs b/fs/xcomp/i386.fs @@ -136,8 +136,10 @@ xcode heremax xcode here wcall, (val) pc to lblhere HERESTART , +pc to lblsysdict 0 , xcode sysdict - wcall, (val) pc to lblsysdict 0 , + lblsysdict pspushN, + ret, pc to lblcompiling 0 , xcode compiling @@ -758,11 +760,9 @@ xcode ," xwordlbl ," i) push, lblcwrite abs>rel jmp, +pc to lblnextmeta 0 , xcode nextmeta - wcall, (val) pc to lblnextmeta 0 , - -xcode to - lbltoptr m) xwordlbl ! i) mov, + lblnextmeta pspushN, ret, \ binary for "bp 4 i) sub, [ebp] XXXX i) mov," is 83 ed 04 c7 45 00 XX XX XX XX diff --git a/posix/vm.c b/posix/vm.c @@ -50,7 +50,6 @@ struct VM { static struct VM vm = {0}; static FILE *bootfp; -static dword lblfind = 0; // Utilities static void vmabort() { vm.PC = MEMSZ + 1; } @@ -675,11 +674,8 @@ static void APOS() { // op: 56 if (!ppeek()) WNF(); } -static void TO() { // op: 57 - if (lblfind == 0) { - lblfind = find("!"); - } - vm.toptr = lblfind; +static void COMPILING() { // op: 57 + ppush(vm.compiling); } static void SWR() { // op: 58 @@ -840,12 +836,7 @@ static void FCLOSE () { // op: 60 } } -// Words that should go before the FS section, but were added later. -static void COMPILING() { // op: 61 - ppush(vm.compiling); -} - -#define OPCNT 0x62 +#define OPCNT 0x61 static void (*ops[OPCNT])() = { JUMP, CALL, RET, LIT, BYE, BYEFAIL, QUIT, ABORT_, EXECUTE, CELL, VAL, ALIAS, DOES, SLIT, BR, CBR, @@ -857,9 +848,9 @@ static void (*ops[OPCNT])() = { STORE, ADDSTORE, WRITE, ADD, SUB, MUL, DIVMOD, AND, OR, XOR, BOOL, NOT, LT, SHLC, SHRC, LSHIFT, RSHIFT, LITN, EXECUTEWR, EXITWR, MOVE, MOVEWR, RTYPE, WNF, - STACKCHK, MAYBEWORD, WORD, PARSE, REQ, FIND, APOS, TO, + STACKCHK, MAYBEWORD, WORD, PARSE, REQ, FIND, APOS, COMPILING, SWR, STARTCOMP, STOPCOMP, RUNWORD, EXIT, FCHILD, FOPEN, FREADBUF, - FCLOSE, COMPILING}; + FCLOSE}; static char *opnames[OPCNT] = { NULL, NULL, NULL, NULL, "bye", "byefail", "quit", "(abort)", @@ -872,9 +863,9 @@ static char *opnames[OPCNT] = { "!", "+!", ",", "+", "-", "*", "/mod", "and", "or", "xor", "bool", "not", "<", "<<c", ">>c", "lshift", "rshift", "litn", "execute,", "exit,", "move", "move,", "rtype", "(wnf)", - "stack?", "maybeword", "word", "parse", "[]=", "find", "'", "to", + "stack?", "maybeword", "word", "parse", "[]=", "find", "'", "compiling", ",\"", "]", "[", "runword", "exit", "_fchild", "_fopen", "_freadbuf", - "_fclose", "compiling"}; + "_fclose"}; static void oprun1() { // run next op if (!memchk(vm.PC)) return; @@ -947,10 +938,10 @@ static void buildsysdict() { sysalias("abort", ABORT); sysalias("main", MAINLOOP); sysval("here", HERE); - sysval("sysdict", SYSDICT); - sysval("nextmeta", NEXTMETA); sysconst("heremax", HEREMAX); sysconst("curword", CURWORD); + sysconst("sysdict", SYSDICT); + sysconst("nextmeta", NEXTMETA); entry("mainloop"); sd(MAINLOOP, here()); callwr(find("word"));