diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-02 09:59:40 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-02 09:59:40 -0800 |
commit | b2566a847948ba808d4ca93d02bcc62ee6487255 (patch) | |
tree | d5c983969695b271b4821d90f0354af317d76891 /html/043space.cc.html | |
parent | 67d2a9c07dea2f100f526cf6cd0831b544cd73fa (diff) | |
download | mu-b2566a847948ba808d4ca93d02bcc62ee6487255.tar.gz |
2625
Diffstat (limited to 'html/043space.cc.html')
-rw-r--r-- | html/043space.cc.html | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/html/043space.cc.html b/html/043space.cc.html index 7f14f589..36e41bc1 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -22,6 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Special { color: #ff6060; } .Identifier { color: #804000; } .Constant { color: #00a0a0; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -72,7 +73,7 @@ recipe main [ <span class="traceContains">+name: assign x 1</span> <span class="traceAbsent">-name: assign default-space 1</span> -<span class="Delimiter">:(before "End Disqualified Reagents")</span> +<span class="Delimiter">:(before "End is_disqualified Cases")</span> if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"default-space"</span><span class="Delimiter">)</span> x<span class="Delimiter">.</span>initialized = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End is_special_name Cases")</span> @@ -201,7 +202,7 @@ recipe main [ <span class="Comment"># allocate space for x and y, as well as the chaining slot at 0</span> <span class="traceContains">+mem: array size is 3</span> -<span class="Delimiter">:(before "End Disqualified Reagents")</span> +<span class="Delimiter">:(before "End is_disqualified Cases")</span> if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"number-of-locals"</span><span class="Delimiter">)</span> x<span class="Delimiter">.</span>initialized = <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End is_special_name Cases")</span> @@ -278,6 +279,50 @@ void rewrite_default_space_instruction<span class="Delimiter">(</span>instructio raise_error << <span class="Constant">"new-default-space can't take any results</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"default-space:address:shared:array:location"</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> + +<span class="SalientComment">//:: all recipes must set default-space one way or another</span> + +<span class="Delimiter">:(before "End Globals")</span> +bool Warn_on_missing_default_space = <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Checks")</span> +Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_default_space<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> +<span class="Delimiter">:(code)</span> +void check_default_space<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Warn_on_missing_default_space<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip previous core tests; this is only for mu code</span> + const recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> + <span class="Comment">// skip scenarios (later layer)</span> + <span class="Comment">// user code should never create recipes with underscores in their names</span> + if <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"scenario_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip mu scenarios which will use raw memory locations</span> + if <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"run_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip calls to 'run', which should be in scenarios and will also use raw memory locations</span> + <span class="Comment">// assume recipes with only numeric addresses know what they're doing (usually tests)</span> + if <span class="Delimiter">(</span>!contains_non_special_name<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check that recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" sets default-space"</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">()</span> + || caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name != <span class="Constant">"default-space"</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">" does not seem to start with default-space or local-scope</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span class="CommentedCode">//? cerr << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << '\n';</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(after "Load .mu Core")</span> +Warn_on_missing_default_space = <span class="Constant">true</span><span class="Delimiter">;</span> +<span class="Delimiter">:(after "Test Runs")</span> +Warn_on_missing_default_space = <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">:(after "Running Main")</span> +Warn_on_missing_default_space = <span class="Constant">true</span><span class="Delimiter">;</span> + +<span class="Delimiter">:(code)</span> +bool contains_non_special_name<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> long long int>::iterator p = Name[r]<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != Name[r]<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"stash_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// generated by rewrite_stashes_to_text</span> + if <span class="Delimiter">(</span>!is_special_name<span class="Delimiter">(</span>p<span class="Delimiter">-></span>first<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << " " << Recipe[r].name << ": " << p->first << '\n';</span> + <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> </pre> </body> </html> |