From 71e4f3812982dba2efb471283d310224e8db363e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 3 Mar 2021 22:09:50 -0800 Subject: 7842 - new directory organization Baremetal is now the default build target and therefore has its sources at the top-level. Baremetal programs build using the phase-2 Mu toolchain that requires a Linux kernel. This phase-2 codebase which used to be at the top-level is now under the linux/ directory. Finally, the phase-2 toolchain, while self-hosting, has a way to bootstrap from a C implementation, which is now stored in linux/bootstrap. The bootstrap C implementation uses some literate programming tools that are now in linux/bootstrap/tools. So the whole thing has gotten inverted. Each directory should build one artifact and include the main sources (along with standard library). Tools used for building it are relegated to sub-directories, even though those tools are often useful in their own right, and have had lots of interesting programs written using them. A couple of things have gotten dropped in this process: - I had old ways to run on just a Linux kernel, or with a Soso kernel. No more. - I had some old tooling for running a single test at the cursor. I haven't used that lately. Maybe I'll bring it back one day. The reorg isn't done yet. Still to do: - redo documentation everywhere. All the README files, all other markdown, particularly vocabulary.md. - clean up how-to-run comments at the start of programs everywhere - rethink what to do with the html/ directory. Do we even want to keep supporting it? In spite of these shortcomings, all the scripts at the top-level, linux/ and linux/bootstrap are working. The names of the scripts also feel reasonable. This is a good milestone to take stock at. --- apps/tile/main.mu | 133 ------------------------------------------------------ 1 file changed, 133 deletions(-) delete mode 100644 apps/tile/main.mu (limited to 'apps/tile/main.mu') diff --git a/apps/tile/main.mu b/apps/tile/main.mu deleted file mode 100644 index e0daaf1b..00000000 --- a/apps/tile/main.mu +++ /dev/null @@ -1,133 +0,0 @@ -fn main args-on-stack: (addr array addr array byte) -> _/ebx: int { - var args/eax: (addr array addr array byte) <- copy args-on-stack - var len/ecx: int <- length args - compare len, 2 - { - break-if-!= - # if single arg is 'test', run tests - var tmp/ecx: (addr addr array byte) <- index args, 1 - var tmp2/eax: boolean <- string-equal? *tmp, "test" - compare tmp2, 0/false - { - break-if-= - run-tests - return 0 # TODO: get at Num-test-failures somehow - } - # if single arg is 'screen', run in full-screen mode - tmp2 <- string-equal? *tmp, "screen" - compare tmp2, 0/false - { - break-if-= - interactive - return 0 - } - # if single arg is 'type', run in typewriter mode - tmp2 <- string-equal? *tmp, "type" - compare tmp2, 0/false - { - break-if-= - repl - return 0 - } - # if single arg is 'test' ... - tmp2 <- string-equal? *tmp, "test2" - compare tmp2, 0/false - { - break-if-= - test - return 0 - } - } - # otherwise error message - print-string-to-real-screen "usage:\n" - print-string-to-real-screen " to run tests: tile test\n" - print-string-to-real-screen " full-screen mode: tile screen\n" - print-string-to-real-screen " regular REPL: tile type\n" - return 1 -} - -fn interactive { - enable-screen-grid-mode - enable-keyboard-immediate-mode - var env-storage: environment - var env/esi: (addr environment) <- address env-storage - initialize-environment env - { - render env - var key/eax: grapheme <- read-key-from-real-keyboard - compare key, 0x11/ctrl-q - break-if-= - process env, key - loop - } - enable-keyboard-type-mode - enable-screen-type-mode -} - -fn test { - var env-storage: environment - var env/esi: (addr environment) <- address env-storage - initialize-environment-with-fake-screen env, 0x20, 0xa0 - render env -} - -fn process-all env: (addr environment), cmds: (addr array byte) { - var cmds-stream: (stream byte 0x100) - var cmds-stream-a/esi: (addr stream byte) <- address cmds-stream - write cmds-stream-a, cmds - { - var done?/eax: boolean <- stream-empty? cmds-stream-a - compare done?, 0/false - break-if-!= - var g/eax: grapheme <- read-grapheme cmds-stream-a - process env, g - loop - } -} - -fn repl { - { - # prompt - print-string-to-real-screen "> " - # read - var line-storage: (stream byte 0x100) - var line/ecx: (addr stream byte) <- address line-storage - clear-stream line - read-line-from-real-keyboard line - var done?/eax: boolean <- stream-empty? line - compare done?, 0/false - break-if-!= - # parse - var env-storage: environment - var env/esi: (addr environment) <- address env-storage - initialize-environment env - { - var done?/eax: boolean <- stream-empty? line - compare done?, 0/false - break-if-!= - var g/eax: grapheme <- read-grapheme line - process env, g - loop - } - # eval - var stack-storage: value-stack - var stack/edi: (addr value-stack) <- address stack-storage - initialize-value-stack stack, 0x10 - evaluate-environment env, stack - # print - var empty?/eax: boolean <- value-stack-empty? stack - { - compare empty?, 0/false - break-if-!= - var result/xmm0: float <- pop-number-from-value-stack stack - print-float-decimal-approximate 0, result, 3 - print-string 0, "\n" - print-string 0, "width: " - var width/eax: int <- float-size result, 3 - print-int32-decimal 0, width - print-string 0, "\n" - } - # - loop - } -} -- cgit 1.4.1-2-gfad0