diff options
Diffstat (limited to 'html/032array.cc.html')
-rw-r--r-- | html/032array.cc.html | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/html/032array.cc.html b/html/032array.cc.html index 7bb0495f..cac483a1 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -10,9 +10,10 @@ <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; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.cSpecial { color: #008000; } .CommentedCode { color: #6c6c6c; } .Constant { color: #008080; } .Comment { color: #8080ff; } @@ -173,6 +174,34 @@ case INDEX_ADDRESS: <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> <span class="Delimiter">}</span> + +<span class="SalientComment">//:: compute the length of an array</span> + +<span class="Delimiter">:(scenario array_length)</span> +recipe main [ + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span>:literal <span class="Comment"># length</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span>:literal + <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal + <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>length <span class="Constant">1</span>:array:number +] +<span class="traceContains">+mem: storing 3 in location 5</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +LENGTH<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"length"</span>] = LENGTH<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case LENGTH: <span class="Delimiter">{</span> + reagent x = 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> + 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>]<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"tried to calculate length of non-array "</span> << x<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <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>Memory[x<span class="Delimiter">.</span>value]<span class="Delimiter">);</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> </pre> </body> </html> |