From 9e751bb8c0cdf771d34c839cb6591d892b8e62de Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Mar 2017 01:41:48 -0800 Subject: 3761 --- html/089scenario_filesystem.cc.html | 223 ++++++++++++++++++------------------ 1 file changed, 112 insertions(+), 111 deletions(-) (limited to 'html/089scenario_filesystem.cc.html') diff --git a/html/089scenario_filesystem.cc.html b/html/089scenario_filesystem.cc.html index e4128820..1bf75454 100644 --- a/html/089scenario_filesystem.cc.html +++ b/html/089scenario_filesystem.cc.html @@ -15,7 +15,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color a { text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.Constant { color: #00a0a0; } +.Conceal { color: #4e4e4e; } .Special { color: #c00000; } .muScenario { color: #00af00; } .Comment { color: #9090ff; } @@ -23,6 +23,7 @@ a:hover { text-decoration: underline; } .LineNr { color: #444444; } .Identifier { color: #c0a020; } .Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } +.Constant { color: #00a0a0; } .cSpecial { color: #008000; } --> @@ -67,16 +68,16 @@ if ('onhashchange' in window) { 7 scenario simple-filesystem [ 8 local-scope 9 assume-resources [ - 10 # file 'a' containing two lines of data - 11 [a] <- [ - 12 |a bc| - 13 |de f| - 14 ] - 15 # directory 'b' containing two files, 'c' and 'd' - 16 [b/c] <- [] - 17 [b/d] <- [ - 18 |xyz| - 19 ] + 10 ¦ # file 'a' containing two lines of data + 11 ¦ [a] <- [ + 12 ¦ ¦ |a bc| + 13 ¦ ¦ |de f| + 14 ¦ ] + 15 ¦ # directory 'b' containing two files, 'c' and 'd' + 16 ¦ [b/c] <- [] + 17 ¦ [b/d] <- [ + 18 ¦ ¦ |xyz| + 19 ¦ ] 20 ] 21 data:&:@:resource <- get *resources, data:offset 22 file1:resource <- index *data, 0 @@ -95,14 +96,14 @@ if ('onhashchange' in window) { 35 file3-contents:text <- get file3, contents:offset 36 60:@:char/raw <- copy *file3-contents 37 memory-should-contain [ - 38 10:array:character <- [a] - 39 100:array:character <- [a bc + 38 ¦ 10:array:character <- [a] + 39 ¦ 100:array:character <- [a bc 40 de f 41 ] - 42 30:array:character <- [b/c] - 43 40:array:character <- [] - 44 50:array:character <- [b/d] - 45 60:array:character <- [xyz + 42 ¦ 30:array:character <- [b/c] + 43 ¦ 40:array:character <- [] + 44 ¦ 50:array:character <- [b/d] + 45 ¦ 60:array:character <- [xyz 46 ] 47 ] 48 ] @@ -111,11 +112,11 @@ if ('onhashchange' in window) { 51 scenario escaping-file-contents [ 52 local-scope 53 assume-resources [ - 54 # file 'a' containing a '|' - 55 # need to escape '\' once for each block - 56 [a] <- [ - 57 |x\\\\|yz| - 58 ] + 54 ¦ # file 'a' containing a '|' + 55 ¦ # need to escape '\' once for each block + 56 ¦ [a] <- [ + 57 ¦ ¦ |x\\\\|yz| + 58 ¦ ] 59 ] 60 data:&:@:resource <- get *resources, data:offset 61 file1:resource <- index *data, 0 @@ -124,8 +125,8 @@ if ('onhashchange' in window) { 64 file1-contents:text <- get file1, contents:offset 65 20:@:char/raw <- copy *file1-contents 66 memory-should-contain [ - 67 10:array:character <- [a] - 68 20:array:character <- [x|yz + 67 ¦ 10:array:character <- [a] + 68 ¦ 20:array:character <- [x|yz 69 ] 70 ] 71 ] @@ -171,60 +172,60 @@ if ('onhashchange' in window) { 111 istringstream in(data); 112 in >> std::noskipws; 113 while (true) { -114 if (!has_data(in)) break; -115 skip_whitespace_and_comments(in); -116 if (!has_data(in)) break; -117 string filename = next_word(in); -118 if (filename.empty()) { -119 assert(!has_data(in)); -120 raise << "incomplete 'resources' block at end of file (0)\n" << end(); -121 return; -122 } -123 if (*filename.begin() != '[') { -124 raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end(); -125 break; -126 } -127 if (*filename.rbegin() != ']') { -128 raise << caller << ": assume-resources: filename '" << filename << "' must end with a ']'\n" << end(); -129 break; -130 } -131 filename.erase(0, 1); -132 filename.erase(SIZE(filename)-1); -133 if (!has_data(in)) { -134 raise << caller << ": assume-resources: no data for filename '" << filename << "'\n" << end(); -135 break; -136 } -137 string arrow = next_word(in); -138 if (arrow.empty()) { -139 assert(!has_data(in)); -140 raise << "incomplete 'resources' block at end of file (1)\n" << end(); -141 return; -142 } -143 if (arrow != "<-") { -144 raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end(); -145 break; -146 } -147 if (!has_data(in)) { -148 raise << caller << ": assume-resources: no data for filename '" << filename << "' after '<-'\n" << end(); -149 break; -150 } -151 string contents = next_word(in); -152 if (contents.empty()) { -153 assert(!has_data(in)); -154 raise << "incomplete 'resources' block at end of file (2)\n" << end(); -155 return; -156 } -157 if (*contents.begin() != '[') { -158 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end(); -159 break; -160 } -161 if (*contents.rbegin() != ']') { -162 raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must end with a ']'\n" << end(); -163 break; -164 } -165 contents.erase(0, 1); -166 contents.erase(SIZE(contents)-1); -167 put(out, filename, munge_resources_contents(contents, filename, caller)); +114 ¦ if (!has_data(in)) break; +115 ¦ skip_whitespace_and_comments(in); +116 ¦ if (!has_data(in)) break; +117 ¦ string filename = next_word(in); +118 ¦ if (filename.empty()) { +119 ¦ ¦ assert(!has_data(in)); +120 ¦ ¦ raise << "incomplete 'resources' block at end of file (0)\n" << end(); +121 ¦ ¦ return; +122 ¦ } +123 ¦ if (*filename.begin() != '[') { +124 ¦ ¦ raise << caller << ": assume-resources: filename '" << filename << "' must begin with a '['\n" << end(); +125 ¦ ¦ break; +126 ¦ } +127 ¦ if (*filename.rbegin() != ']') { +128 ¦ ¦ raise << caller << ": assume-resources: filename '" << filename << "' must end with a ']'\n" << end(); +129 ¦ ¦ break; +130 ¦ } +131 ¦ filename.erase(0, 1); +132 ¦ filename.erase(SIZE(filename)-1); +133 ¦ if (!has_data(in)) { +134 ¦ ¦ raise << caller << ": assume-resources: no data for filename '" << filename << "'\n" << end(); +135 ¦ ¦ break; +136 ¦ } +137 ¦ string arrow = next_word(in); +138 ¦ if (arrow.empty()) { +139 ¦ ¦ assert(!has_data(in)); +140 ¦ ¦ raise << "incomplete 'resources' block at end of file (1)\n" << end(); +141 ¦ ¦ return; +142 ¦ } +143 ¦ if (arrow != "<-") { +144 ¦ ¦ raise << caller << ": assume-resources: expected '<-' after filename '" << filename << "' but got '" << arrow << "'\n" << end(); +145 ¦ ¦ break; +146 ¦ } +147 ¦ if (!has_data(in)) { +148 ¦ ¦ raise << caller << ": assume-resources: no data for filename '" << filename << "' after '<-'\n" << end(); +149 ¦ ¦ break; +150 ¦ } +151 ¦ string contents = next_word(in); +152 ¦ if (contents.empty()) { +153 ¦ ¦ assert(!has_data(in)); +154 ¦ ¦ raise << "incomplete 'resources' block at end of file (2)\n" << end(); +155 ¦ ¦ return; +156 ¦ } +157 ¦ if (*contents.begin() != '[') { +158 ¦ ¦ raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must begin with a '['\n" << end(); +159 ¦ ¦ break; +160 ¦ } +161 ¦ if (*contents.rbegin() != ']') { +162 ¦ ¦ raise << caller << ": assume-resources: file contents '" << contents << "' for filename '" << filename << "' must end with a ']'\n" << end(); +163 ¦ ¦ break; +164 ¦ } +165 ¦ contents.erase(0, 1); +166 ¦ contents.erase(SIZE(contents)-1); +167 ¦ put(out, filename, munge_resources_contents(contents, filename, caller)); 168 } 169 } 170 @@ -235,29 +236,29 @@ if ('onhashchange' in window) { 175 skip_whitespace_and_comments(in); 176 ostringstream out; 177 while (true) { -178 if (!has_data(in)) break; -179 skip_whitespace(in); -180 if (!has_data(in)) break; -181 if (in.peek() != '|') { -182 raise << caller << ": assume-resources: file contents for filename '" << filename << "' must be delimited in '|'s\n" << end(); -183 break; -184 } -185 in.get(); // skip leading '|' -186 string line; -187 getline(in, line); -188 for (int i = 0; i < SIZE(line); ++i) { -189 if (line.at(i) == '|') break; -190 if (line.at(i) == '\\') { -191 ++i; // skip -192 if (i == SIZE(line)) { -193 raise << caller << ": assume-resources: file contents can't end a line with '\\'\n" << end(); -194 break; -195 } -196 } -197 out << line.at(i); -198 } -199 // todo: some way to represent a file without a final newline -200 out << '\n'; +178 ¦ if (!has_data(in)) break; +179 ¦ skip_whitespace(in); +180 ¦ if (!has_data(in)) break; +181 ¦ if (in.peek() != '|') { +182 ¦ ¦ raise << caller << ": assume-resources: file contents for filename '" << filename << "' must be delimited in '|'s\n" << end(); +183 ¦ ¦ break; +184 ¦ } +185 ¦ in.get(); // skip leading '|' +186 ¦ string line; +187 ¦ getline(in, line); +188 ¦ for (int i = 0; i < SIZE(line); ++i) { +189 ¦ ¦ if (line.at(i) == '|') break; +190 ¦ ¦ if (line.at(i) == '\\') { +191 ¦ ¦ ¦ ++i; // skip +192 ¦ ¦ ¦ if (i == SIZE(line)) { +193 ¦ ¦ ¦ ¦ raise << caller << ": assume-resources: file contents can't end a line with '\\'\n" << end(); +194 ¦ ¦ ¦ ¦ break; +195 ¦ ¦ ¦ } +196 ¦ ¦ } +197 ¦ ¦ out << line.at(i); +198 ¦ } +199 ¦ // todo: some way to represent a file without a final newline +200 ¦ out << '\n'; 201 } 202 return out.str(); 203 } @@ -266,16 +267,16 @@ if ('onhashchange' in window) { 206 int resources_data_address = allocate(SIZE(contents)*2 + /*array length*/1); 207 int curr = resources_data_address + /*skip refcount and length*/2; 208 for (map<string, string>::const_iterator p = contents.begin(); p != contents.end(); ++p) { -209 put(Memory, curr, new_mu_text(p->first)); -210 trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); -211 put(Memory, get(Memory, curr), 1); -212 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); -213 ++curr; -214 put(Memory, curr, new_mu_text(p->second)); -215 trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end(); -216 put(Memory, get(Memory, curr), 1); -217 trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); -218 ++curr; +209 ¦ put(Memory, curr, new_mu_text(p->first)); +210 ¦ trace(9999, "mem") << "storing file name " << get(Memory, curr) << " in location " << curr << end(); +211 ¦ put(Memory, get(Memory, curr), 1); +212 ¦ trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); +213 ¦ ++curr; +214 ¦ put(Memory, curr, new_mu_text(p->second)); +215 ¦ trace(9999, "mem") << "storing file contents " << get(Memory, curr) << " in location " << curr << end(); +216 ¦ put(Memory, get(Memory, curr), 1); +217 ¦ trace(9999, "mem") << "storing refcount 1 in location " << get(Memory, curr) << end(); +218 ¦ ++curr; 219 } 220 curr = resources_data_address+/*skip refcount*/1; 221 put(Memory, curr, SIZE(contents)); // size of array -- cgit 1.4.1-2-gfad0