diff options
-rw-r--r-- | html/001help.cc.html | 6 | ||||
-rw-r--r-- | html/017parse_tree.cc.html | 7 | ||||
-rw-r--r-- | html/020run.cc.html | 6 | ||||
-rw-r--r-- | html/030container.cc.html | 56 | ||||
-rw-r--r-- | html/033exclusive_container.cc.html | 6 | ||||
-rw-r--r-- | html/034address.cc.html | 53 | ||||
-rw-r--r-- | html/036refcount.cc.html | 74 | ||||
-rw-r--r-- | html/050scenario.cc.html | 4 | ||||
-rw-r--r-- | html/055shape_shifting_container.cc.html | 72 | ||||
-rw-r--r-- | html/072scheduler.cc.html | 2 |
10 files changed, 167 insertions, 119 deletions
diff --git a/html/001help.cc.html b/html/001help.cc.html index dd6f7d74..7d999033 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -53,10 +53,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color << <span class="Constant">"Examples:</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" To load files and run 'main':</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" mu file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" To run 'main' and dump a trace of all operations at the end:</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" mu --trace file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" To run all tests:</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" mu test</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" To load files and then run all tests:</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" mu test file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" To run a single Mu scenario:</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" mu test file1.mu file2.mu ... scenario</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" To run a single Mu scenario and dump a trace at the end:</span><span class="cSpecial">\n</span><span class="Constant">"</span> + << <span class="Constant">" mu --trace test file1.mu file2.mu ... scenario</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" To load files and run only the tests in explicitly loaded files (for apps):</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" mu --test-only-app test file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <span class="Constant">" To load all files with a numeric prefix in a directory:</span><span class="cSpecial">\n</span><span class="Constant">"</span> diff --git a/html/017parse_tree.cc.html b/html/017parse_tree.cc.html index f700033e..39f56afb 100644 --- a/html/017parse_tree.cc.html +++ b/html/017parse_tree.cc.html @@ -115,6 +115,7 @@ string_tree* parse_string_tree<span class="Delimiter">(</span>istream& in<sp <span class="Delimiter">}</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> <span class="Comment">// skip ')'</span> assert<span class="Delimiter">(</span>*curr == <span class="Constant">NULL</span><span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>result == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>result<span class="Delimiter">-></span>right == <span class="Constant">NULL</span><span class="Delimiter">)</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Comment">// standardize the final element to always be on the right if it's an atom</span> <span class="Comment">// (a b c) => (a b . c) in s-expression parlance</span> @@ -142,6 +143,12 @@ string_tree* parse_string_tree<span class="Delimiter">(</span>istream& in<sp ] <span class="traceContains">+parse: product: {1: ("foo" ("address" "array" "character") ("bar" "number"))}</span> +<span class="Delimiter">:(scenario dilated_empty_tree)</span> +<span class="muRecipe">def</span> main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: <span class="Delimiter">()}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> +] +<span class="traceContains">+parse: product: {1: "number", "foo": ()}</span> + <span class="Delimiter">:(scenario dilated_singleton_tree)</span> <span class="muRecipe">def</span> main [ <span class="Delimiter">{</span><span class="Constant">1</span>: number<span class="Delimiter">,</span> foo: <span class="Delimiter">(</span>bar<span class="Delimiter">)}</span><span class="Special"> <- </span>copy <span class="Constant">34</span> diff --git a/html/020run.cc.html b/html/020run.cc.html index 57ea81ac..59b13726 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -226,7 +226,7 @@ save_snapshots<span class="Delimiter">();</span> <span class="Comment">// Running Main</span> setup<span class="Delimiter">();</span> <span class="CommentedCode">//? Save_trace = true;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>Trace_main<span class="Delimiter">)</span> Trace_stream = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>Start_tracing<span class="Delimiter">)</span> Trace_stream = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9990</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"=== Starting to run"</span> << end<span class="Delimiter">();</span> assert<span class="Delimiter">(</span>Num_calls_to_transform_all == <span class="Constant">1</span><span class="Delimiter">);</span> run_main<span class="Delimiter">(</span>argc<span class="Delimiter">,</span> argv<span class="Delimiter">);</span> @@ -241,10 +241,10 @@ save_snapshots<span class="Delimiter">();</span> <span class="Comment">//: By default we don't maintain the trace while running main because its</span> <span class="Comment">//: overheads can grow rapidly. However, it's useful when debugging.</span> <span class="Delimiter">:(before "End Globals")</span> -<span class="Normal">bool</span> Trace_main = <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Normal">bool</span> Start_tracing = <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Commandline Options(*arg)")</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_equal<span class="Delimiter">(</span>*arg<span class="Delimiter">,</span> <span class="Constant">"--trace"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> - Trace_main = <span class="Constant">true</span><span class="Delimiter">;</span> + Start_tracing = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> diff --git a/html/030container.cc.html b/html/030container.cc.html index 2c7bfe6d..81437ba6 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -222,24 +222,24 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"- compute container sizes for "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</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 < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - compute_container_sizes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + compute_container_sizes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">" in '"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</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 < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - compute_container_sizes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + compute_container_sizes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">" in '"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span>reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span>reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> expand_type_abbreviations<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">)</span> || is_dummy<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> reagent rcopy = r<span class="Delimiter">;</span> <span class="Comment">// Compute Container Size(reagent rcopy)</span> set<type_tree> pending_metadata<span class="Delimiter">;</span> <span class="Comment">// might actually be faster to just convert to string rather than compare type_tree directly; so far the difference is negligible</span> - compute_container_sizes<span class="Delimiter">(</span>rcopy<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>rcopy<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> rcopy<span class="Delimiter">.</span>type<span class="Delimiter">))</span> r<span class="Delimiter">.</span>metadata = get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> rcopy<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> set<type_tree>& pending_metadata<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_container_sizes<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* 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 class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"compute container sizes for "</span> << to_string<span class="Delimiter">(</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</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="Identifier">return</span><span class="Delimiter">;</span> @@ -248,14 +248,14 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"address"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_sizes<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_tree* element_type = type<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Comment">// hack: support both array:num:3 and array:address:num</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!element_type<span class="Delimiter">-></span>atom && element_type<span class="Delimiter">-></span>right && element_type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>atom && is_integer<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name<span class="Delimiter">))</span> element_type = element_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> - compute_container_sizes<span class="Delimiter">(</span>element_type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>element_type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// End compute_container_sizes Non-atom Cases</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -264,12 +264,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <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> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_sizes<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</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 class="Delimiter">}</span> <span class="Comment">// End compute_container_sizes Atom Cases</span> <span class="Delimiter">}</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="Delimiter">{</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> assert<span class="Delimiter">(</span>container_info<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">);</span> <span class="Comment">// size of a container is the sum of the sizes of its element</span> <span class="Comment">// (So it can only contain arrays if they're static and include their</span> @@ -278,7 +278,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <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 < SIZE<span class="Delimiter">(</span>container_info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = container_info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Comment">// Compute Container Size(element, full_type)</span> - compute_container_sizes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> metadata<span class="Delimiter">.</span>offset<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">);</span> <span class="Comment">// save previous size as offset</span> metadata<span class="Delimiter">.</span>size += size_of<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -328,7 +328,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ reagent r<span class="Delimiter">(</span><span class="Constant">"x:point"</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> r<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Comment">// scan</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// the reagent we scanned knows its size</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// the global table also knows its size</span> @@ -341,7 +341,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">"pt"</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">"point"</span><span class="Delimiter">));</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:pt"</span><span class="Delimiter">);</span> <span class="Comment">// scan</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// the reagent we scanned knows its size</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// the global table also knows its size</span> @@ -354,7 +354,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ reagent r<span class="Delimiter">(</span><span class="Constant">"x:point-number"</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> r<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Comment">// scan</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// the reagent we scanned knows its size</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> <span class="Comment">// the global table also knows its size</span> @@ -369,7 +369,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ <span class="Constant">" y:address:foo</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -379,7 +379,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ CHECK<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Comment">// scanning an address to the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -390,7 +390,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ CHECK<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Comment">// scanning an array of the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:array:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -401,7 +401,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ CHECK<span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> <span class="Comment">// scanning an address to an array of the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -412,7 +412,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ <span class="Normal">int</span> old_size = SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">);</span> <span class="Comment">// scanning an address to an array of the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:array:point:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// no non-container types precomputed</span> @@ -425,7 +425,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ <span class="Normal">int</span> old_size = SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">);</span> <span class="Comment">// scanning an address to an array of the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:point:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// no non-container types precomputed</span> @@ -438,7 +438,7 @@ container_metadata& get<span class="Delimiter">(</span>vector<pair<typ <span class="Normal">int</span> old_size = SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">);</span> <span class="Comment">// scanning repeated address and array types modifying the container precomputes the size of the container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:address:array:point:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">));</span> CHECK_EQ<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> container<span class="Delimiter">.</span>type<span class="Delimiter">).</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// no non-container types precomputed</span> @@ -934,12 +934,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa check_or_set_invalid_types<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">,</span> maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">),</span> <span class="Constant">"'"</span>+inst<span class="Delimiter">.</span>original_string+<span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> check_or_set_invalid_types<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& block<span class="Delimiter">,</span> <span class="Normal">const</span> string& name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> check_or_set_invalid_types<span class="Delimiter">(</span>type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">,</span> <span class="Normal">const</span> string& name_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// End Container Type Checks</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> - check_or_set_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> block<span class="Delimiter">,</span> name<span class="Delimiter">);</span> - check_or_set_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> block<span class="Delimiter">,</span> name<span class="Delimiter">);</span> + check_or_set_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">,</span> name_for_error_messages<span class="Delimiter">);</span> + check_or_set_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">,</span> name_for_error_messages<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -948,7 +948,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type<span class="Delimiter">-></span>name<span class="Delimiter">))</span> type<span class="Delimiter">-></span>value = get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> type<span class="Delimiter">-></span>name<span class="Delimiter">);</span> <span class="Normal">else</span> - raise << block << <span class="Constant">"unknown type "</span> << type<span class="Delimiter">-></span>name << <span class="Constant">" in "</span> << name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << location_for_error_messages << <span class="Constant">"unknown type "</span> << type<span class="Delimiter">-></span>name << <span class="Constant">" in "</span> << name_for_error_messages << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -989,16 +989,16 @@ check_container_field_types<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> check_invalid_types<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& block<span class="Delimiter">,</span> <span class="Normal">const</span> string& name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> check_invalid_types<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">,</span> <span class="Normal">const</span> string& name_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// will throw a more precise error elsewhere</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> - check_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> block<span class="Delimiter">,</span> name<span class="Delimiter">);</span> - check_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> block<span class="Delimiter">,</span> name<span class="Delimiter">);</span> + check_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">,</span> name_for_error_messages<span class="Delimiter">);</span> + check_invalid_types<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">,</span> name_for_error_messages<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>value != <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// value 0 = compound types (layer parse_tree) or type ingredients (layer shape_shifting_container)</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> - raise << block << <span class="Constant">"unknown type in "</span> << name << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << location_for_error_messages << <span class="Constant">"unknown type in "</span> << name_for_error_messages << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> </pre> diff --git a/html/033exclusive_container.cc.html b/html/033exclusive_container.cc.html index 589e3075..b2dfb99d 100644 --- a/html/033exclusive_container.cc.html +++ b/html/033exclusive_container.cc.html @@ -74,11 +74,11 @@ get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> tmp<span <span class="Delimiter">}</span> <span class="Delimiter">:(before "End compute_container_sizes Atom Cases")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_exclusive_container_sizes<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_exclusive_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 class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -<span class="Normal">void</span> compute_exclusive_container_sizes<span class="Delimiter">(</span><span class="Normal">const</span> type_info& exclusive_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="Delimiter">{</span> +<span class="Normal">void</span> compute_exclusive_container_sizes<span class="Delimiter">(</span><span class="Normal">const</span> type_info& exclusive_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 class="Comment">// size of an exclusive container is the size of its largest variant</span> <span class="Comment">// (So, like containers, it can only contain arrays if they're static and</span> <span class="Comment">// include their length in the type.)</span> @@ -86,7 +86,7 @@ get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> tmp<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 < SIZE<span class="Delimiter">(</span>exclusive_container_info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = exclusive_container_info<span class="Delimiter">.</span>elements<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Comment">// Compute Exclusive Container Size(element, full_type)</span> - compute_container_sizes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Normal">int</span> variant_size = size_of<span class="Delimiter">(</span>element<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>variant_size > metadata<span class="Delimiter">.</span>size<span class="Delimiter">)</span> metadata<span class="Delimiter">.</span>size = variant_size<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/034address.cc.html b/html/034address.cc.html index dadb168a..5d2cc554 100644 --- a/html/034address.cc.html +++ b/html/034address.cc.html @@ -165,11 +165,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="traceContains">+mem: storing 0 in location 3</span> +<span class="Delimiter">:(scenario new_array)</span> +<span class="Comment"># call 'new' with a second ingredient to allocate an array of some type rather than a single copy</span> +<span class="muRecipe">def</span> main [ + <span class="Constant">1</span>:address:array:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span><span class="Delimiter">,</span> <span class="Constant">5</span> + <span class="Constant">2</span>:address:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> + <span class="Constant">3</span>:num/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:array:num/<span class="Special">raw</span> +] +<span class="traceContains">+run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"}</span> +<span class="traceContains">+mem: array length is 5</span> +<span class="Comment"># don't forget the extra location for array length, and the second extra location for the refcount</span> +<span class="traceContains">+mem: storing 7 in location 3</span> + <span class="Delimiter">:(scenario dilated_reagent_with_new)</span> <span class="muRecipe">def</span> main [ <span class="Constant">1</span>:address:address:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> ] -<span class="traceContains">+new: size of ("address" "number") is 1</span> +<span class="traceContains">+new: size of '(address number)' is 1</span> <span class="Comment">//: 'new' takes a weird 'type' as its first ingredient; don't error on it</span> <span class="Delimiter">:(before "End Mu Types Initialization")</span> @@ -196,6 +208,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'new' should be a type, but got '"</span> << type<span class="Delimiter">.</span>original_string << <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> + <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span> && !is_mu_number<span class="Delimiter">(</span>inst<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="Delimiter">{</span> + raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"second ingredient of 'new' should be a number (array length), but got '"</span> << type<span class="Delimiter">.</span>original_string << <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> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"result of 'new' should never be ignored</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -236,12 +252,25 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">delete</span> tmp<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(scenario new_returns_incorrect_type)</span> +<span class="Special">% Hide_errors = true;</span> +<span class="muRecipe">def</span> main [ + <span class="Constant">1</span>:<span class="Normal">bool</span><span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">num:type</span> +] +<span class="traceContains">+error: main: product of 'new' has incorrect type: '1:bool <- new num:type'</span> + <span class="Delimiter">:(scenario new_with_type_abbreviation)</span> <span class="muRecipe">def</span> main [ <span class="Constant">1</span>:address:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">num:type</span> ] $error: <span class="Constant">0</span> +<span class="Delimiter">:(scenario new_with_type_abbreviation_inside_compound)</span> +<span class="muRecipe">def</span> main [ + <span class="Delimiter">{</span><span class="Constant">1</span>: <span class="Delimiter">(</span>address address number<span class="Delimiter">),</span> <span class="Special">raw</span>: <span class="Delimiter">()}</span><span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>& num<span class="Delimiter">)</span>: type<span class="Delimiter">}</span> +] +$error: <span class="Constant">0</span> + <span class="Comment">//: To implement 'new', a Mu transform turns all 'new' instructions into</span> <span class="Comment">//: 'allocate' instructions that precompute the amount of memory they want to</span> <span class="Comment">//: allocate.</span> @@ -270,13 +299,10 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Comment">// Convert 'new' To 'allocate'</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"new"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> inst<span class="Delimiter">.</span>operation = ALLOCATE<span class="Delimiter">;</span> - string_tree* type_name = <span class="Normal">new</span> string_tree<span class="Delimiter">(</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>name<span class="Delimiter">);</span> - type_name = parse_string_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">);</span> - type_tree* type = new_type_tree<span class="Delimiter">(</span>type_name<span class="Delimiter">);</span> + type_tree* type = new_type_tree<span class="Delimiter">(</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>name<span class="Delimiter">);</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>set_value<span class="Delimiter">(</span>size_of<span class="Delimiter">(</span>type<span class="Delimiter">));</span> - trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"new"</span><span class="Delimiter">)</span> << <span class="Constant">"size of "</span> << to_string<span class="Delimiter">(</span>type_name<span class="Delimiter">)</span> << <span class="Constant">" is "</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>value << end<span class="Delimiter">();</span> + trace<span class="Delimiter">(</span><span class="Constant">9992</span><span class="Delimiter">,</span> <span class="Constant">"new"</span><span class="Delimiter">)</span> << <span class="Constant">"size of '"</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>name << <span class="Constant">"' is "</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>value << end<span class="Delimiter">();</span> <span class="Normal">delete</span> type<span class="Delimiter">;</span> - <span class="Normal">delete</span> type_name<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -382,15 +408,22 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span ] <span class="traceContains">+mem: storing 0 in location 10</span> -<span class="Delimiter">:(scenario new_array)</span> +<span class="Delimiter">:(scenario new_size)</span> +<span class="muRecipe">def</span> main [ + <span class="Constant">11</span>:address:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> + <span class="Constant">12</span>:address:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> + <span class="Constant">13</span>:num/<span class="Special">raw <- </span>subtract <span class="Constant">12</span>:address:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">11</span>:address:num/<span class="Special">raw</span> +] +<span class="Comment"># size of number + refcount</span> +<span class="traceContains">+mem: storing 2 in location 13</span> + +<span class="Delimiter">:(scenario new_array_size)</span> <span class="muRecipe">def</span> main [ <span class="Constant">1</span>:address:array:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span><span class="Delimiter">,</span> <span class="Constant">5</span> <span class="Constant">2</span>:address:num/<span class="Special">raw <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span class="Constant">3</span>:num/<span class="Special">raw <- </span>subtract <span class="Constant">2</span>:address:num/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:array:num/<span class="Special">raw</span> ] -<span class="traceContains">+run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"}</span> -<span class="traceContains">+mem: array length is 5</span> -<span class="Comment"># don't forget the extra location for array length, and the second extra location for the refcount</span> +<span class="Comment"># 5 locations for array contents + array length + refcount</span> <span class="traceContains">+mem: storing 7 in location 3</span> <span class="Delimiter">:(scenario new_empty_array)</span> diff --git a/html/036refcount.cc.html b/html/036refcount.cc.html index 95e1bf03..54c790d3 100644 --- a/html/036refcount.cc.html +++ b/html/036refcount.cc.html @@ -328,65 +328,65 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9993</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"- compute address offsets for "</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << end<span class="Delimiter">();</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 < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - compute_container_address_offsets<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + compute_container_address_offsets<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">" in '"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</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 < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> - compute_container_address_offsets<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + compute_container_address_offsets<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">" in '"</span>+to_original_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span>+<span class="Constant">"'"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> compute_container_address_offsets<span class="Delimiter">(</span>reagent& r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_container_address_offsets<span class="Delimiter">(</span>reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">)</span> || is_dummy<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">.</span>type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> r<span class="Delimiter">.</span>type<span class="Delimiter">))</span> r<span class="Delimiter">.</span>metadata = get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> r<span class="Delimiter">.</span>type<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// the recursive structure of this function needs to exactly match</span> <span class="Comment">// compute_container_sizes</span> -<span class="Normal">void</span> compute_container_address_offsets<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_container_address_offsets<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>atom<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"address"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_address_offsets<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">-></span>name == <span class="Constant">"array"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> type_tree* element_type = type<span class="Delimiter">-></span>right<span class="Delimiter">;</span> <span class="Comment">// hack: support both array:num:3 and array:address:num</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!element_type<span class="Delimiter">-></span>atom && element_type<span class="Delimiter">-></span>right && element_type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>atom && is_integer<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name<span class="Delimiter">))</span> element_type = element_type<span class="Delimiter">-></span>left<span class="Delimiter">;</span> - compute_container_address_offsets<span class="Delimiter">(</span>element_type<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>element_type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// End compute_container_address_offsets Non-atom Cases</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root_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> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root_type<span class="Delimiter">(</span>type<span class="Delimiter">)-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_exclusive_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">);</span> + compute_exclusive_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> compute_container_address_offsets<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> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_container_address_offsets<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> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> container_metadata& metadata = get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> full_type<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!metadata<span class="Delimiter">.</span>address<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9994</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"compute address offsets for container "</span> << container_info<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> - append_addresses<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">());</span> + append_addresses<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">(),</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> compute_exclusive_container_address_offsets<span class="Delimiter">(</span><span class="Normal">const</span> type_info& exclusive_container_info<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* full_type<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> compute_exclusive_container_address_offsets<span class="Delimiter">(</span><span class="Normal">const</span> type_info& exclusive_container_info<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* full_type<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> container_metadata& metadata = get<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">,</span> full_type<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9994</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"compute address offsets for exclusive container "</span> << exclusive_container_info<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> tag = <span class="Constant">0</span><span class="Delimiter">;</span> tag < SIZE<span class="Delimiter">(</span>exclusive_container_info<span class="Delimiter">.</span>elements<span class="Delimiter">);</span> ++tag<span class="Delimiter">)</span> <span class="Delimiter">{</span> set<tag_condition_info> key<span class="Delimiter">;</span> key<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>tag_condition_info<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">tag is at offset</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">,</span> tag<span class="Delimiter">));</span> - append_addresses<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">skip tag offset</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>full_type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> key<span class="Delimiter">);</span> + append_addresses<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">skip tag offset</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>full_type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> key<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Normal">void</span> append_addresses<span class="Delimiter">(</span><span class="Normal">int</span> base_offset<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> map<set<tag_condition_info><span class="Delimiter">,</span> set<address_element_info> >& out<span class="Delimiter">,</span> <span class="Normal">const</span> set<tag_condition_info>& key<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> append_addresses<span class="Delimiter">(</span><span class="Normal">int</span> base_offset<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* type<span class="Delimiter">,</span> map<set<tag_condition_info><span class="Delimiter">,</span> set<address_element_info> >& out<span class="Delimiter">,</span> <span class="Normal">const</span> set<tag_condition_info>& key<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_address<span class="Delimiter">(</span>type<span class="Delimiter">))</span> <span class="Delimiter">{</span> get_or_insert<span class="Delimiter">(</span>out<span class="Delimiter">,</span> key<span class="Delimiter">).</span>insert<span class="Delimiter">(</span>address_element_info<span class="Delimiter">(</span>base_offset<span class="Delimiter">,</span> <span class="Normal">new</span> type_tree<span class="Delimiter">(</span>*type<span class="Delimiter">-></span>right<span class="Delimiter">)));</span> <span class="Identifier">return</span><span class="Delimiter">;</span> @@ -404,7 +404,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa ++curr_offset<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_container<span class="Delimiter">(</span>element<span class="Delimiter">))</span> <span class="Delimiter">{</span> - append_addresses<span class="Delimiter">(</span>curr_offset<span class="Delimiter">,</span> element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> key<span class="Delimiter">);</span> + append_addresses<span class="Delimiter">(</span>curr_offset<span class="Delimiter">,</span> element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> key<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> curr_offset += size_of<span class="Delimiter">(</span>element<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_exclusive_container<span class="Delimiter">(</span>element<span class="Delimiter">))</span> <span class="Delimiter">{</span> @@ -414,7 +414,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa set<tag_condition_info> new_key = key<span class="Delimiter">;</span> new_key<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>tag_condition_info<span class="Delimiter">(</span>curr_offset<span class="Delimiter">,</span> tag<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>out<span class="Delimiter">,</span> new_key<span class="Delimiter">))</span> - append_addresses<span class="Delimiter">(</span>curr_offset+<span class="Comment">/*</span><span class="Comment">skip tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> new_key<span class="Delimiter">);</span> + append_addresses<span class="Delimiter">(</span>curr_offset+<span class="Comment">/*</span><span class="Comment">skip tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> new_key<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> curr_offset += size_of<span class="Delimiter">(</span>element<span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -429,7 +429,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa set<tag_condition_info> new_key = key<span class="Delimiter">;</span> new_key<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>tag_condition_info<span class="Delimiter">(</span>base_offset<span class="Delimiter">,</span> tag<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>out<span class="Delimiter">,</span> new_key<span class="Delimiter">))</span> - append_addresses<span class="Delimiter">(</span>base_offset+<span class="Comment">/*</span><span class="Comment">skip tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> new_key<span class="Delimiter">);</span> + append_addresses<span class="Delimiter">(</span>base_offset+<span class="Comment">/*</span><span class="Comment">skip tag</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">,</span> variant_type<span class="Delimiter">(</span>type<span class="Delimiter">,</span> tag<span class="Delimiter">).</span>type<span class="Delimiter">,</span> out<span class="Delimiter">,</span> new_key<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> @@ -447,9 +447,9 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">int</span> old_size = SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">);</span> <span class="Comment">// define a container with no addresses</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// scan</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> @@ -469,9 +469,9 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// scan</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> @@ -502,12 +502,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" y:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// the reagent we scanned knows it has an address at offset 1</span> @@ -539,12 +539,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" f:foo</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Comment">// nested container containing address</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:bar"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains entries for bar and included types: point and foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> <span class="Comment">// scan</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// the reagent we scanned knows it has an address at offset 2</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">()));</span> @@ -571,12 +571,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan an address to the container</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> @@ -596,12 +596,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:array:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan an array of the container</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> @@ -621,12 +621,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:foo"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan an address to an array of the container</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> @@ -646,12 +646,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:array:foo:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan a static array of the container</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> @@ -671,12 +671,12 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">" x:address:num</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:foo:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scan an address to a static array of the container</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> @@ -697,11 +697,11 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> <span class="Comment">// scan a deep nest of 'address' and 'array' types modifying a container</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:address:array:address:address:array:foo:10"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// need to first pre-populate the metadata</span> <span class="Comment">// global metadata contains just the entry for foo</span> <span class="Comment">// no entries for non-container types or other junk</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> <span class="Comment">// compute_container_address_offsets creates no new entries</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>Container_metadata<span class="Delimiter">)</span>-old_size<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// scanning precomputed metadata for the container</span> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index ca19e9be..9aafaebf 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -201,6 +201,10 @@ Hide_missing_default_space_errors = <span class="Constant">false</span><span cla <span class="Delimiter">:(after "Test Runs")</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 < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == argv[argc-<span class="Constant">1</span>]<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>Start_tracing<span class="Delimiter">)</span> <span class="Delimiter">{</span> + Trace_stream = <span class="Normal">new</span> trace_stream<span class="Delimiter">;</span> + Save_trace = <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> run_mu_scenario<span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Passed<span class="Delimiter">)</span> cerr << <span class="Constant">".</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span> diff --git a/html/055shape_shifting_container.cc.html b/html/055shape_shifting_container.cc.html index 77aa6e8a..8d8b3545 100644 --- a/html/055shape_shifting_container.cc.html +++ b/html/055shape_shifting_container.cc.html @@ -261,6 +261,10 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="Comment"># no other stores</span> <span class="Special">% CHECK_EQ(trace_count_prefix("mem", "storing"), 7);</span> +<span class="Delimiter">:(before "End variant_type Special-cases")</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient<span class="Delimiter">(</span>element<span class="Delimiter">))</span> + replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> info<span class="Delimiter">,</span> <span class="Constant">" while computing variant type of exclusive-container"</span><span class="Delimiter">);</span> + <span class="Delimiter">:(scenario get_on_shape_shifting_container)</span> <span class="muData">container</span> foo:_t [ <span class="Normal">x</span>:_t @@ -324,24 +328,15 @@ map<string<span class="Delimiter">,</span> type_ordinal> type_ingredient_n <span class="traceContains">+mem: storing 1 in location 4</span> <span class="Delimiter">:(before "End element_type Special-cases")</span> -replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> type<span class="Delimiter">,</span> info<span class="Delimiter">);</span> +replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> type<span class="Delimiter">,</span> info<span class="Delimiter">,</span> <span class="Constant">" while computing element type of container"</span><span class="Delimiter">);</span> <span class="Delimiter">:(before "Compute Container Size(element, full_type)")</span> -replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> container_info<span class="Delimiter">);</span> +replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> container_info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">:(before "Compute Exclusive Container Size(element, full_type)")</span> -replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> exclusive_container_info<span class="Delimiter">);</span> +replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> full_type<span class="Delimiter">,</span> exclusive_container_info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Delimiter">:(before "Compute Container Address Offset(element)")</span> -replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> type<span class="Delimiter">,</span> info<span class="Delimiter">);</span> +replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">,</span> type<span class="Delimiter">,</span> info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient<span class="Delimiter">(</span>element<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// error raised elsewhere</span> -<span class="Delimiter">:(code)</span> -<span class="Normal">void</span> replace_type_ingredients<span class="Delimiter">(</span>reagent& element<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* caller_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& info<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient<span class="Delimiter">(</span>element<span class="Delimiter">))</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!caller_type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> - raise << <span class="Constant">"illegal type "</span> << names_to_string<span class="Delimiter">(</span>caller_type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> caller_type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> info<span class="Delimiter">);</span> - <span class="Delimiter">}</span> -<span class="Delimiter">}</span> - <span class="Delimiter">:(after "Compute size_of Container")</span> assert<span class="Delimiter">(</span>!contains_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">));</span> <span class="Delimiter">:(after "Compute size_of Exclusive Container")</span> @@ -358,19 +353,27 @@ assert<span class="Delimiter">(</span>!contains_type_ingredient<span class="Deli <span class="Identifier">return</span> contains_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">-></span>left<span class="Delimiter">)</span> || contains_type_ingredient<span class="Delimiter">(</span>type<span class="Delimiter">-></span>right<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Normal">void</span> replace_type_ingredients<span class="Delimiter">(</span>reagent& element<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* caller_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& info<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient<span class="Delimiter">(</span>element<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!caller_type<span class="Delimiter">-></span>right<span class="Delimiter">)</span> + raise << <span class="Constant">"illegal type "</span> << names_to_string<span class="Delimiter">(</span>caller_type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three"</span> << location_for_error_messages << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> caller_type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> + <span class="Comment">// replace all type_ingredients in element_type with corresponding elements of callsite_type</span> -<span class="Normal">void</span> replace_type_ingredients<span class="Delimiter">(</span>type_tree* element_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* callsite_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& container_info<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">void</span> replace_type_ingredients<span class="Delimiter">(</span>type_tree* element_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_tree* callsite_type<span class="Delimiter">,</span> <span class="Normal">const</span> type_info& container_info<span class="Delimiter">,</span> <span class="Normal">const</span> string& location_for_error_messages<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!callsite_type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// error but it's already been raised above</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!element_type<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!element_type<span class="Delimiter">-></span>atom<span class="Delimiter">)</span> <span class="Delimiter">{</span> - replace_type_ingredients<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> callsite_type<span class="Delimiter">,</span> container_info<span class="Delimiter">);</span> - replace_type_ingredients<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> callsite_type<span class="Delimiter">,</span> container_info<span class="Delimiter">);</span> + replace_type_ingredients<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>left<span class="Delimiter">,</span> callsite_type<span class="Delimiter">,</span> container_info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> + replace_type_ingredients<span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> callsite_type<span class="Delimiter">,</span> container_info<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>element_type<span class="Delimiter">-></span>value < START_TYPE_INGREDIENTS<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Normal">const</span> <span class="Normal">int</span> type_ingredient_index = element_type<span class="Delimiter">-></span>value-START_TYPE_INGREDIENTS<span class="Delimiter">;</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!has_nth_type<span class="Delimiter">(</span>callsite_type<span class="Delimiter">,</span> type_ingredient_index<span class="Delimiter">))</span> <span class="Delimiter">{</span> - raise << <span class="Constant">"illegal type "</span> << names_to_string<span class="Delimiter">(</span>callsite_type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise << <span class="Constant">"illegal type "</span> << names_to_string<span class="Delimiter">(</span>callsite_type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three"</span> << location_for_error_messages << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> *element_type = *nth_type_ingredient<span class="Delimiter">(</span>callsite_type<span class="Delimiter">,</span> type_ingredient_index<span class="Delimiter">,</span> container_info<span class="Delimiter">);</span> @@ -517,7 +520,7 @@ assert<span class="Delimiter">(</span>!contains_type_ingredient<span class="Deli <span class="Constant">10</span>:foo:point<span class="Special"> <- </span>merge <span class="Constant">14</span><span class="Delimiter">,</span> <span class="Constant">15</span><span class="Delimiter">,</span> <span class="Constant">16</span> <span class="Constant">1</span>:num<span class="Special"> <- </span>get <span class="Constant">10</span>:foo<span class="Delimiter">,</span> <span class="Constant">1:offset</span> ] -<span class="traceContains">+error: illegal type "foo" seems to be missing a type ingredient or three</span> +<span class="traceContains">+error: illegal type "foo" seems to be missing a type ingredient or three in '1:num <- get 10:foo, 1:offset'</span> <span class="SalientComment">//:: fix up previous layers</span> @@ -529,11 +532,11 @@ assert<span class="Delimiter">(</span>!contains_type_ingredient<span class="Deli <span class="Normal">const</span> type_tree* root = root_type<span class="Delimiter">(</span>type<span class="Delimiter">);</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_sizes<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</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 class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_exclusive_container_sizes<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> pending_metadata<span class="Delimiter">);</span> + compute_exclusive_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 class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -544,7 +547,7 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">" y:_t</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -554,10 +557,10 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">" y:_t</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">3</span><span class="Delimiter">);</span> reagent r2<span class="Delimiter">(</span><span class="Constant">"x:foo:num"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r2<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r2<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r2<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -567,7 +570,7 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">" y:_t</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo:&:point"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// scan also pre-computes metadata for type ingredient</span> reagent point<span class="Delimiter">(</span><span class="Constant">"x:point"</span><span class="Delimiter">);</span> @@ -581,7 +584,7 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">" y:&:foo:_t</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r2<span class="Delimiter">(</span><span class="Constant">"x:foo:num"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r2<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r2<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>r2<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">,</span> <span class="Constant">2</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> @@ -589,11 +592,11 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Normal">const</span> type_tree* root = root_type<span class="Delimiter">(</span>type<span class="Delimiter">);</span> type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> root<span class="Delimiter">-></span>value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">if</span> <span class="Delimiter">(</span>info<span class="Delimiter">.</span>kind == EXCLUSIVE_CONTAINER<span class="Delimiter">)</span> <span class="Delimiter">{</span> - compute_exclusive_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">);</span> + compute_exclusive_container_address_offsets<span class="Delimiter">(</span>info<span class="Delimiter">,</span> type<span class="Delimiter">,</span> location_for_error_messages<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -604,8 +607,8 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">" y:_t</span><span class="cSpecial">\n</span><span class="Constant">"</span> <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:foo:&:num"</span><span class="Delimiter">);</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">()));</span> set<address_element_info>& offset_info = get<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">());</span> @@ -626,8 +629,8 @@ type_info& info = get<span class="Delimiter">(</span>Type<span class="Delimi <span class="Constant">"]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> reagent r<span class="Delimiter">(</span><span class="Constant">"x:bar:&:num"</span><span class="Delimiter">);</span> CLEAR_TRACE<span class="Delimiter">;</span> - compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">);</span> - compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">);</span> + compute_container_sizes<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> + compute_container_address_offsets<span class="Delimiter">(</span>r<span class="Delimiter">,</span> <span class="Constant">""</span><span class="Delimiter">);</span> CHECK_EQ<span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">),</span> <span class="Constant">1</span><span class="Delimiter">);</span> CHECK<span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">()));</span> set<address_element_info>& offset_info = get<span class="Delimiter">(</span>r<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>address<span class="Delimiter">,</span> set<tag_condition_info><span class="Delimiter">());</span> @@ -719,13 +722,6 @@ $error: <span class="Constant">0</span> <span class="Constant">1</span>:foo:bar<span class="Special"> <- </span>merge <span class="Constant">1</span>/y<span class="Delimiter">,</span> <span class="Constant">23</span> ] <span class="traceContains">+error: main: too few ingredients in '1:foo:bar <- merge 1/y, 23'</span> - -<span class="Delimiter">:(before "End variant_type Special-cases")</span> -<span class="Normal">if</span> <span class="Delimiter">(</span>contains_type_ingredient<span class="Delimiter">(</span>element<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> - raise << <span class="Constant">"illegal type "</span> << to_string<span class="Delimiter">(</span>type<span class="Delimiter">)</span> << <span class="Constant">" seems to be missing a type ingredient or three</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> - replace_type_ingredients<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">,</span> type<span class="Delimiter">-></span>right<span class="Delimiter">,</span> info<span class="Delimiter">);</span> -<span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/072scheduler.cc.html b/html/072scheduler.cc.html index 7d1734cf..33bf23c0 100644 --- a/html/072scheduler.cc.html +++ b/html/072scheduler.cc.html @@ -169,6 +169,8 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">1</span><span class="Delimiter">;</span> i < argc<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> vector<<span class="Normal">double</span>> arg<span class="Delimiter">;</span> arg<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>new_mu_text<span class="Delimiter">(</span>argv[i]<span class="Delimiter">));</span> + assert<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> arg<span class="Delimiter">.</span>back<span class="Delimiter">())</span> == <span class="Constant">0</span><span class="Delimiter">);</span> + put<span class="Delimiter">(</span>Memory<span class="Delimiter">,</span> arg<span class="Delimiter">.</span>back<span class="Delimiter">(),</span> <span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// update refcount</span> current_call<span class="Delimiter">().</span>ingredient_atoms<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>arg<span class="Delimiter">);</span> <span class="Delimiter">}</span> run<span class="Delimiter">(</span>main_routine<span class="Delimiter">);</span> |