diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-25 22:27:19 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-25 22:27:19 -0700 |
commit | c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008 (patch) | |
tree | 2d05d987ec3c81bfbb0c1f598966d9d1b16e9b1f /html/032array.cc.html | |
parent | b2757892d553352feb59d70b1e7241ccdafa6905 (diff) | |
download | mu-c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008.tar.gz |
1459
Diffstat (limited to 'html/032array.cc.html')
-rw-r--r-- | html/032array.cc.html | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/html/032array.cc.html b/html/032array.cc.html index c2fc903c..f5bab670 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>~/Desktop/s/mu/032array.cc</title> +<title>032array.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -49,12 +49,6 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal <span class="Constant">5</span>:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:array:number ] -<span class="traceContains">+run: instruction main/4</span> -<span class="traceContains">+run: ingredient 0 is 1</span> -<span class="traceContains">+mem: location 1 is 3</span> -<span class="traceContains">+mem: location 2 is 14</span> -<span class="traceContains">+mem: location 3 is 15</span> -<span class="traceContains">+mem: location 4 is 16</span> <span class="traceContains">+mem: storing 3 in location 5</span> <span class="traceContains">+mem: storing 14 in location 6</span> <span class="traceContains">+mem: storing 15 in location 7</span> @@ -69,23 +63,17 @@ recipe main [ <span class="Constant">5</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Constant">6</span>:array:number<span class="Special"> <- </span>copy <span class="Constant">5</span>:address:array:number/deref ] -<span class="traceContains">+run: instruction main/5</span> -<span class="traceContains">+run: ingredient 0 is 5</span> -<span class="traceContains">+mem: location 1 is 3</span> -<span class="traceContains">+mem: location 2 is 14</span> -<span class="traceContains">+mem: location 3 is 15</span> -<span class="traceContains">+mem: location 4 is 16</span> <span class="traceContains">+mem: storing 3 in location 6</span> <span class="traceContains">+mem: storing 14 in location 7</span> <span class="traceContains">+mem: storing 15 in location 8</span> <span class="traceContains">+mem: storing 16 in location 9</span> <span class="Comment">//: disable the size mismatch check since the destination array need not be initialized</span> -<span class="Delimiter">:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<double> data)")</span> -if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>types<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> != Type_number[<span class="Constant">"array"</span>] && size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> != data<span class="Delimiter">.</span>size<span class="Delimiter">())</span> -<span class="Delimiter">:(after "size_t size_of(const reagent& r)")</span> +<span class="Delimiter">:(replace "if (size_of(x) != SIZE(data))" following "void write_memory(reagent x, vector<double> data)")</span> +if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>types<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> != Type_number[<span class="Constant">"array"</span>] && size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>data<span class="Delimiter">))</span> +<span class="Delimiter">:(after "long long int size_of(const reagent& r)")</span> if <span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == Type_number[<span class="Constant">"array"</span>]<span class="Delimiter">)</span> <span class="Delimiter">{</span> - assert<span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">.</span>size<span class="Delimiter">()</span> > <span class="Constant">1</span><span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// skip the 'array' type to get at the element type</span> <span class="Identifier">return</span> <span class="Constant">1</span> + Memory[r<span class="Delimiter">.</span>value]*size_of<span class="Delimiter">(</span>array_element<span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">));</span> <span class="Delimiter">}</span> @@ -100,11 +88,6 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal <span class="Constant">5</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">0</span>:literal ] -<span class="traceContains">+run: instruction main/4</span> -<span class="traceContains">+run: address to copy is 2</span> -<span class="traceContains">+run: its type is 1</span> -<span class="traceContains">+mem: location 2 is 14</span> -<span class="traceContains">+run: product 0 is 5</span> <span class="traceContains">+mem: storing 14 in location 5</span> <span class="Delimiter">:(scenario index_direct_offset)</span> @@ -116,11 +99,6 @@ recipe main [ <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal <span class="Constant">6</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">5</span>:number ] -<span class="traceContains">+run: instruction main/5</span> -<span class="traceContains">+run: address to copy is 2</span> -<span class="traceContains">+run: its type is 1</span> -<span class="traceContains">+mem: location 2 is 14</span> -<span class="traceContains">+run: product 0 is 6</span> <span class="traceContains">+mem: storing 14 in location 6</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -131,18 +109,18 @@ Recipe_number[<span class="Constant">"index"</span>] = INDEX<span clas case INDEX: <span class="Delimiter">{</span> <span class="CommentedCode">//? if (Trace_stream) Trace_stream->dump_layer = "run"; //? 1</span> reagent base = canonize<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> -<span class="CommentedCode">//? trace("run") << "ingredient 0 after canonize: " << base.to_string(); //? 1</span> - index_t base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> +<span class="CommentedCode">//? trace(Primitive_recipe_depth, "run") << "ingredient 0 after canonize: " << base.to_string(); //? 1</span> + long long int base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>base<span class="Delimiter">.</span>types<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == Type_number[<span class="Constant">"array"</span>]<span class="Delimiter">);</span> reagent offset = canonize<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> -<span class="CommentedCode">//? trace("run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1</span> +<span class="CommentedCode">//? trace(Primitive_recipe_depth, "run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1</span> vector<double> offset_val<span class="Delimiter">(</span>read_memory<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> vector<type_number> element_type = array_element<span class="Delimiter">(</span>base<span class="Delimiter">.</span>types<span class="Delimiter">);</span> -<span class="CommentedCode">//? trace("run") << "offset: " << offset_val.at(0); //? 1</span> -<span class="CommentedCode">//? trace("run") << "size of elements: " << size_of(element_type); //? 1</span> - index_t src = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"address to copy is "</span> << src<span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"its type is "</span> << element_type<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> +<span class="CommentedCode">//? trace(Primitive_recipe_depth, "run") << "offset: " << offset_val.at(0); //? 1</span> +<span class="CommentedCode">//? trace(Primitive_recipe_depth, "run") << "size of elements: " << size_of(element_type); //? 1</span> + long long int src = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"address to copy is "</span> << src<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"its type is "</span> << element_type<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> reagent tmp<span class="Delimiter">;</span> tmp<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>src<span class="Delimiter">);</span> copy<span class="Delimiter">(</span>element_type<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> element_type<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> inserter<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>types<span class="Delimiter">,</span> tmp<span class="Delimiter">.</span>types<span class="Delimiter">.</span>begin<span class="Delimiter">()));</span> @@ -163,7 +141,6 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal <span class="Constant">5</span>:number<span class="Special"> <- </span>index-address <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">0</span>:literal ] -<span class="traceContains">+run: instruction main/4</span> <span class="traceContains">+mem: storing 2 in location 5</span> <span class="SalientComment">//:: To write to elements of containers, you need their address.</span> @@ -177,7 +154,6 @@ recipe main [ <span class="Constant">5</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Constant">6</span>:number<span class="Special"> <- </span>index <span class="Constant">5</span>:address:array:number/deref<span class="Delimiter">,</span> <span class="Constant">1</span>:literal ] -<span class="traceContains">+run: instruction main/5</span> <span class="traceContains">+mem: storing 15 in location 6</span> <span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> @@ -187,12 +163,12 @@ Recipe_number[<span class="Constant">"index-address"</span>] = INDEX_A <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case INDEX_ADDRESS: <span class="Delimiter">{</span> reagent base = canonize<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - index_t base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + long long int base_address = base<span class="Delimiter">.</span>value<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>base<span class="Delimiter">.</span>types<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == Type_number[<span class="Constant">"array"</span>]<span class="Delimiter">);</span> reagent offset = canonize<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">));</span> vector<double> offset_val<span class="Delimiter">(</span>read_memory<span class="Delimiter">(</span>offset<span class="Delimiter">));</span> vector<type_number> element_type = array_element<span class="Delimiter">(</span>base<span class="Delimiter">.</span>types<span class="Delimiter">);</span> - index_t result = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + long long int result = base_address + <span class="Constant">1</span> + offset_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>*size_of<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>result<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> |