diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-09 02:56:27 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-09 02:56:27 -0800 |
commit | 4690ce81e079fc58cae8d6d583e5e3eb3ed81a83 (patch) | |
tree | b62ebb7e9a7fb88f8db3a168354acfebced83dd2 /html/046global.cc.html | |
parent | 1d079fc574a35f39fd52e3de23a1c8bfa45238ae (diff) | |
download | mu-4690ce81e079fc58cae8d6d583e5e3eb3ed81a83.tar.gz |
2743
Looks like "TOhtml | <other command>" doesn't work on Mac OS X for some reason..
Diffstat (limited to 'html/046global.cc.html')
-rw-r--r-- | html/046global.cc.html | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/html/046global.cc.html b/html/046global.cc.html index 75d02253..152b0d97 100644 --- a/html/046global.cc.html +++ b/html/046global.cc.html @@ -3,41 +3,40 @@ <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Mu - 046global.cc</title> -<meta name="Generator" content="Vim/7.4"> -<meta name="plugin-version" content="vim7.4_v1"> +<meta name="Generator" content="Vim/7.3"> +<meta name="plugin-version" content="vim7.3_v6"> <meta name="syntax" content="cpp"> -<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> -<meta name="colorscheme" content="minimal"> +<meta name="settings" content="use_css"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } +pre { font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } -* { font-size: 1.05em; } -.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Comment { color: #9090ff; } -.Delimiter { color: #a04060; } -.Special { color: #ff6060; } .Identifier { color: #804000; } +.traceContains { color: #008000; } +.Normal { color: #eeeeee; background-color: #080808; } +.Special { color: #ff6060; } .Constant { color: #00a0a0; } +.Delimiter { color: #a04060; } +.Comment { color: #9090ff; } --> </style> - -<script type='text/javascript'> -<!-- - ---> -</script> </head> <body> -<pre id='vimCodeElement'> -<span class="Comment">// So far we have local variables, and we can nest local variables of short</span> -<span class="Comment">// lifetimes inside longer ones. Now let's support 'global' variables that</span> -<span class="Comment">// last for the life of a routine. If we create multiple routines they won't</span> -<span class="Comment">// have access to each other's globals.</span> +<pre> +<span class="Comment">//: So far we have local variables, and we can nest local variables of short</span> +<span class="Comment">//: lifetimes inside longer ones. Now let's support 'global' variables that</span> +<span class="Comment">//: last for the life of a routine. If we create multiple routines they won't</span> +<span class="Comment">//: have access to each other's globals.</span> +<span class="Comment">//:</span> +<span class="Comment">//: This feature is still experimental and half-baked. You can't name global</span> +<span class="Comment">//: variables, and so like in most tests they don't get checked for types (the</span> +<span class="Comment">//: only known hole in the type system, can cause memory corruption). We might</span> +<span class="Comment">//: fix these issues if we ever use globals. Or we might just drop the feature</span> +<span class="Comment">//: entirely.</span> <span class="Delimiter">:(scenario global_space)</span> -recipe main [ +def main [ <span class="Comment"># pretend shared:array:location; in practice we'll use new</span> <span class="Constant">10</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> @@ -46,7 +45,7 @@ recipe main [ <span class="Constant">21</span>:number<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> global-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe - default-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">1</span>:number/space:global<span class="Special"> <- </span>copy <span class="Constant">24</span> ] @@ -57,19 +56,19 @@ recipe main [ <span class="Comment">//: to support it, create another special variable called global space</span> <span class="Delimiter">:(before "End is_disqualified Cases")</span> -if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"global-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> -if <span class="Delimiter">(</span>s == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>s == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="Comment">//: writes to this variable go to a field in the current routine</span> <span class="Delimiter">:(before "End routine Fields")</span> -long long int global_space<span class="Delimiter">;</span> +<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> global_space<span class="Delimiter">;</span> <span class="Delimiter">:(before "End routine Constructor")</span> global_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">:(after "void write_memory(reagent x, vector<double> data)")</span> - if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>name == <span class="Constant">"global-space"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!scalar<span class="Delimiter">(</span>data<span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right @@ -79,19 +78,19 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'global-space' should be of type address:shared:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'global-space' should be of type address:shared:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> - if <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> - raise_error << <span class="Constant">"routine already has a global-space; you can't over-write your globals"</span> << end<span class="Delimiter">();</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> + raise << <span class="Constant">"routine already has a global-space; you can't over-write your globals"</span> << end<span class="Delimiter">();</span> Current_routine<span class="Delimiter">-></span>global_space = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">//: now marking variables as /space:global looks them up inside this field</span> <span class="Delimiter">:(after "long long int space_base(const reagent& x)")</span> - if <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> - raise_error << <span class="Constant">"routine has no global space</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>global_space<span class="Delimiter">)</span> + raise << <span class="Constant">"routine has no global space</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>global_space + <span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -99,8 +98,8 @@ global_space = <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Comment">//: don't want to make them too comfortable to use.</span> <span class="Delimiter">:(scenario global_space_with_names)</span> -recipe main [ - global-space:address:shared:array:location<span class="Special"> <- </span>new location:type<span class="Delimiter">,</span> <span class="Constant">10</span> +def main [ + global-space:address:shared:array:location<span class="Special"> <- </span><span class="Normal">new</span> location:type<span class="Delimiter">,</span> <span class="Constant">10</span> x:number<span class="Special"> <- </span>copy <span class="Constant">23</span> <span class="Constant">1</span>:number/space:global<span class="Special"> <- </span>copy <span class="Constant">24</span> ] @@ -108,14 +107,14 @@ recipe main [ $error: <span class="Constant">0</span> <span class="Delimiter">:(after "bool is_numeric_location(const reagent& x)")</span> - if <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_global<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">//: helpers</span> <span class="Delimiter">:(code)</span> -bool is_global<span class="Delimiter">(</span>const reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first == <span class="Constant">"space"</span><span class="Delimiter">)</span> +<span class="Normal">bool</span> is_global<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>first == <span class="Constant">"space"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second && x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>second<span class="Delimiter">-></span>value == <span class="Constant">"global"</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> @@ -123,4 +122,3 @@ bool is_global<span class="Delimiter">(</span>const reagent& x<span class="D </pre> </body> </html> -<!-- vim: set foldmethod=manual : --> |