From 3d1c4216ede8c628558c9fe700fb2be1aa08b473 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 2 Nov 2020 21:24:53 -0800 Subject: 7162 --- html/apps/tile/main.mu.html | 225 ++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 113 deletions(-) (limited to 'html/apps/tile/main.mu.html') diff --git a/html/apps/tile/main.mu.html b/html/apps/tile/main.mu.html index 7440bd07..8e329fff 100644 --- a/html/apps/tile/main.mu.html +++ b/html/apps/tile/main.mu.html @@ -57,7 +57,7 @@ if ('onhashchange' in window) { https://github.com/akkartik/mu/blob/master/apps/tile/main.mu
-  1 fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int {
+  1 fn main args-on-stack: (addr array addr array byte) -> _/ebx: int {
   2   var args/eax: (addr array addr array byte) <- copy args-on-stack
   3   var len/ecx: int <- length args
   4   $main-body: {
@@ -71,118 +71,117 @@ if ('onhashchange' in window) {
  12       {
  13         break-if-=
  14         run-tests
- 15         exit-status <- copy 0  # TODO: get at Num-test-failures somehow
- 16         break $main-body
- 17       }
- 18       # if single arg is 'screen', run in full-screen mode
- 19       tmp2 <- string-equal? *tmp, "screen"
- 20       compare tmp2, 0  # false
- 21       {
- 22         break-if-=
- 23         interactive
- 24         exit-status <- copy 0
- 25         break $main-body
- 26       }
- 27       # if single arg is 'type', run in typewriter mode
- 28       tmp2 <- string-equal? *tmp, "type"
- 29       compare tmp2, 0  # false
- 30       {
- 31         break-if-=
- 32         repl
- 33         exit-status <- copy 0
- 34         break $main-body
- 35       }
- 36       # if single arg is 'test' ...
- 37       tmp2 <- string-equal? *tmp, "test2"
- 38       compare tmp2, 0  # false
- 39       {
- 40         break-if-=
- 41         test
- 42         exit-status <- copy 0
- 43         break $main-body
- 44       }
- 45     }
- 46     # otherwise error message
- 47     print-string-to-real-screen "usage:\n"
- 48     print-string-to-real-screen "  to run tests: tile test\n"
- 49     print-string-to-real-screen "  full-screen mode: tile screen\n"
- 50     print-string-to-real-screen "  regular REPL: tile type\n"
- 51     exit-status <- copy 1
- 52   }
- 53 }
- 54 
- 55 fn interactive {
- 56   enable-screen-grid-mode
- 57   enable-keyboard-immediate-mode
- 58   var env-storage: environment
- 59   var env/esi: (addr environment) <- address env-storage
- 60   initialize-environment env
- 61   draw-screen env
- 62   {
- 63     var key/eax: grapheme <- read-key-from-real-keyboard
- 64     compare key, 0x11  # 'ctrl-q'
- 65     break-if-=
- 66     process env, key
- 67     render env
- 68     loop
- 69   }
- 70   enable-keyboard-type-mode
- 71   enable-screen-type-mode
- 72 }
- 73 
- 74 fn test {
- 75   var env-storage: environment
- 76   var env/esi: (addr environment) <- address env-storage
- 77   initialize-environment-with-fake-screen env, 5, 0xa
- 78   var g/eax: grapheme <- copy 0x31  # '1'
- 79   process env, g
- 80   g <- copy 1  # 'ctrl-a'
- 81   process env, g
- 82 #?   render env
- 83 }
- 84 
- 85 fn repl {
- 86   {
- 87     # prompt
- 88     var line-storage: (stream byte 0x100)
- 89     var line/ecx: (addr stream byte) <- address line-storage
- 90     print-string-to-real-screen "> "
- 91     # read
- 92     clear-stream line
- 93     read-line-from-real-keyboard line
- 94     var done?/eax: boolean <- stream-empty? line
- 95     compare done?, 0  # false
- 96     break-if-!=
- 97     # parse
- 98     var env-storage: environment
- 99     var env/esi: (addr environment) <- address env-storage
-100     initialize-environment env
-101     {
-102       var done?/eax: boolean <- stream-empty? line
-103       compare done?, 0  # false
-104       break-if-!=
-105       var g/eax: grapheme <- read-grapheme line
-106       process env, g
-107       loop
-108     }
-109     # eval
-110     var stack-storage: value-stack
-111     var stack/edi: (addr value-stack) <- address stack-storage
-112     initialize-value-stack stack, 0x10
-113     evaluate-environment env, stack
-114     # print
-115     var empty?/eax: boolean <- value-stack-empty? stack
-116     {
-117       compare empty?, 0  # false
-118       break-if-!=
-119       var result/eax: int <- pop-int-from-value-stack stack
-120       print-int32-decimal-to-real-screen result
-121       print-string-to-real-screen "\n"
-122     }
-123     #
-124     loop
-125   }
-126 }
+ 15         return 0  # TODO: get at Num-test-failures somehow
+ 16       }
+ 17       # if single arg is 'screen', run in full-screen mode
+ 18       tmp2 <- string-equal? *tmp, "screen"
+ 19       compare tmp2, 0  # false
+ 20       {
+ 21         break-if-=
+ 22         interactive
+ 23         return 0
+ 24       }
+ 25       # if single arg is 'type', run in typewriter mode
+ 26       tmp2 <- string-equal? *tmp, "type"
+ 27       compare tmp2, 0  # false
+ 28       {
+ 29         break-if-=
+ 30         repl
+ 31         return 0
+ 32       }
+ 33       # if single arg is 'test' ...
+ 34       tmp2 <- string-equal? *tmp, "test2"
+ 35       compare tmp2, 0  # false
+ 36       {
+ 37         break-if-=
+ 38         test
+ 39         return 0
+ 40       }
+ 41     }
+ 42     # otherwise error message
+ 43     print-string-to-real-screen "usage:\n"
+ 44     print-string-to-real-screen "  to run tests: tile test\n"
+ 45     print-string-to-real-screen "  full-screen mode: tile screen\n"
+ 46     print-string-to-real-screen "  regular REPL: tile type\n"
+ 47     return 1
+ 48   }
+ 49 }
+ 50 
+ 51 fn interactive {
+ 52   enable-screen-grid-mode
+ 53   enable-keyboard-immediate-mode
+ 54   var env-storage: environment
+ 55   var env/esi: (addr environment) <- address env-storage
+ 56   initialize-environment env
+ 57   draw-screen env
+ 58   {
+ 59     var key/eax: grapheme <- read-key-from-real-keyboard
+ 60     compare key, 0x11  # 'ctrl-q'
+ 61     break-if-=
+ 62     process env, key
+ 63     render env
+ 64     loop
+ 65   }
+ 66   enable-keyboard-type-mode
+ 67   enable-screen-type-mode
+ 68 }
+ 69 
+ 70 fn test {
+ 71   test-surface-pin-at-origin
+ 72 #?   var env-storage: environment
+ 73 #?   var env/esi: (addr environment) <- address env-storage
+ 74 #?   initialize-environment-with-fake-screen env, 5, 0xa
+ 75 #?   var g/eax: grapheme <- copy 0x22  # '"'
+ 76 #?   process env, g
+ 77 #?   g <- copy 0x61  # 'a'
+ 78 #?   process env, g
+ 79 #?   g <- copy 0x22  # '"'
+ 80 #?   process env, g
+ 81 #?   render env
+ 82 }
+ 83 
+ 84 fn repl {
+ 85   {
+ 86     # prompt
+ 87     print-string-to-real-screen "> "
+ 88     # read
+ 89     var line-storage: (stream byte 0x100)
+ 90     var line/ecx: (addr stream byte) <- address line-storage
+ 91     clear-stream line
+ 92     read-line-from-real-keyboard line
+ 93     var done?/eax: boolean <- stream-empty? line
+ 94     compare done?, 0  # false
+ 95     break-if-!=
+ 96     # parse
+ 97     var env-storage: environment
+ 98     var env/esi: (addr environment) <- address env-storage
+ 99     initialize-environment env
+100     {
+101       var done?/eax: boolean <- stream-empty? line
+102       compare done?, 0  # false
+103       break-if-!=
+104       var g/eax: grapheme <- read-grapheme line
+105       process env, g
+106       loop
+107     }
+108     # eval
+109     var stack-storage: value-stack
+110     var stack/edi: (addr value-stack) <- address stack-storage
+111     initialize-value-stack stack, 0x10
+112     evaluate-environment env, stack
+113     # print
+114     var empty?/eax: boolean <- value-stack-empty? stack
+115     {
+116       compare empty?, 0  # false
+117       break-if-!=
+118       var result/eax: int <- pop-int-from-value-stack stack
+119       print-int32-decimal-to-real-screen result
+120       print-string-to-real-screen "\n"
+121     }
+122     #
+123     loop
+124   }
+125 }
 
-- cgit 1.4.1-2-gfad0