diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 10:32:57 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 10:32:57 -0700 |
commit | 80df524b566a708551f752ce8b82e21738591651 (patch) | |
tree | c56f845159bd273420141dab4cfb91b437ca63a6 | |
parent | 17622b5a397093f43423e210b5bd47ae19eb4454 (diff) | |
download | mu-80df524b566a708551f752ce8b82e21738591651.tar.gz |
3388
-rw-r--r-- | 081print.mu | 54 | ||||
-rw-r--r-- | 084console.mu | 18 | ||||
-rw-r--r-- | 086scenario_console_test.mu | 8 | ||||
-rw-r--r-- | 088file.mu | 18 | ||||
-rw-r--r-- | 090scenario_filesystem_test.mu | 12 | ||||
-rw-r--r-- | 101run_sandboxed.cc | 2 |
6 files changed, 56 insertions, 56 deletions
diff --git a/081print.mu b/081print.mu index c8d39036..8f63d90b 100644 --- a/081print.mu +++ b/081print.mu @@ -35,7 +35,7 @@ def clear-screen screen:address:screen -> screen:address:screen [ max:num <- length *buf i:num <- copy 0 { - done?:boolean <- greater-or-equal i, max + done?:bool <- greater-or-equal i, max break-if done? curr:screen-cell <- merge 0/empty, 7/white *buf <- put-index *buf, i, curr @@ -61,7 +61,7 @@ def sync-screen screen:address:screen -> screen:address:screen [ # do nothing for fake screens ] -def fake-screen-is-empty? screen:address:screen -> result:boolean [ +def fake-screen-is-empty? screen:address:screen -> result:bool [ local-scope load-ingredients return-unless screen, 1/true @@ -69,7 +69,7 @@ def fake-screen-is-empty? screen:address:screen -> result:boolean [ i:num <- copy 0 len:num <- length *buf { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? curr:screen-cell <- index *buf, i curr-contents:char <- get curr, contents:offset @@ -84,13 +84,13 @@ def fake-screen-is-empty? screen:address:screen -> result:boolean [ def print screen:address:screen, c:char -> screen:address:screen [ local-scope load-ingredients - color:num, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 7/white } - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? @@ -106,7 +106,7 @@ def print screen:address:screen, c:char -> screen:address:screen [ height:num <- get *screen, num-rows:offset # if cursor is out of bounds, silently exit row:num <- get *screen, cursor-row:offset - legal?:boolean <- greater-or-equal row, 0 + legal?:bool <- greater-or-equal row, 0 return-unless legal? legal? <- lesser-than row, height return-unless legal? @@ -118,12 +118,12 @@ def print screen:address:screen, c:char -> screen:address:screen [ #? $print [print-character (], row, [, ], column, [): ], c, 10/newline # special-case: newline { - newline?:boolean <- equal c, 10/newline + newline?:bool <- equal c, 10/newline break-unless newline? { # unless cursor is already at bottom bottom:num <- subtract height, 1 - at-bottom?:boolean <- greater-or-equal row, bottom + at-bottom?:bool <- greater-or-equal row, bottom break-if at-bottom? # move it to the next row column <- copy 0 @@ -140,11 +140,11 @@ def print screen:address:screen, c:char -> screen:address:screen [ len:num <- length *buf # special-case: backspace { - backspace?:boolean <- equal c, 8 + backspace?:bool <- equal c, 8 break-unless backspace? { # unless cursor is already at left margin - at-left?:boolean <- lesser-or-equal column, 0 + at-left?:bool <- lesser-or-equal column, 0 break-if at-left? # clear previous location column <- subtract column, 1 @@ -160,7 +160,7 @@ def print screen:address:screen, c:char -> screen:address:screen [ # increment column unless it's already all the way to the right { right:num <- subtract width, 1 - at-right?:boolean <- greater-or-equal column, right + at-right?:bool <- greater-or-equal column, right break-if at-right? column <- add column, 1 *screen <- put *screen, cursor-column:offset, column @@ -369,7 +369,7 @@ def clear-line screen:address:screen -> screen:address:screen [ # space over the entire line { right:num <- subtract width, 1 - done?:boolean <- greater-or-equal column, right + done?:bool <- greater-or-equal column, right break-if done? print screen, space column <- add column, 1 @@ -388,14 +388,14 @@ def clear-line-until screen:address:screen, right:num/inclusive -> screen:addres load-ingredients _, column:num <- cursor-position screen space:char <- copy 32/space - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? bg-color <- copy 0/black } { - done?:boolean <- greater-than column, right + done?:bool <- greater-than column, right break-if done? screen <- print screen, space, 7/white, bg-color # foreground color is mostly unused except if the cursor shows up at this cell column <- add column, 1 @@ -473,7 +473,7 @@ def cursor-down screen:address:screen -> screen:address:screen [ height:num <- get *screen, num-rows:offset row:num <- get *screen, cursor-row:offset max:num <- subtract height, 1 - at-bottom?:boolean <- greater-or-equal row, max + at-bottom?:bool <- greater-or-equal row, max break-if at-bottom? row <- add row, 1 *screen <- put *screen, cursor-row:offset, row @@ -493,7 +493,7 @@ def cursor-up screen:address:screen -> screen:address:screen [ { # decrement row unless it's already all the way up row:num <- get *screen, cursor-row:offset - at-top?:boolean <- lesser-or-equal row, 0 + at-top?:bool <- lesser-or-equal row, 0 break-if at-top? row <- subtract row, 1 *screen <- put *screen, cursor-row:offset, row @@ -515,7 +515,7 @@ def cursor-right screen:address:screen -> screen:address:screen [ width:num <- get *screen, num-columns:offset column:num <- get *screen, cursor-column:offset max:num <- subtract width, 1 - at-bottom?:boolean <- greater-or-equal column, max + at-bottom?:bool <- greater-or-equal column, max break-if at-bottom? column <- add column, 1 *screen <- put *screen, cursor-column:offset, column @@ -535,7 +535,7 @@ def cursor-left screen:address:screen -> screen:address:screen [ { # decrement column unless it's already all the way to the left column:num <- get *screen, cursor-column:offset - at-top?:boolean <- lesser-or-equal column, 0 + at-top?:bool <- lesser-or-equal column, 0 break-if at-top? column <- subtract column, 1 *screen <- put *screen, cursor-column:offset, column @@ -647,13 +647,13 @@ def show-screen screen:address:screen -> screen:address:screen [ def print screen:address:screen, s:text -> screen:address:screen [ local-scope load-ingredients - color:num, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 7/white } - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? @@ -662,7 +662,7 @@ def print screen:address:screen, s:text -> screen:address:screen [ len:num <- length *s i:num <- copy 0 { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? c:char <- index *s, i print screen, c, color, bg-color @@ -696,13 +696,13 @@ scenario print-text-stops-at-right-margin [ def print-integer screen:address:screen, n:num -> screen:address:screen [ local-scope load-ingredients - color:num, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 7/white } - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? @@ -717,13 +717,13 @@ def print-integer screen:address:screen, n:num -> screen:address:screen [ def print screen:address:screen, n:num -> screen:address:screen [ local-scope load-ingredients - color:num, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 7/white } - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? @@ -736,13 +736,13 @@ def print screen:address:screen, n:num -> screen:address:screen [ def print screen:address:screen, n:address:_elem -> screen:address:screen [ local-scope load-ingredients - color:num, color-found?:boolean <- next-ingredient + color:num, color-found?:bool <- next-ingredient { # default color to white break-if color-found? color <- copy 7/white } - bg-color:num, bg-color-found?:boolean <- next-ingredient + bg-color:num, bg-color-found?:bool <- next-ingredient { # default bg-color to black break-if bg-color-found? diff --git a/084console.mu b/084console.mu index 9d5da4e3..ffc07486 100644 --- a/084console.mu +++ b/084console.mu @@ -32,7 +32,7 @@ def new-fake-console events:address:array:event -> result:address:console [ *result <- put *result, events:offset, events ] -def read-event console:address:console -> result:event, console:address:console, found?:boolean, quit?:boolean [ +def read-event console:address:console -> result:event, console:address:console, found?:bool, quit?:bool [ local-scope load-ingredients { @@ -41,7 +41,7 @@ def read-event console:address:console -> result:event, console:address:console, buf:address:array:event <- get *console, events:offset { max:num <- length *buf - done?:boolean <- greater-or-equal current-event-index, max + done?:bool <- greater-or-equal current-event-index, max break-unless done? dummy:address:event <- new event:type return *dummy, console/same-as-ingredient:0, 1/found, 1/quit @@ -52,20 +52,20 @@ def read-event console:address:console -> result:event, console:address:console, return result, console/same-as-ingredient:0, 1/found, 0/quit } switch # real event source is infrequent; avoid polling it too much - result:event, found?:boolean <- check-for-interaction + result:event, found?:bool <- check-for-interaction return result, console/same-as-ingredient:0, found?, 0/quit ] # variant of read-event for just keyboard events. Discards everything that # isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get # newlines, tabs, ctrl-d.. -def read-key console:address:console -> result:char, console:address:console, found?:boolean, quit?:boolean [ +def read-key console:address:console -> result:char, console:address:console, found?:bool, quit?:bool [ local-scope load-ingredients - x:event, console, found?:boolean, quit?:boolean <- read-event console + x:event, console, found?:bool, quit?:bool <- read-event console return-if quit?, 0, console/same-as-ingredient:0, found?, quit? return-unless found?, 0, console/same-as-ingredient:0, found?, quit? - c:char, converted?:boolean <- maybe-convert x, text:variant + c:char, converted?:bool <- maybe-convert x, text:variant return-unless converted?, 0, console/same-as-ingredient:0, 0/found, 0/quit return c, console/same-as-ingredient:0, 1/found, 0/quit ] @@ -74,7 +74,7 @@ def send-keys-to-channel console:address:console, chan:address:sink:char, screen local-scope load-ingredients { - c:char, console, found?:boolean, quit?:boolean <- read-key console + c:char, console, found?:bool, quit?:bool <- read-key console loop-unless found? break-if quit? assert c, [invalid event, expected text] @@ -89,13 +89,13 @@ def wait-for-event console:address:console -> console:address:console [ local-scope load-ingredients { - _, console, found?:boolean <- read-event console + _, console, found?:bool <- read-event console loop-unless found? } ] # use this helper to skip rendering if there's lots of other events queued up -def has-more-events? console:address:console -> result:boolean [ +def has-more-events? console:address:console -> result:bool [ local-scope load-ingredients { diff --git a/086scenario_console_test.mu b/086scenario_console_test.mu index 3a598322..1b393c63 100644 --- a/086scenario_console_test.mu +++ b/086scenario_console_test.mu @@ -7,10 +7,10 @@ scenario read-key-in-mu [ type [abc] ] run [ - 1:char, console:address:console, 2:boolean <- read-key console:address:console - 3:char, console:address:console, 4:boolean <- read-key console:address:console - 5:char, console:address:console, 6:boolean <- read-key console:address:console - 7:char, console:address:console, 8:boolean <- read-key console:address:console + 1:char, console:address:console, 2:bool <- read-key console:address:console + 3:char, console:address:console, 4:bool <- read-key console:address:console + 5:char, console:address:console, 6:bool <- read-key console:address:console + 7:char, console:address:console, 8:bool <- read-key console:address:console ] memory-should-contain [ 1 <- 97 # 'a' diff --git a/088file.mu b/088file.mu index 63ab54f7..b118b8b8 100644 --- a/088file.mu +++ b/088file.mu @@ -27,12 +27,12 @@ def start-reading fs:address:filesystem, filename:text -> contents:address:sourc data:address:array:file-mapping <- get *fs, data:offset len:num <- length *data { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? tmp:file-mapping <- index *data, i i <- add i, 1 curr-filename:text <- get tmp, name:offset - found?:boolean <- equal filename, curr-filename + found?:bool <- equal filename, curr-filename loop-unless found? contents:address:source:char, sink:address:sink:char <- new-channel 30 curr-contents:text <- get tmp, contents:offset @@ -46,7 +46,7 @@ def transmit-from-file file:num, sink:address:sink:char -> sink:address:sink:cha local-scope load-ingredients { - c:char, eof?:boolean <- $read-from-file file + c:char, eof?:bool <- $read-from-file file break-if eof? sink <- write sink, c loop @@ -61,7 +61,7 @@ def transmit-from-text contents:text, sink:address:sink:char -> sink:address:sin i:num <- copy 0 len:num <- length *contents { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? c:char <- index *contents, i sink <- write sink, c @@ -92,7 +92,7 @@ def transmit-to-file file:num, source:address:source:char -> source:address:sour local-scope load-ingredients { - c:char, done?:boolean, source <- read source + c:char, done?:bool, source <- read source break-if done? $write-to-file file, c loop @@ -106,7 +106,7 @@ def transmit-to-fake-file fs:address:filesystem, filename:text, source:address:s # compute new file contents buf:address:buffer <- new-buffer 30 { - c:char, done?:boolean, source <- read source + c:char, done?:bool, source <- read source break-if done? buf <- append buf, c loop @@ -120,11 +120,11 @@ def transmit-to-fake-file fs:address:filesystem, filename:text, source:address:s i:num <- copy 0 len:num <- length *data { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? tmp:file-mapping <- index *data, i curr-filename <- get tmp, name:offset - found?:boolean <- equal filename, curr-filename + found?:bool <- equal filename, curr-filename loop-unless found? put-index *data, i, new-file-mapping reply @@ -136,7 +136,7 @@ def transmit-to-fake-file fs:address:filesystem, filename:text, source:address:s # copy over old files i:num <- copy 0 { - done?:boolean <- greater-or-equal i, len + done?:bool <- greater-or-equal i, len break-if done? tmp:file-mapping <- index *data, i put-index *new-data, i, tmp diff --git a/090scenario_filesystem_test.mu b/090scenario_filesystem_test.mu index 2a47c18d..caaecbd2 100644 --- a/090scenario_filesystem_test.mu +++ b/090scenario_filesystem_test.mu @@ -12,7 +12,7 @@ scenario read-from-fake-file [ 2:char/raw <- read contents 3:char/raw <- read contents 4:char/raw <- read contents - _, 5:boolean/raw <- read contents + _, 5:bool/raw <- read contents memory-should-contain [ 1 <- 120 # x 2 <- 121 # y @@ -32,7 +32,7 @@ scenario write-to-fake-file [ close sink wait-for-routine writer contents-read-back:text <- slurp filesystem, [a] - 10:boolean/raw <- equal contents-read-back, [xy] + 10:bool/raw <- equal contents-read-back, [xy] memory-should-contain [ 10 <- 1 # file contents read back exactly match what was written ] @@ -49,7 +49,7 @@ scenario write-to-fake-file-that-exists [ close sink wait-for-routine writer contents-read-back:text <- slurp filesystem, [a] - 10:boolean/raw <- equal contents-read-back, [xy] + 10:bool/raw <- equal contents-read-back, [xy] memory-should-contain [ 10 <- 1 # file contents read back exactly match what was written ] @@ -69,9 +69,9 @@ scenario write-to-existing-file-preserves-other-files [ close sink wait-for-routine writer contents-read-back:text <- slurp filesystem, [a] - 10:boolean/raw <- equal contents-read-back, [xy] + 10:bool/raw <- equal contents-read-back, [xy] other-file-contents:text <- slurp filesystem, [b] - 11:boolean/raw <- equal other-file-contents, [bcd + 11:bool/raw <- equal other-file-contents, [bcd ] memory-should-contain [ 10 <- 1 # file contents read back exactly match what was written @@ -85,7 +85,7 @@ def slurp fs:address:filesystem, filename:text -> contents:text [ source:address:source:char <- start-reading fs, filename buf:address:buffer <- new-buffer 30/capacity { - c:char, done?:boolean, source <- read source + c:char, done?:bool, source <- read source break-if done? buf <- append buf, c loop diff --git a/101run_sandboxed.cc b/101run_sandboxed.cc index ab0b1740..3dfeb0da 100644 --- a/101run_sandboxed.cc +++ b/101run_sandboxed.cc @@ -201,7 +201,7 @@ load(string( "instructions-run:num <- number-of-instructions routine-id\n" + "stash instructions-run [instructions run]\n" + "sandbox-state:num <- routine-state routine-id\n" + - "completed?:boolean <- equal sandbox-state, 1/completed\n" + + "completed?:bool <- equal sandbox-state, 1/completed\n" + "output:text <- $most-recent-products\n" + "errors:text <- save-errors\n" + "stashes:text <- save-app-trace\n" + |