commit b77150410193afd8360f65314c95d26c5e07c0cc
parent a265965dd35eed71bdde1b44395eb58842d0e5f0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 24 Feb 2023 16:07:16 -0500
Move codesize.sh logic in Dusk
Also, stop paying attention to the "total" LOC figure. Only core LOC are
representative of Dusk's complexity. The rest doesn't affect the system
complexity.
Diffstat:
4 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
@@ -165,9 +165,8 @@ higher cognitive space to fit BSD/Linux wider abstractions in your mind.
* Very small footprint. In Grid mode (TUI mode) with the Grid text editor
and DuskCC (including its stdlib) loaded, Dusk uses 180KB of RAM on a PC.
* It completely self-hosts on all its target (only PC for now) machines.
-* Did I mention that the *whole* code for Dusk OS and its ported applications
- (excluding docs and test code) is less than 13K lines of code and that DuskCC,
- including its assemblers, is 2000 lines?
+* Simple and terse. The core system (all kernels, drivers, filesystems, CC,
+ core libraries) is less than 8K lines of code.
* Since `text/ed` has reached a usable status, the main author of Dusk has been
developing it from within itself on an old Pentium 75 Mhz with 16mb of RAM and
he's having a blast.
diff --git a/codesize.sh b/codesize.sh
@@ -1,12 +1,3 @@
-#!/bin/bash
-echo "Lines of code in Dusk OS"
-echo "All Dusk excluding docs and tests"
-find fs -type f ! -name "*.bin" | grep -vE "fs/(tests|doc)" | xargs cat | wc -l
-echo "Core system: all kernels, drivers, filesystems, subsystems, core libs, asm, CC"
-find fs/{asm,comp,drv,fs,lib,sys,xcomp} -type f | xargs cat | wc -l
-echo "C compiler, excluding arch-specific backends:"
-cat fs/comp/c/*.fs fs/comp/c/vm/common* fs/comp/c/vm/vm.fs | wc -l
-echo "i386 assembler and CC backend"
-cat fs/asm/i386.fs fs/comp/c/vm/i386.fs | wc -l
-echo "Test code:"
-find fs/tests -type f ! -name "*.bin" | xargs cat | wc -l
+#!/bin/sh
+make -s dusk
+echo "f<< /home/codesz.fs bye" | ./dusk
diff --git a/fs/doc/sys/file.txt b/fs/doc/sys/file.txt
@@ -156,11 +156,11 @@ on to a Path reference a little longer, you should copy it elsewhere.
Recursion notes: :iter can recurse and it will behave as expected. However,
all recursive :iter calls must take place within the same filesystem.
-:i ( self -- path )
+:i ( -- path )
Wraps "i" from :iter in a Path structure.
:open ( self -- file )
-:info ( self -- file )
+:info ( self -- info )
:child ( name self -- path-or-0 )
Convenience proxies to the corresponding methods in the Filesystem API.
diff --git a/fs/home/codesz.fs b/fs/home/codesz.fs
@@ -0,0 +1,30 @@
+\ Print statistics about the size of Dusk OS
+?f<< /lib/str.fs
+
+: lc ( path -- linecount )
+ Path :open 0 begin ( hdl cnt )
+ 1+ over IO :readline not until
+ 1- swap File :close ;
+
+: dirlc ( path -- linecount )
+ 0 over Path :iter ( path cnt )
+ Path :i dup Path :info FSInfo dir? if dirlc else lc then +
+ next nip ;
+
+: slistlc ( slist -- linecount )
+ 0 begin over c@ while over curpath :find# dirlc + dip s) | repeat nip ;
+
+." Lines of code in Dusk OS\n"
+." Core system: all kernels, drivers, filesystems, subsystems, core libs, asm, "
+." CC\n"
+7 stringlist core "asm" "comp" "drv" "fs" "lib" "sys" "xcomp"
+core slistlc . nl>
+." C compiler, excluding arch-specific backends\n"
+p" comp/c" dirlc value cclc
+p" comp/c/vm/forth.fs" lc neg to+ cclc
+p" comp/c/vm/i386.fs" lc value i386lc
+i386lc neg to+ cclc
+cclc . nl>
+." i386 assembler and CC backend\n"
+p" asm/i386.fs" lc to+ i386lc
+i386lc . nl>