diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-06 00:19:03 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-06 00:19:03 -0700 |
commit | 672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9 (patch) | |
tree | 5fa3d82e40137b15dec2941a3446e838ce43d3e5 /html/043space.cc.html | |
parent | 20d1c9057a559ce8db83bbc2787ca91348bcb16f (diff) | |
download | mu-672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9.tar.gz |
1279 - colorized rendering of the source files
Diffstat (limited to 'html/043space.cc.html')
-rw-r--r-- | html/043space.cc.html | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/html/043space.cc.html b/html/043space.cc.html new file mode 100644 index 00000000..c52c5d42 --- /dev/null +++ b/html/043space.cc.html @@ -0,0 +1,169 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>~/Desktop/s/mu/043space.cc.html</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } +body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +* { font-size: 1em; } +.cSpecial { color: #008000; } +.Identifier { color: #008080; } +.SalientComment { color: #00ffff; } +.Constant { color: #008080; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.Special { color: #ff6060; } +.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: Spaces help isolate functions from each other. You can create them at will,</span> +<span class="Comment">//: and all addresses in arguments are implicitly based on the 'default-space'</span> +<span class="Comment">//: (unless they have the /raw property)</span> + +<span class="Delimiter">:(scenario set_default_space)</span> +<span class="Comment"># if default-space is 10, and if an array of 5 locals lies from location 11 to 15 (inclusive),</span> +<span class="Comment"># then location 0 is really location 11, location 1 is really location 12, and so on.</span> +recipe main [ + <span class="Constant">10</span>:integer<span class="Special"> <- </span>copy <span class="Constant">5</span>:literal <span class="Comment"># pretend array; in practice we'll use new</span> + default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>:literal + <span class="Constant">1</span>:integer<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal +] +<span class="traceContains">+mem: storing 23 in location 12</span> + +<span class="Delimiter">:(scenario deref_sidesteps_default_space)</span> +recipe main [ + <span class="Comment"># pretend pointer from outside</span> + <span class="Constant">3</span>:integer<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal + <span class="Comment"># pretend array</span> + <span class="Constant">1000</span>:integer<span class="Special"> <- </span>copy <span class="Constant">5</span>:literal + <span class="Comment"># actual start of this function</span> + default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>:literal + <span class="Constant">1</span>:address:integer<span class="Special"> <- </span>copy <span class="Constant">3</span>:literal + <span class="Constant">8</span>:integer/<span class="Special">raw <- </span>copy <span class="Constant">1</span>:address:integer/deref +] +<span class="traceContains">+mem: storing 34 in location 8</span> + +<span class="Delimiter">:(before "End call Fields")</span> +index_t default_space<span class="Delimiter">;</span> +<span class="Delimiter">:(replace "call(recipe_number r) :running_recipe(r)")</span> +call<span class="Delimiter">(</span>recipe_number r<span class="Delimiter">)</span> :running_recipe<span class="Delimiter">(</span>r<span class="Delimiter">),</span> running_step_index<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> next_ingredient_to_process<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">),</span> default_space<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{}</span> + +<span class="Delimiter">:(replace "reagent r = x" following "reagent canonize(reagent x)")</span> +reagent r = absolutize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> +<span class="Delimiter">:(code)</span> +reagent absolutize<span class="Delimiter">(</span>reagent x<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? if (Recipe_number.find("increment-counter") != Recipe_number.end()) //? 1</span> +<span class="CommentedCode">//? cout << "AAA " << "increment-counter/2: " << Recipe[Recipe_number["increment-counter"]].steps[2].products[0].to_string() << '\n'; //? 1</span> +<span class="CommentedCode">//? cout << "absolutize " << x.to_string() << '\n'; //? 4</span> +<span class="CommentedCode">//? cout << is_raw(x) << '\n'; //? 1</span> + if <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">)</span> || is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> x<span class="Delimiter">;</span> +<span class="CommentedCode">//? cout << "not raw: " << x.to_string() << '\n'; //? 1</span> + assert<span class="Delimiter">(</span>x<span class="Delimiter">.</span>initialized<span class="Delimiter">);</span> + reagent r = x<span class="Delimiter">;</span> + r<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>address<span class="Delimiter">(</span>r<span class="Delimiter">.</span>value<span class="Delimiter">,</span> space_base<span class="Delimiter">(</span>r<span class="Delimiter">)));</span> +<span class="CommentedCode">//? cout << "after absolutize: " << r.value << '\n'; //? 1</span> + r<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> vector<string><span class="Delimiter">()));</span> + assert<span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>r<span class="Delimiter">));</span> + <span class="Identifier">return</span> r<span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "return result" following "reagent deref(reagent x)")</span> +result<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> vector<string><span class="Delimiter">()));</span> + +<span class="SalientComment">//:: fix 'get'</span> + +<span class="Delimiter">:(scenario deref_sidesteps_default_space_in_get)</span> +recipe main [ + <span class="Comment"># pretend pointer to container from outside</span> + <span class="Constant">12</span>:integer<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal + <span class="Constant">13</span>:integer<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal + <span class="Comment"># pretend array</span> + <span class="Constant">1000</span>:integer<span class="Special"> <- </span>copy <span class="Constant">5</span>:literal + <span class="Comment"># actual start of this function</span> + default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>:literal + <span class="Constant">1</span>:address:point<span class="Special"> <- </span>copy <span class="Constant">12</span>:literal + <span class="Constant">9</span>:integer/<span class="Special">raw <- </span>get <span class="Constant">1</span>:address:point/deref<span class="Delimiter">,</span> <span class="Constant">1</span>:offset +] +<span class="traceContains">+mem: storing 35 in location 9</span> + +<span class="Delimiter">:(after "reagent tmp" following "case GET:")</span> +tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> vector<string><span class="Delimiter">()));</span> + +<span class="SalientComment">//:: fix 'index'</span> + +<span class="Delimiter">:(scenario deref_sidesteps_default_space_in_index)</span> +recipe main [ + <span class="Comment"># pretend pointer to array from outside</span> + <span class="Constant">12</span>:integer<span class="Special"> <- </span>copy <span class="Constant">2</span>:literal + <span class="Constant">13</span>:integer<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal + <span class="Constant">14</span>:integer<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal + <span class="Comment"># pretend array</span> + <span class="Constant">1000</span>:integer<span class="Special"> <- </span>copy <span class="Constant">5</span>:literal + <span class="Comment"># actual start of this function</span> + default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>:literal + <span class="Constant">1</span>:address:array:integer<span class="Special"> <- </span>copy <span class="Constant">12</span>:literal + <span class="Constant">9</span>:integer/<span class="Special">raw <- </span>index <span class="Constant">1</span>:address:array:integer/deref<span class="Delimiter">,</span> <span class="Constant">1</span>:literal +] +<span class="traceContains">+mem: storing 35 in location 9</span> + +<span class="Delimiter">:(after "reagent tmp" following "case INDEX:")</span> +tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> vector<string><span class="Delimiter">()));</span> + +<span class="SalientComment">//:: helpers</span> + +<span class="Delimiter">:(code)</span> +index_t space_base<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>top<span class="Delimiter">().</span>default_space<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +index_t address<span class="Delimiter">(</span>index_t offset<span class="Delimiter">,</span> index_t base<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>base == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> offset<span class="Delimiter">;</span> <span class="Comment">// raw</span> +<span class="CommentedCode">//? cout << base << '\n'; //? 2</span> + if <span class="Delimiter">(</span>offset >= static_cast<index_t><span class="Delimiter">(</span>Memory[base]<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Comment">// todo: test</span> + raise << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << Memory[base] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> base+<span class="Constant">1</span> + offset<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(after "void write_memory(reagent x, vector<long long int> data)")</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>data<span class="Delimiter">.</span>size<span class="Delimiter">()</span> == <span class="Constant">1</span><span class="Delimiter">);</span> + Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>top<span class="Delimiter">().</span>default_space = data[<span class="Constant">0</span>]<span class="Delimiter">;</span> +<span class="CommentedCode">//? cout << "AAA " << Current_routine->calls.top().default_space << '\n'; //? 1</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + +<span class="Delimiter">:(scenario get_default_space)</span> +recipe main [ + default-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>:literal + <span class="Constant">1</span>:integer/<span class="Special">raw <- </span>copy default-space:address:array:location +] +<span class="traceContains">+mem: storing 10 in location 1</span> + +<span class="Delimiter">:(after "vector<long long int> read_memory(reagent x)")</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + vector<long long int> result<span class="Delimiter">;</span> + result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>top<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> + <span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> |