diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-05 01:08:00 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-05 01:08:00 -0700 |
commit | 298f8065857630e414d84e4ee785a6d17e5f99bb (patch) | |
tree | 8880a092ab59850a6f821ba892f3904ab464431c /html/032array.cc.html | |
parent | f28f2636c6707e1a33bebacafd0486f4965978ea (diff) | |
download | mu-298f8065857630e414d84e4ee785a6d17e5f99bb.tar.gz |
3102
Diffstat (limited to 'html/032array.cc.html')
-rw-r--r-- | html/032array.cc.html | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/html/032array.cc.html b/html/032array.cc.html index 277398e6..fb9bb0d5 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -163,7 +163,7 @@ container foo [ <span class="Delimiter">:(before "End Load Container Element Definition")</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_tree* type = info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>back<span class="Delimiter">().</span>type<span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>type && type<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << <span class="Constant">"container '"</span> << name << <span class="Constant">"' doesn't specify type of array elements for '"</span> << info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>back<span class="Delimiter">().</span>name << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -175,6 +175,17 @@ container foo [ <span class="Delimiter">}</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(scenario code_inside_container)</span> +<span class="Special">% Hide_errors = true;</span> +container card [ + <span class="Normal">rank</span>:number<span class="Special"> <- </span>next-ingredient +] +recipe foo [ + <span class="Constant">1</span>:card<span class="Special"> <- </span>merge <span class="Constant">3</span> + <span class="Constant">2</span>:number<span class="Special"> <- </span>get <span class="Constant">1</span>:card rank:offset +] +<span class="Comment"># shouldn't die</span> + <span class="SalientComment">//:: To access elements of an array, use 'index'</span> <span class="Delimiter">:(scenario index)</span> @@ -245,7 +256,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Comment">// Update INDEX index in Run</span> vector<<span class="Normal">double</span>> index_val<span class="Delimiter">(</span>read_memory<span class="Delimiter">(</span>index<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>index_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> < <span class="Constant">0</span> || index_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> >= get_or_insert<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> base_address<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"invalid index "</span> << no_scientific<span class="Delimiter">(</span>index_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"invalid index "</span> << no_scientific<span class="Delimiter">(</span>index_val<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> << <span class="Constant">" in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> type_tree* element_type = copy_array_element<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">);</span> @@ -306,7 +317,7 @@ def main [ <span class="Constant">7</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span> index <span class="Constant">1</span>:array:number:<span class="Constant">3</span><span class="Delimiter">,</span> <span class="Constant">4</span> <span class="Comment"># less than size of array in locations, but larger than its length in elements</span> ] -<span class="traceContains">+error: main: invalid index 4</span> +<span class="traceContains">+error: main: invalid index 4 in 'index 1:array:number:3, 4'</span> <span class="Delimiter">:(scenario index_out_of_bounds_2)</span> <span class="Special">% Hide_errors = true;</span> @@ -320,7 +331,7 @@ def main [ <span class="Constant">7</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span> index <span class="Constant">1</span>:array:point<span class="Delimiter">,</span> -<span class="Constant">1</span> ] -<span class="traceContains">+error: main: invalid index -1</span> +<span class="traceContains">+error: main: invalid index -1 in 'index 1:array:point, -1'</span> <span class="Delimiter">:(scenario index_product_type_mismatch)</span> <span class="Special">% Hide_errors = true;</span> |