From d44123cabaa730c778a0e2644c75dbfba6a7ab30 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 12 Jun 2015 22:34:45 -0700 Subject: 1556 --- html/061channel.mu.html | 94 ++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'html/061channel.mu.html') diff --git a/html/061channel.mu.html b/html/061channel.mu.html index e9d5a8f9..4122d241 100644 --- a/html/061channel.mu.html +++ b/html/061channel.mu.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> @@ -68,7 +68,7 @@ container channel [ # result:address:channel <- init-channel capacity:number recipe init-channel [ - default-space:address:array:location <- new location:type, 30:literal + default-space:address:array:location <- new location:type, 30:literal # result = new channel result:address:channel <- new channel:type # result.first-full = 0 @@ -78,22 +78,22 @@ container channel [ free:address:number <- get-address result:address:channel/deref, first-free:offset free:address:number/deref <- copy 0:literal # result.data = new location[ingredient+1] - capacity:number <- next-ingredient + capacity:number <- next-ingredient capacity:number <- add capacity:number, 1:literal # unused slot for 'full?' below dest:address:address:array:location <- get-address result:address:channel/deref, data:offset dest:address:address:array:location/deref <- new location:type, capacity:number - reply result:address:channel + reply result:address:channel ] # chan:address:channel <- write chan:address:channel, val:location recipe write [ - default-space:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient - val:location <- next-ingredient + default-space:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient + val:location <- next-ingredient { # block if chan is full full:boolean <- channel-full? chan:address:channel - break-unless full:boolean + break-unless full:boolean full-address:address:number <- get-address chan:address:channel/deref, first-full:offset wait-for-location full-address:address:number/deref } @@ -108,20 +108,20 @@ container channel [ # wrap free around to 0 if necessary len:number <- length circular-buffer:address:array:location/deref at-end?:boolean <- greater-or-equal free:address:number/deref, len:number - break-unless at-end?:boolean + break-unless at-end?:boolean free:address:number/deref <- copy 0:literal } - reply chan:address:channel/same-as-ingredient:0 + reply chan:address:channel/same-as-ingredient:0 ] # result:location, chan:address:channel <- read chan:address:channel recipe read [ - default-space:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient + default-space:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient { # block if chan is empty empty:boolean <- channel-empty? chan:address:channel - break-unless empty:boolean + break-unless empty:boolean free-address:address:number <- get-address chan:address:channel/deref, first-free:offset wait-for-location free-address:address:number/deref } @@ -135,21 +135,21 @@ container channel [ # wrap full around to 0 if necessary len:number <- length circular-buffer:address:array:location/deref at-end?:boolean <- greater-or-equal full:address:number/deref, len:number - break-unless at-end?:boolean + break-unless at-end?:boolean full:address:number/deref <- copy 0:literal } - reply result:location, chan:address:channel/same-as-ingredient:0 + reply result:location, chan:address:channel/same-as-ingredient:0 ] recipe clear-channel [ - default-space:address:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient + default-space:address:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient { empty?:boolean <- channel-empty? chan:address:channel - break-if empty?:boolean + break-if empty?:boolean _, chan:address:channel <- read chan:address:channel } - reply chan:address:channel/same-as-ingredient:0 + reply chan:address:channel/same-as-ingredient:0 ] scenario channel-initialization [ @@ -220,20 +220,20 @@ container channel [ # An empty channel has first-empty and first-full both at the same value. recipe channel-empty? [ - default-space:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient + default-space:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient # return chan.first-full == chan.first-free full:number <- get chan:address:channel/deref, first-full:offset free:number <- get chan:address:channel/deref, first-free:offset result:boolean <- equal full:number, free:number - reply result:boolean + reply result:boolean ] # A full channel has first-empty just before first-full, wasting one slot. # (Other alternatives: https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction) recipe channel-full? [ - default-space:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient + default-space:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient # tmp = chan.first-free + 1 tmp:number <- get chan:address:channel/deref, first-free:offset tmp:number <- add tmp:number, 1:literal @@ -241,22 +241,22 @@ container channel [ # if tmp == chan.capacity, tmp = 0 len:number <- channel-capacity chan:address:channel at-end?:boolean <- greater-or-equal tmp:number, len:number - break-unless at-end?:boolean + break-unless at-end?:boolean tmp:number <- copy 0:literal } # return chan.first-full == tmp full:number <- get chan:address:channel/deref, first-full:offset result:boolean <- equal full:number, tmp:number - reply result:boolean + reply result:boolean ] # result:number <- channel-capacity chan:address:channel recipe channel-capacity [ - default-space:address:array:location <- new location:type, 30:literal - chan:address:channel <- next-ingredient + default-space:address:array:location <- new location:type, 30:literal + chan:address:channel <- next-ingredient q:address:array:location <- get chan:address:channel/deref, data:offset result:number <- length q:address:array:location/deref - reply result:number + reply result:number ] scenario channel-new-empty-not-full [ @@ -314,23 +314,23 @@ container channel [ # helper for channels of characters in particular # out:address:channel <- buffer-lines in:address:channel, out:address:channel recipe buffer-lines [ - default-space:address:address:array:location <- new location:type, 30:literal + default-space:address:address:array:location <- new location:type, 30:literal #? $print [buffer-lines: aaa #? ] - in:address:channel <- next-ingredient - out:address:channel <- next-ingredient + in:address:channel <- next-ingredient + out:address:channel <- next-ingredient # repeat forever { line:address:buffer <- init-buffer, 30:literal # read characters from 'in' until newline, copy into line { - +next-character + +next-character c:character, in:address:channel <- read in:address:channel # drop a character on backspace { # special-case: if it's a backspace backspace?:boolean <- equal c:character, 8:literal - break-unless backspace?:boolean + break-unless backspace?:boolean # drop previous character #? return-to-console #? 2 #? $print [backspace! #? 1 @@ -338,7 +338,7 @@ container channel [ { buffer-length:address:number <- get-address line:address:buffer/deref, length:offset buffer-empty?:boolean <- equal buffer-length:address:number/deref, 0:literal - break-if buffer-empty?:boolean + break-if buffer-empty?:boolean #? $print [before: ], buffer-length:address:number/deref, [ #? ] #? 1 buffer-length:address:number/deref <- subtract buffer-length:address:number/deref, 1:literal @@ -347,18 +347,18 @@ container channel [ } #? $exit #? 2 # and don't append this one - loop +next-character:label + loop +next-character:label } # append anything else #? $print [buffer-lines: appending ], c:character, [ #? ] line:address:buffer <- buffer-append line:address:buffer, c:character line-done?:boolean <- equal c:character, 10:literal/newline - break-if line-done?:boolean + break-if line-done?:boolean # stop buffering on eof (currently only generated by fake keyboard) empty-fake-keyboard?:boolean <- equal c:character, 0:literal/eof - break-if empty-fake-keyboard?:boolean - loop + break-if empty-fake-keyboard?:boolean + loop } #? return-to-console #? 1 # copy line into 'out' @@ -369,19 +369,19 @@ container channel [ max:number <- get line:address:buffer/deref, length:offset { done?:boolean <- greater-or-equal i:number, max:number - break-if done?:boolean + break-if done?:boolean c:character <- index line-contents:address:array:character/deref, i:number out:address:channel <- write out:address:channel, c:character #? $print [writing ], i:number, [: ], c:character, [ #? ] #? 1 i:number <- add i:number, 1:literal - loop + loop } #? $dump-trace #? 1 #? $exit #? 1 - loop + loop } - reply out:address:channel/same-as-ingredient:1 + reply out:address:channel/same-as-ingredient:1 ] scenario buffer-lines-blocks-until-newline [ @@ -403,14 +403,14 @@ F buffer-lines-blocks-until-newline: channel should be empty <- channel-empty? 2:address:channel/buffered-stdin assert 6:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty after writing 'a'] +F buffer-lines-blocks-until-newline: channel should be empty after writing 'a'] # write 'b' 1:address:channel <- write 1:address:channel, 98:literal/b restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine 7:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 7:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty after writing 'b'] +F buffer-lines-blocks-until-newline: channel should be empty after writing 'b'] # write newline 1:address:channel <- write 1:address:channel, 10:literal/newline restart 4:number/buffer-routine -- cgit 1.4.1-2-gfad0