diff options
| author | kitty <nepeta@canaglie.net> | 2026-03-28 14:06:55 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-03-28 14:06:55 +1100 |
| commit | 2814698c08e02c65793bd9cbc9437ff56dd61fbe (patch) | |
| tree | 5a287330fb3d23e2a86e5404586909fe83432f60 /sanctuary.fs | |
| parent | 839e3510d3ad5bece904001a76d65901664ec4da (diff) | |
wheeee
Diffstat (limited to 'sanctuary.fs')
| -rw-r--r-- | sanctuary.fs | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/sanctuary.fs b/sanctuary.fs index c420890..15d5a0e 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -56,6 +56,14 @@ 0 constant false -1 constant true +hex +\ really i should just change the builtins to work with defer +: hijacks ' ( word ) here >r dp ! ( temporarily set dp so we can use , ) + 49 c, bb c, ( xt ) , \ mov r11, xt + 41 c, ff c, e3 c, \ jmp r11 + r> dp ! ; +decimal + : cmove, dup >r here swap cmove r> allot ; : s" [ char " ] literal parse ( a u ) branch >mark >r 2dup cmove, nip ( u ) ( R: mark ) @@ -68,17 +76,51 @@ : zstrlen dup begin dup c@ 0<> while 1+ repeat swap - ; : s>z here -rot cmove, 0 c, ; -1 constant stdout -2 constant stderr +\ PRIVATISATION AND HIDING {{{ +\ maybe i add locals later, implementation may be complex though. this isn't. +\ privatise just loops through words from the start of privatisation +\ to the end and activates the smudge bit on all of them. +\ privatisation yoinked from pforth + +: (hide) cell+ dup c@ 1 or swap c! ; +: hide parse-name ?find (hide) ; + +variable private0 variable private$ -: type swap stdout 1 syscall3 ; -: emit sp 1 swap stdout 1 syscall3 2drop ; +: private{ latest @ private0 ! ; +: }private latest @ private$ ! ; +: privatise private0 @ 0= private$ @ 0= or if abort then + private$ @ + begin dup private0 @ u> while + dup (hide) @ ( → next ht ) repeat drop + 0 private0 ! 0 private$ ! ; +\ }}} +\ MMAP {{{ +\ MMAP CONSTANTS {{{ hex -\ really i should just change the builtins to work with defer -: hijacks ' ( word ) here >r dp ! ( temporarily set dp so we can use , ) - 49 c, bb c, ( xt ) , \ mov r11, xt - 41 c, ff c, e3 c, \ jmp r11 - r> dp ! ; +\ prot +0 constant PROT_NONE 1 constant PROT_READ 2 constant PROT_WRITE 4 constant PROT_EXEC +\ flags +1 constant MAP_SHARED 2 constant MAP_PRIVATE 3 constant MAP_SHARED_VALIDATE +10 constant MAP_FIXED 20 constant MAP_ANONYMOUS 100 constant MAP_GROWSDOWN decimal +\ }}} + +: mmap 9 syscall6 ; +: munmap 11 syscall2 ; +\ }}} + +\ I/O {{{ +0 constant stdin +1 constant stdout +2 constant stderr + +: sys-write 0 syscall3 ; +: sys-read 1 syscall3 ; + +: type swap stdout 1 syscall3 drop ; +: emit sp 1 type drop ; +\ }}} + bye |
