diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-05-12 19:55:21 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-05-12 20:14:49 -0700 |
commit | 1fb0cf9ef9e616163039fd4df6584c6c2ba68d23 (patch) | |
tree | cdffcc21108054c20585d74b4c57634e929c6c4c /html/030container.cc.html | |
parent | cdf2822743b3beeb37ebc3deea8e08b6130698c5 (diff) | |
download | mu-1fb0cf9ef9e616163039fd4df6584c6c2ba68d23.tar.gz |
4243
Diffstat (limited to 'html/030container.cc.html')
-rw-r--r-- | html/030container.cc.html | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/html/030container.cc.html b/html/030container.cc.html index 113446d0..5df040ec 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -70,7 +70,7 @@ if ('onhashchange' in window) { <span id="L4" class="LineNr"> 4 </span><span class="Comment">//: We'll use this container as a running example in scenarios below.</span> <span id="L5" class="LineNr"> 5 </span><a href='010vm.cc.html#L124'>type_ordinal</a> point = <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"point"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> <span id="L6" class="LineNr"> 6 </span><a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">);</span> <span class="Comment">// initialize</span> -<span id="L7" class="LineNr"> 7 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>kind = <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">;</span> +<span id="L7" class="LineNr"> 7 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>kind = <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">;</span> <span id="L8" class="LineNr"> 8 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>name = <span class="Constant">"point"</span><span class="Delimiter">;</span> <span id="L9" class="LineNr"> 9 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"x:number"</span><span class="Delimiter">));</span> <span id="L10" class="LineNr"> 10 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"y:number"</span><span class="Delimiter">));</span> @@ -103,7 +103,7 @@ if ('onhashchange' in window) { <span id="L37" class="LineNr"> 37 </span><span class="Comment">// its elements.</span> <span id="L38" class="LineNr"> 38 </span><a href='010vm.cc.html#L124'>type_ordinal</a> point_number = <a href='001help.cc.html#L221'>put</a><span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"point-number"</span><span class="Delimiter">,</span> Next_type_ordinal++<span class="Delimiter">);</span> <span id="L39" class="LineNr"> 39 </span><a href='001help.cc.html#L229'>get_or_insert</a><span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">);</span> <span class="Comment">// initialize</span> -<span id="L40" class="LineNr"> 40 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">).</span>kind = <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">;</span> +<span id="L40" class="LineNr"> 40 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">).</span>kind = <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">;</span> <span id="L41" class="LineNr"> 41 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">).</span>name = <span class="Constant">"point-number"</span><span class="Delimiter">;</span> <span id="L42" class="LineNr"> 42 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"xy:point"</span><span class="Delimiter">));</span> <span id="L43" class="LineNr"> 43 </span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> point_number<span class="Delimiter">).</span>elements<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"z:number"</span><span class="Delimiter">));</span> @@ -221,7 +221,7 @@ if ('onhashchange' in window) { <span id="L155" class="LineNr">155 </span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> <span id="L156" class="LineNr">156 </span><span class="Delimiter">}</span> <span id="L157" class="LineNr">157 </span>type_info t = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> -<span id="L158" class="LineNr">158 </span><span class="Normal">if</span> <span class="Delimiter">(</span>t<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L158" class="LineNr">158 </span><span class="Normal">if</span> <span class="Delimiter">(</span>t<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L159" class="LineNr">159 </span> <span class="Comment">// Compute size_of Container</span> <span id="L160" class="LineNr">160 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> type<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L161" class="LineNr">161 </span> <a href='003trace.cc.html#L174'>raise</a> << <span class="Constant">"unknown size for container type '"</span> << to_string<span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L203'>end</a><span class="Delimiter">();</span> @@ -280,13 +280,13 @@ if ('onhashchange' in window) { <span id="L214" class="LineNr">214 </span> assert<span class="Delimiter">(</span>type<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> <span id="L215" class="LineNr">215 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>value<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// error raised elsewhere</span> <span id="L216" class="LineNr">216 </span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> -<span id="L217" class="LineNr">217 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">)</span> +<span id="L217" class="LineNr">217 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">)</span> <span id="L218" class="LineNr">218 </span> compute_container_sizes<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span id="L219" class="LineNr">219 </span> <span class="Comment">// End compute_container_sizes Atom Special-cases</span> <span id="L220" class="LineNr">220 </span><span class="Delimiter">}</span> <span id="L221" class="LineNr">221 </span> <span id="L222" class="LineNr">222 </span><span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span><span class="Normal">const</span> type_info& container_info<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* full_type<span class="Delimiter">,</span> set<type_tree>& pending_metadata<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L223" class="LineNr">223 </span> assert<span class="Delimiter">(</span>container_info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">);</span> +<span id="L223" class="LineNr">223 </span> assert<span class="Delimiter">(</span>container_info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">);</span> <span id="L224" class="LineNr">224 </span> <span class="Comment">// size of a container is the sum of the sizes of its element</span> <span id="L225" class="LineNr">225 </span> <span class="Comment">// (So it can only contain arrays if they're static and include their</span> <span id="L226" class="LineNr">226 </span> <span class="Comment">// length in the type.)</span> @@ -437,7 +437,7 @@ if ('onhashchange' in window) { <span id="L371" class="LineNr">371 </span> <span class="Delimiter">}</span> <span id="L372" class="LineNr">372 </span> <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> <span id="L373" class="LineNr">373 </span> <span class="Comment">// Update GET base_type in Check</span> -<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L374" class="LineNr">374 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L375" class="LineNr">375 </span> <a href='003trace.cc.html#L174'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'get' should be a container, but got '"</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L203'>end</a><span class="Delimiter">();</span> <span id="L376" class="LineNr">376 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L377" class="LineNr">377 </span> <span class="Delimiter">}</span> @@ -499,7 +499,7 @@ if ('onhashchange' in window) { <span id="L433" class="LineNr">433 </span> assert<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">));</span> <span id="L434" class="LineNr">434 </span> assert<span class="Delimiter">(</span>!get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name<span class="Delimiter">.</span>empty<span class="Delimiter">());</span> <span id="L435" class="LineNr">435 </span> <span class="Normal">const</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> -<span id="L436" class="LineNr">436 </span> assert<span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">);</span> +<span id="L436" class="LineNr">436 </span> assert<span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">);</span> <span id="L437" class="LineNr">437 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset_value >= <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">))</span> <span class="Identifier">return</span> reagent<span class="Delimiter">();</span> <span class="Comment">// error handled elsewhere</span> <span id="L438" class="LineNr">438 </span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset_value<span class="Delimiter">);</span> <span id="L439" class="LineNr">439 </span> <span class="Comment">// End element_type Special-cases</span> @@ -585,7 +585,7 @@ if ('onhashchange' in window) { <span id="L519" class="LineNr">519 </span> <span class="Delimiter">}</span> <span id="L520" class="LineNr">520 </span> <span class="Normal">const</span> type_tree* base_type = base<span class="Delimiter">.</span>type<span class="Delimiter">;</span> <span id="L521" class="LineNr">521 </span> <span class="Comment">// Update PUT base_type in Check</span> -<span id="L522" class="LineNr">522 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L522" class="LineNr">522 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!base_type<span class="Delimiter">-></span>atom || base_type<span class="Delimiter">-></span>value == <span class="Constant">0</span> || !contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">)</span> || get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>kind != <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L523" class="LineNr">523 </span> <a href='003trace.cc.html#L174'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'put' should be a container, but got '"</span> << inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L203'>end</a><span class="Delimiter">();</span> <span id="L524" class="LineNr">524 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L525" class="LineNr">525 </span> <span class="Delimiter">}</span> @@ -712,7 +712,7 @@ if ('onhashchange' in window) { <span id="L646" class="LineNr">646 </span> <span id="L647" class="LineNr">647 </span><span class="Delimiter">:(before "End Command Handlers")</span> <span id="L648" class="LineNr">648 </span><span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>command == <span class="Constant">"container"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L649" class="LineNr">649 </span> <a href='030container.cc.html#L661'>insert_container</a><span class="Delimiter">(</span>command<span class="Delimiter">,</span> <a href='010vm.cc.html#L174'>CONTAINER</a><span class="Delimiter">,</span> in<span class="Delimiter">);</span> +<span id="L649" class="LineNr">649 </span> <a href='030container.cc.html#L661'>insert_container</a><span class="Delimiter">(</span>command<span class="Delimiter">,</span> <a href='010vm.cc.html#L179'>CONTAINER</a><span class="Delimiter">,</span> in<span class="Delimiter">);</span> <span id="L650" class="LineNr">650 </span><span class="Delimiter">}</span> <span id="L651" class="LineNr">651 </span> <span id="L652" class="LineNr">652 </span><span class="Comment">//: Even though we allow containers to be extended, we don't allow this after</span> @@ -724,7 +724,7 @@ if ('onhashchange' in window) { <span id="L658" class="LineNr">658 </span>Num_calls_to_transform_all_at_first_definition = -<span class="Constant">1</span><span class="Delimiter">;</span> <span id="L659" class="LineNr">659 </span> <span id="L660" class="LineNr">660 </span><span class="Delimiter">:(code)</span> -<span id="L661" class="LineNr">661 </span><span class="Normal">void</span> <a href='030container.cc.html#L661'>insert_container</a><span class="Delimiter">(</span><span class="Normal">const</span> string& command<span class="Delimiter">,</span> <a href='010vm.cc.html#L172'>kind_of_type</a> kind<span class="Delimiter">,</span> istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L661" class="LineNr">661 </span><span class="Normal">void</span> <a href='030container.cc.html#L661'>insert_container</a><span class="Delimiter">(</span><span class="Normal">const</span> string& command<span class="Delimiter">,</span> <a href='010vm.cc.html#L177'>kind_of_type</a> kind<span class="Delimiter">,</span> istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L662" class="LineNr">662 </span> skip_whitespace_but_not_newline<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span id="L663" class="LineNr">663 </span> string name = <a href='011load.cc.html#L167'>next_word</a><span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span id="L664" class="LineNr">664 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>name<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> @@ -971,8 +971,8 @@ if ('onhashchange' in window) { <span id="L905" class="LineNr">905 </span> ostringstream out<span class="Delimiter">;</span> <span id="L906" class="LineNr">906 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> t<span class="Delimiter">))</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span id="L907" class="LineNr">907 </span> <span class="Normal">const</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> t<span class="Delimiter">);</span> -<span id="L908" class="LineNr">908 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L173'>PRIMITIVE</a><span class="Delimiter">)</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> -<span id="L909" class="LineNr">909 </span> out << <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L174'>CONTAINER</a> ? <span class="Constant">"container"</span> : <span class="Constant">"exclusive-container"</span><span class="Delimiter">)</span> << <span class="Constant">" "</span> << info<span class="Delimiter">.</span>name << <span class="Constant">" [</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> +<span id="L908" class="LineNr">908 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L178'>PRIMITIVE</a><span class="Delimiter">)</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span id="L909" class="LineNr">909 </span> out << <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == <a href='010vm.cc.html#L179'>CONTAINER</a> ? <span class="Constant">"container"</span> : <span class="Constant">"exclusive-container"</span><span class="Delimiter">)</span> << <span class="Constant">" "</span> << info<span class="Delimiter">.</span>name << <span class="Constant">" [</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span id="L910" class="LineNr">910 </span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < <a href='001help.cc.html#L141'>SIZE</a><span class="Delimiter">(</span>info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L911" class="LineNr">911 </span> out << <span class="Constant">" "</span> << info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>original_string << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span id="L912" class="LineNr">912 </span> <span class="Delimiter">}</span> |