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/020run.cc.html | |
parent | b2757892d553352feb59d70b1e7241ccdafa6905 (diff) | |
download | mu-c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008.tar.gz |
1459
Diffstat (limited to 'html/020run.cc.html')
-rw-r--r-- | html/020run.cc.html | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/html/020run.cc.html b/html/020run.cc.html index 246ca3eb..3ebdbf88 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>~/Desktop/s/mu/020run.cc</title> +<title>020run.cc</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="cpp"> @@ -49,8 +49,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal ] -<span class="traceContains">+run: instruction main/0</span> -<span class="traceContains">+run: ingredient 0 is 23</span> +<span class="traceContains">+run: 1:number <- copy 23:literal</span> <span class="traceContains">+mem: storing 23 in location 1</span> <span class="Delimiter">:(scenario copy)</span> @@ -58,8 +57,7 @@ recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] -<span class="traceContains">+run: instruction main/1</span> -<span class="traceContains">+run: ingredient 0 is 1</span> +<span class="traceContains">+run: 2:number <- copy 1:number</span> <span class="traceContains">+mem: location 1 is 23</span> <span class="traceContains">+mem: storing 23 in location 2</span> @@ -67,8 +65,6 @@ recipe main [ recipe main [ <span class="Constant">1</span>:number<span class="Delimiter">,</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal<span class="Delimiter">,</span> <span class="Constant">24</span>:literal ] -<span class="traceContains">+run: ingredient 0 is 23</span> -<span class="traceContains">+run: ingredient 1 is 24</span> <span class="traceContains">+mem: storing 23 in location 1</span> <span class="traceContains">+mem: storing 24 in location 2</span> @@ -77,7 +73,7 @@ recipe main [ <span class="Comment">//: Later layers will change this.</span> struct routine <span class="Delimiter">{</span> recipe_number running_recipe<span class="Delimiter">;</span> - index_t running_step_index<span class="Delimiter">;</span> + long long int running_step_index<span class="Delimiter">;</span> routine<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> <span class="Delimiter">{}</span> bool completed<span class="Delimiter">()</span> const<span class="Delimiter">;</span> <span class="Delimiter">};</span> @@ -98,21 +94,18 @@ void run_current_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Comment">// Running One Instruction.</span> if <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span> ++current_step_index<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"instruction "</span> << current_recipe_name<span class="Delimiter">()</span> << <span class="Constant">'/'</span> << current_step_index<span class="Delimiter">();</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span>Initial_callstack_depth+Callstack_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">();</span> assert<span class="Delimiter">(</span>Memory[<span class="Constant">0</span>] == <span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// Read all ingredients from memory.</span> <span class="Comment">// Each ingredient loads a vector of values rather than a single value; mu</span> <span class="Comment">// permits operating on reagents spanning multiple locations.</span> vector<vector<double> > ingredients<span class="Delimiter">;</span> - for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"ingredient "</span> << i << <span class="Constant">" is "</span> << current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>read_memory<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)));</span> <span class="Delimiter">}</span> <span class="Comment">// Instructions below will write to 'products' or to 'instruction_counter'.</span> vector<vector<double> > products<span class="Delimiter">;</span> - index_t instruction_counter = current_step_index<span class="Delimiter">();</span> -<span class="CommentedCode">//? cout << "AAA: " << current_instruction().to_string() << '\n'; //? 1</span> + long long int instruction_counter = current_step_index<span class="Delimiter">();</span> switch <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>operation<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// Primitive Recipe Implementations</span> case COPY: <span class="Delimiter">{</span> @@ -124,17 +117,12 @@ void run_current_routine<span class="Delimiter">()</span> cout << <span class="Constant">"not a primitive op: "</span> << current_instruction<span class="Delimiter">().</span>operation << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="CommentedCode">//? cout << "BBB: " << current_instruction().to_string() << '\n'; //? 1</span> - if <span class="Delimiter">(</span>products<span class="Delimiter">.</span>size<span class="Delimiter">()</span> < current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>size<span class="Delimiter">())</span> + if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>products<span class="Delimiter">)</span> < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">))</span> raise << <span class="Constant">"failed to write to all products! "</span> << current_instruction<span class="Delimiter">().</span>to_string<span class="Delimiter">();</span> -<span class="CommentedCode">//? cout << "CCC: " << current_instruction().to_string() << '\n'; //? 1</span> - for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i < current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"product "</span> << i << <span class="Constant">" is "</span> << current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> write_memory<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> -<span class="CommentedCode">//? cout << "DDD: " << current_instruction().to_string() << '\n'; //? 1</span> current_step_index<span class="Delimiter">()</span> = instruction_counter+<span class="Constant">1</span><span class="Delimiter">;</span> -<span class="CommentedCode">//? cerr << "screen: " << Memory[SCREEN] << '\n'; //? 1</span> <span class="Delimiter">}</span> stop_running_current_routine:<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -143,7 +131,7 @@ void run_current_routine<span class="Delimiter">()</span> <span class="Comment">//: We'll need to override these later as we change the definition of routine.</span> <span class="Comment">//: Important that they return referrences into the routine.</span> -inline index_t& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> +inline long long int& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -156,7 +144,7 @@ inline const instruction& current_instruction<span class="Delimiter">()</spa <span class="Delimiter">}</span> inline bool routine::completed<span class="Delimiter">()</span> const <span class="Delimiter">{</span> - <span class="Identifier">return</span> running_step_index >= Recipe[running_recipe]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>size<span class="Delimiter">();</span> + <span class="Identifier">return</span> running_step_index >= SIZE<span class="Delimiter">(</span>Recipe[running_recipe]<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">:(before "End Commandline Parsing")</span> @@ -222,11 +210,11 @@ vector<double> read_memory<span class="Delimiter">(</span>reagent x<span c result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>x<span class="Delimiter">.</span>value<span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> - index_t base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - size_t size = size_of<span class="Delimiter">(</span>x<span class="Delimiter">);</span> - for <span class="Delimiter">(</span>index_t offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < size<span class="Delimiter">;</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + long long int size = size_of<span class="Delimiter">(</span>x<span class="Delimiter">);</span> + for <span class="Delimiter">(</span>long long int offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < size<span class="Delimiter">;</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> double val = Memory[base+offset]<span class="Delimiter">;</span> - trace<span class="Delimiter">(</span><span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << base+offset << <span class="Constant">" is "</span> << val<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"location "</span> << base+offset << <span class="Constant">" is "</span> << val<span class="Delimiter">;</span> result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>val<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> @@ -234,20 +222,20 @@ vector<double> read_memory<span class="Delimiter">(</span>reagent x<span c void write_memory<span class="Delimiter">(</span>reagent x<span class="Delimiter">,</span> vector<double> data<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - index_t base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> != data<span class="Delimiter">.</span>size<span class="Delimiter">())</span> + long long int base = x<span class="Delimiter">.</span>value<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>size_of<span class="Delimiter">(</span>x<span class="Delimiter">)</span> != SIZE<span class="Delimiter">(</span>data<span class="Delimiter">))</span> raise << <span class="Constant">"size mismatch in storing to "</span> << x<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> - for <span class="Delimiter">(</span>index_t offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < data<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> - trace<span class="Delimiter">(</span><span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << <span class="Constant">" in location "</span> << base+offset<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int offset = <span class="Constant">0</span><span class="Delimiter">;</span> offset < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++offset<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"mem"</span><span class="Delimiter">)</span> << <span class="Constant">"storing "</span> << data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">)</span> << <span class="Constant">" in location "</span> << base+offset<span class="Delimiter">;</span> Memory[base+offset] = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -size_t size_of<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +long long int size_of<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> size_of<span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">);</span> <span class="Delimiter">}</span> -size_t size_of<span class="Delimiter">(</span>const vector<type_number>& types<span class="Delimiter">)</span> <span class="Delimiter">{</span> +long long int size_of<span class="Delimiter">(</span>const vector<type_number>& types<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End size_of(types) Cases</span> <span class="Identifier">return</span> <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -257,7 +245,7 @@ bool is_dummy<span class="Delimiter">(</span>const reagent& x<span class="De <span class="Delimiter">}</span> bool isa_literal<span class="Delimiter">(</span>const reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Identifier">return</span> r<span class="Delimiter">.</span>types<span class="Delimiter">.</span>size<span class="Delimiter">()</span> == <span class="Constant">1</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> == <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>types<span class="Delimiter">)</span> == <span class="Constant">1</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> == <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(scenario run_label)</span> @@ -266,15 +254,15 @@ recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:number ] -<span class="traceContains">+run: instruction main/1</span> -<span class="traceContains">+run: instruction main/2</span> -<span class="traceAbsent">-run: instruction main/0</span> +<span class="traceContains">+run: 1:number <- copy 23:literal</span> +<span class="traceContains">+run: 2:number <- copy 1:number</span> +<span class="traceAbsent">-run: +foo</span> <span class="Delimiter">:(scenario run_dummy)</span> recipe main [ _<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal ] -<span class="traceContains">+run: instruction main/0</span> +<span class="traceContains">+run: _ <- copy 0:literal</span> </pre> </body> </html> |