diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/088file.mu.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/088file.mu.html')
-rw-r--r-- | html/088file.mu.html | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/html/088file.mu.html b/html/088file.mu.html index 435e3439..091f18c4 100644 --- a/html/088file.mu.html +++ b/html/088file.mu.html @@ -35,7 +35,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># are thus easier to test.</span> <span class="muData">container</span> filesystem [ - data:address:array:file-mapping + data:&:@:file-mapping ] <span class="muData">container</span> file-mapping [ @@ -43,31 +43,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color contents:text ] -<span class="muRecipe">def</span> start-reading fs:address:filesystem, filename:text<span class="muRecipe"> -> </span>contents:address:source:character [ +<span class="muRecipe">def</span> start-reading fs:&:filesystem, filename:text<span class="muRecipe"> -> </span>contents:&:source:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> fs <span class="Comment"># real file system</span> - file:number<span class="Special"> <- </span>$open-file-for-reading filename + file:num<span class="Special"> <- </span>$open-file-for-reading filename assert file, <span class="Constant">[file not found]</span> - contents:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">30</span> + contents:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> start-running transmit-from-file file, sink <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># fake file system</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - data:address:array:file-mapping<span class="Special"> <- </span>get *fs, <span class="Constant">data:offset</span> - len:number<span class="Special"> <- </span>length *data + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + data:&:@:file-mapping<span class="Special"> <- </span>get *fs, <span class="Constant">data:offset</span> + len:num<span class="Special"> <- </span>length *data <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? tmp:file-mapping<span class="Special"> <- </span>index *data, i i<span class="Special"> <- </span>add i, <span class="Constant">1</span> curr-filename:text<span class="Special"> <- </span>get tmp, <span class="Constant">name:offset</span> - found?:boolean<span class="Special"> <- </span>equal filename, curr-filename + found?:bool<span class="Special"> <- </span>equal filename, curr-filename <span class="muControl">loop-unless</span> found? - contents:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">30</span> + contents:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> curr-contents:text<span class="Special"> <- </span>get tmp, <span class="Constant">contents:offset</span> start-running transmit-from-text curr-contents, sink <span class="muControl">return</span> @@ -75,11 +75,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muControl">return</span> <span class="Constant">0/not-found</span> ] -<span class="muRecipe">def</span> transmit-from-file file:number, sink:address:sink:character<span class="muRecipe"> -> </span>sink:address:sink:character [ +<span class="muRecipe">def</span> transmit-from-file file:num, sink:&:sink:char<span class="muRecipe"> -> </span>sink:&:sink:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - c:character, eof?:boolean<span class="Special"> <- </span>$read-from-file file + c:char, eof?:bool<span class="Special"> <- </span>$read-from-file file <span class="muControl">break-if</span> eof? sink<span class="Special"> <- </span>write sink, c <span class="muControl">loop</span> @@ -88,15 +88,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file<span class="Special"> <- </span>$close-file file ] -<span class="muRecipe">def</span> transmit-from-text contents:text, sink:address:sink:character<span class="muRecipe"> -> </span>sink:address:sink:character [ +<span class="muRecipe">def</span> transmit-from-text contents:text, sink:&:sink:char<span class="muRecipe"> -> </span>sink:&:sink:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:number<span class="Special"> <- </span>length *contents + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *contents <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? - c:character<span class="Special"> <- </span>index *contents, i + c:char<span class="Special"> <- </span>index *contents, i sink<span class="Special"> <- </span>write sink, c i<span class="Special"> <- </span>add i, <span class="Constant">1</span> <span class="muControl">loop</span> @@ -104,14 +104,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color sink<span class="Special"> <- </span>close sink ] -<span class="muRecipe">def</span> start-writing fs:address:filesystem, filename:text<span class="muRecipe"> -> </span>sink:address:sink:character, routine-id:number [ +<span class="muRecipe">def</span> start-writing fs:&:filesystem, filename:text<span class="muRecipe"> -> </span>sink:&:sink:char, routine-id:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">30</span> + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">30</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> fs <span class="Comment"># real file system</span> - file:number<span class="Special"> <- </span>$open-file-for-writing filename + file:num<span class="Special"> <- </span>$open-file-for-writing filename assert file, <span class="Constant">[no such file]</span> routine-id<span class="Special"> <- </span>start-running transmit-to-file file, source <span class="muControl">reply</span> @@ -121,11 +121,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color routine-id<span class="Special"> <- </span>start-running transmit-to-fake-file fs, filename, source ] -<span class="muRecipe">def</span> transmit-to-file file:number, source:address:source:character<span class="muRecipe"> -> </span>source:address:source:character [ +<span class="muRecipe">def</span> transmit-to-file file:num, source:&:source:char<span class="muRecipe"> -> </span>source:&:source:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - c:character, done?:boolean, source<span class="Special"> <- </span>read source + c:char, done?:bool, source<span class="Special"> <- </span>read source <span class="muControl">break-if</span> done? $write-to-file file, c <span class="muControl">loop</span> @@ -133,13 +133,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color file<span class="Special"> <- </span>$close-file file ] -<span class="muRecipe">def</span> transmit-to-fake-file fs:address:filesystem, filename:text, source:address:source:character<span class="muRecipe"> -> </span>fs:address:filesystem, source:address:source:character [ +<span class="muRecipe">def</span> transmit-to-fake-file fs:&:filesystem, filename:text, source:&:source:char<span class="muRecipe"> -> </span>fs:&:filesystem, source:&:source:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute new file contents</span> - buf:address:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> + buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> <span class="Delimiter">{</span> - c:character, done?:boolean, source<span class="Special"> <- </span>read source + c:char, done?:bool, source<span class="Special"> <- </span>read source <span class="muControl">break-if</span> done? buf<span class="Special"> <- </span>append buf, c <span class="muControl">loop</span> @@ -148,28 +148,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color new-file-mapping:file-mapping<span class="Special"> <- </span>merge filename, contents <span class="Comment"># write to filesystem</span> curr-filename:text<span class="Special"> <- </span>copy <span class="Constant">0</span> - data:address:array:file-mapping<span class="Special"> <- </span>get *fs, <span class="Constant">data:offset</span> + data:&:@:file-mapping<span class="Special"> <- </span>get *fs, <span class="Constant">data:offset</span> <span class="Comment"># replace file contents if it already exists</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:number<span class="Special"> <- </span>length *data + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + len:num<span class="Special"> <- </span>length *data <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? tmp:file-mapping<span class="Special"> <- </span>index *data, i curr-filename<span class="Special"> <- </span>get tmp, <span class="Constant">name:offset</span> - found?:boolean<span class="Special"> <- </span>equal filename, curr-filename + found?:bool<span class="Special"> <- </span>equal filename, curr-filename <span class="muControl">loop-unless</span> found? put-index *data, i, new-file-mapping <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># if file didn't already exist, make room for it</span> - new-len:number<span class="Special"> <- </span>add len, <span class="Constant">1</span> - new-data:address:array:file-mapping<span class="Special"> <- </span>new <span class="Constant">file-mapping:type</span>, new-len + new-len:num<span class="Special"> <- </span>add len, <span class="Constant">1</span> + new-data:&:@:file-mapping<span class="Special"> <- </span>new <span class="Constant">file-mapping:type</span>, new-len put *fs, <span class="Constant">data:offset</span>, new-data <span class="Comment"># copy over old files</span> - i:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal i, len + done?:bool<span class="Special"> <- </span>greater-or-equal i, len <span class="muControl">break-if</span> done? tmp:file-mapping<span class="Special"> <- </span>index *data, i put-index *new-data, i, tmp |