From 6c52e24e2996a77aa6297b26159003d503aef8a0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 18 Apr 2017 11:33:33 -0700 Subject: 3830 - crosslink shape-shifting containers in html --- html/088file.mu.html | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'html/088file.mu.html') diff --git a/html/088file.mu.html b/html/088file.mu.html index 794e9592..42c94671 100644 --- a/html/088file.mu.html +++ b/html/088file.mu.html @@ -79,7 +79,7 @@ if ('onhashchange' in window) { 18 contents:text 19 ] 20 - 21 def start-reading resources:&:resources, filename:text -> contents:&:source:char, error?:bool [ + 21 def start-reading resources:&:resources, filename:text -> contents:&:source:char, error?:bool [ 22 local-scope 23 load-ingredients 24 error? <- copy 0/false @@ -92,18 +92,18 @@ if ('onhashchange' in window) { 31 # real file system 32 file:num <- $open-file-for-reading filename 33 return-unless file, 0/contents, 1/error? - 34 contents:&:source:char, sink:&:sink:char <- new-channel 30 - 35 start-running receive-from-file file, sink + 34 contents:&:source:char, sink:&:sink:char <- new-channel 30 + 35 start-running receive-from-file file, sink 36 ] 37 38 def slurp resources:&:resources, filename:text -> contents:text, error?:bool [ 39 local-scope 40 load-ingredients - 41 source:&:source:char, error?:bool <- start-reading resources, filename + 41 source:&:source:char, error?:bool <- start-reading resources, filename 42 return-if error?, 0/contents - 43 buf:&:buffer:char <- new-buffer 30/capacity + 43 buf:&:buffer:char <- new-buffer 30/capacity 44 { - 45 ¦ c:char, done?:bool, source <- read source + 45 ¦ c:char, done?:bool, source <- read source 46 ¦ break-if done? 47 ¦ buf <- append buf, c 48 ¦ loop @@ -111,7 +111,7 @@ if ('onhashchange' in window) { 50 contents <- buffer-to-array buf 51 ] 52 - 53 def start-reading-from-fake-resource resources:&:resources, resource:text -> contents:&:source:char, error?:bool [ + 53 def start-reading-from-fake-resource resources:&:resources, resource:text -> contents:&:source:char, error?:bool [ 54 local-scope 55 load-ingredients 56 error? <- copy 0/no-error @@ -126,28 +126,28 @@ if ('onhashchange' in window) { 65 ¦ curr-resource:text <- get tmp, name:offset 66 ¦ found?:bool <- equal resource, curr-resource 67 ¦ loop-unless found? - 68 ¦ contents:&:source:char, sink:&:sink:char <- new-channel 30 + 68 ¦ contents:&:source:char, sink:&:sink:char <- new-channel 30 69 ¦ curr-contents:text <- get tmp, contents:offset - 70 ¦ start-running receive-from-text curr-contents, sink + 70 ¦ start-running receive-from-text curr-contents, sink 71 ¦ return 72 } 73 return 0/not-found, 1/error 74 ] 75 - 76 def receive-from-file file:num, sink:&:sink:char -> sink:&:sink:char [ + 76 def receive-from-file file:num, sink:&:sink:char -> sink:&:sink:char [ 77 local-scope 78 load-ingredients 79 { 80 ¦ c:char, eof?:bool <- $read-from-file file 81 ¦ break-if eof? - 82 ¦ sink <- write sink, c + 82 ¦ sink <- write sink, c 83 ¦ loop 84 } - 85 sink <- close sink + 85 sink <- close sink 86 file <- $close-file file 87 ] 88 - 89 def receive-from-text contents:text, sink:&:sink:char -> sink:&:sink:char [ + 89 def receive-from-text contents:text, sink:&:sink:char -> sink:&:sink:char [ 90 local-scope 91 load-ingredients 92 i:num <- copy 0 @@ -156,22 +156,22 @@ if ('onhashchange' in window) { 95 ¦ done?:bool <- greater-or-equal i, len 96 ¦ break-if done? 97 ¦ c:char <- index *contents, i - 98 ¦ sink <- write sink, c + 98 ¦ sink <- write sink, c 99 ¦ i <- add i, 1 100 ¦ loop 101 } -102 sink <- close sink +102 sink <- close sink 103 ] 104 -105 def start-writing resources:&:resources, filename:text -> sink:&:sink:char, routine-id:num, error?:bool [ +105 def start-writing resources:&:resources, filename:text -> sink:&:sink:char, routine-id:num, error?:bool [ 106 local-scope 107 load-ingredients 108 error? <- copy 0/false -109 source:&:source:char, sink:&:sink:char <- new-channel 30 +109 source:&:source:char, sink:&:sink:char <- new-channel 30 110 { 111 ¦ break-unless resources 112 ¦ # fake file system -113 ¦ routine-id <- start-running transmit-to-fake-resource resources, filename, source +113 ¦ routine-id <- start-running transmit-to-fake-resource resources, filename, source 114 ¦ return 115 } 116 # real file system @@ -182,7 +182,7 @@ if ('onhashchange' in window) { 121 ¦ msg:text <- append [no such file: ] filename 122 ¦ assert file, msg 123 } -124 routine-id <- start-running transmit-to-file file, source +124 routine-id <- start-running transmit-to-file file, source 125 ] 126 127 def dump resources:&:resources, filename:text, contents:text -> resources:&:resources, error?:bool [ @@ -190,7 +190,7 @@ if ('onhashchange' in window) { 129 load-ingredients 130 # todo: really create an empty file 131 return-unless contents, resources, 0/no-error -132 sink-file:&:sink:char, write-routine:num, error?:bool <- start-writing resources, filename +132 sink-file:&:sink:char, write-routine:num, error?:bool <- start-writing resources, filename 133 return-if error? 134 i:num <- copy 0 135 len:num <- length *contents @@ -208,11 +208,11 @@ if ('onhashchange' in window) { 147 wait-for-routine write-routine 148 ] 149 -150 def transmit-to-file file:num, source:&:source:char -> source:&:source:char [ +150 def transmit-to-file file:num, source:&:source:char -> source:&:source:char [ 151 local-scope 152 load-ingredients 153 { -154 ¦ c:char, done?:bool, source <- read source +154 ¦ c:char, done?:bool, source <- read source 155 ¦ break-if done? 156 ¦ $write-to-file file, c 157 ¦ loop @@ -220,15 +220,15 @@ if ('onhashchange' in window) { 159 file <- $close-file file 160 ] 161 -162 def transmit-to-fake-resource resources:&:resources, filename:text, source:&:source:char -> resources:&:resources, source:&:source:char [ +162 def transmit-to-fake-resource resources:&:resources, filename:text, source:&:source:char -> resources:&:resources, source:&:source:char [ 163 local-scope 164 load-ingredients 165 lock:location <- get-location *resources, lock:offset 166 wait-for-reset-then-set lock 167 # compute new file contents -168 buf:&:buffer:char <- new-buffer 30 +168 buf:&:buffer:char <- new-buffer 30 169 { -170 ¦ c:char, done?:bool, source <- read source +170 ¦ c:char, done?:bool, source <- read source 171 ¦ break-if done? 172 ¦ buf <- append buf, c 173 ¦ loop -- cgit 1.4.1-2-gfad0