about summary refs log tree commit diff stats
path: root/html/043space.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-17 15:01:51 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-17 15:01:51 -0700
commitf344b250f6f062a1a1902bf69b23ebf9b565de0e (patch)
tree199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/043space.cc.html
parent897ae8c1855f830d8819759ea327d147f28a09bf (diff)
downloadmu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz
3395
Diffstat (limited to 'html/043space.cc.html')
-rw-r--r--html/043space.cc.html116
1 files changed, 61 insertions, 55 deletions
diff --git a/html/043space.cc.html b/html/043space.cc.html
index 221f4ff2..036f7def 100644
--- a/html/043space.cc.html
+++ b/html/043space.cc.html
@@ -38,29 +38,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="Comment">//: and all addresses in arguments are implicitly based on the 'default-space'</span>
 <span class="Comment">//: (unless they have the /raw property)</span>
 
+<span class="Comment">//: A space is just an array of any scalar location.</span>
+<span class="Delimiter">:(before &quot;End Mu Types Initialization&quot;)</span>
+put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;space&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;address:array:location&quot;</span><span class="Delimiter">));</span>
+<span class="Comment">//: Spaces are often called 'scopes' in other languages.</span>
+put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</span> <span class="Constant">&quot;scope&quot;</span><span class="Delimiter">,</span> new_type_tree<span class="Delimiter">(</span><span class="Constant">&quot;address:array:location&quot;</span><span class="Delimiter">));</span>
+
 <span class="Delimiter">:(scenario set_default_space)</span>
 <span class="Comment"># if default-space is 10, and if an array of 5 locals lies from location 12 to 16 (inclusive),</span>
 <span class="Comment"># then local 0 is really location 12, local 1 is really location 13, and so on.</span>
 def main [
   <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
-  <span class="Constant">10</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
-  <span class="Constant">11</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
-  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
-  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>
+  <span class="Constant">10</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
+  <span class="Constant">11</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
+  <span class="Normal">default</span>-space:space<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
+  <span class="Constant">1</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>
 ]
 <span class="traceContains">+mem: storing 23 in location 13</span>
 
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space)</span>
 def main [
   <span class="Comment"># pretend pointer from outside (2000 reserved for refcount)</span>
-  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Constant">2001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
   <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
-  <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
-  <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
+  <span class="Constant">1000</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
+  <span class="Constant">1001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe  <span class="Comment"># even local variables always contain raw addresses</span>
-  <span class="Constant">8</span>:number/<span class="Special">raw &lt;- </span>copy *<span class="Constant">1</span>:address:number
+  <span class="Normal">default</span>-space:space<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:&amp;:num<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe  <span class="Comment"># even local variables always contain raw addresses</span>
+  <span class="Constant">8</span>:num/<span class="Special">raw &lt;- </span>copy *<span class="Constant">1</span>:&amp;:num
 ]
 <span class="traceContains">+mem: storing 34 in location 8</span>
 
@@ -68,7 +74,7 @@ def main [
 <span class="Delimiter">:(scenario convert_names_passes_default_space)</span>
 <span class="Special">% Hide_errors = true;</span>
 def main [
-  <span class="Normal">default</span>-space:number<span class="Delimiter">,</span> x:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>
+  <span class="Normal">default</span>-space:num<span class="Delimiter">,</span> x:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span>
 ]
 <span class="traceContains">+name: assign x 1</span>
 <span class="traceAbsent">-name: assign default-space 1</span>
@@ -131,8 +137,8 @@ absolutize<span class="Delimiter">(</span>x<span class="Delimiter">);</span>
 
 <span class="Delimiter">:(scenario get_default_space)</span>
 def main [
-  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
-  <span class="Constant">1</span>:address:array:location/<span class="Special">raw &lt;- </span>copy <span class="Normal">default</span>-space:address:array:location
+  <span class="Normal">default</span>-space:space<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
+  <span class="Constant">1</span>:space/<span class="Special">raw &lt;- </span>copy <span class="Normal">default</span>-space:space
 ]
 <span class="traceContains">+mem: storing 10 in location 1</span>
 
@@ -148,15 +154,15 @@ def main [
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space_in_get)</span>
 def main [
   <span class="Comment"># pretend pointer to container from outside (2000 reserved for refcount)</span>
-  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Constant">2002</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
+  <span class="Constant">2001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Constant">2002</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
   <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
-  <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
-  <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
+  <span class="Constant">1000</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
+  <span class="Constant">1001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:point<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
-  <span class="Constant">9</span>:number/<span class="Special">raw &lt;- </span>get *<span class="Constant">1</span>:address:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset
+  <span class="Normal">default</span>-space:space<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:&amp;:point<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
+  <span class="Constant">9</span>:num/<span class="Special">raw &lt;- </span>get *<span class="Constant">1</span>:&amp;:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset
 ]
 <span class="traceContains">+mem: storing 35 in location 9</span>
 
@@ -168,16 +174,16 @@ element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space_in_index)</span>
 def main [
   <span class="Comment"># pretend pointer to array from outside (2000 reserved for refcount)</span>
-  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>  <span class="Comment"># length</span>
-  <span class="Constant">2002</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Constant">2003</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
+  <span class="Constant">2001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>  <span class="Comment"># length</span>
+  <span class="Constant">2002</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Constant">2003</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
   <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
-  <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
-  <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
+  <span class="Constant">1000</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
+  <span class="Constant">1001</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:array:number<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
-  <span class="Constant">9</span>:number/<span class="Special">raw &lt;- </span>index *<span class="Constant">1</span>:address:array:number<span class="Delimiter">,</span> <span class="Constant">1</span>
+  <span class="Normal">default</span>-space:space<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:&amp;:@:num<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
+  <span class="Constant">9</span>:num/<span class="Special">raw &lt;- </span>index *<span class="Constant">1</span>:&amp;:@:num<span class="Delimiter">,</span> <span class="Constant">1</span>
 ]
 <span class="traceContains">+mem: storing 35 in location 9</span>
 
@@ -190,8 +196,8 @@ element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span
 <span class="Delimiter">:(scenario new_default_space)</span>
 def main [
   <span class="Normal">new</span>-<span class="Normal">default</span>-space
-  <span class="Normal">x</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  <span class="Normal">y</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">3</span>
+  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="Normal">y</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">3</span>
 ]
 <span class="Comment"># allocate space for x and y, as well as the chaining slot at 0</span>
 <span class="traceContains">+mem: array length is 3</span>
@@ -204,7 +210,7 @@ def main [
 
 <span class="Delimiter">:(before &quot;End Rewrite Instruction(curr, recipe result)&quot;)</span>
 <span class="Comment">// rewrite `new-default-space` to</span>
-<span class="Comment">//   `default-space:address:array:location &lt;- new location:type, number-of-locals:literal`</span>
+<span class="Comment">//   `default-space:space &lt;- new location:type, number-of-locals:literal`</span>
 <span class="Comment">// where N is Name[recipe][&quot;&quot;]</span>
 <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;new-default-space&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
   rewrite_default_space_instruction<span class="Delimiter">(</span>curr<span class="Delimiter">);</span>
@@ -228,14 +234,14 @@ def main [
 
 <span class="Delimiter">:(scenario local_scope)</span>
 def main [
-  <span class="Constant">1</span>:address<span class="Special"> &lt;- </span>foo
-  <span class="Constant">2</span>:address<span class="Special"> &lt;- </span>foo
-  <span class="Constant">3</span>:boolean<span class="Special"> &lt;- </span>equal <span class="Constant">1</span>:address<span class="Delimiter">,</span> <span class="Constant">2</span>:address
+  <span class="Constant">1</span>:&amp;<span class="Special"> &lt;- </span>foo
+  <span class="Constant">2</span>:&amp;<span class="Special"> &lt;- </span>foo
+  <span class="Constant">3</span>:<span class="Normal">bool</span><span class="Special"> &lt;- </span>equal <span class="Constant">1</span>:&amp;<span class="Delimiter">,</span> <span class="Constant">2</span>:&amp;
 ]
 def foo [
   local-scope
-  <span class="Normal">x</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Identifier">return</span> <span class="Normal">default</span>-space:address:array:location
+  <span class="Normal">x</span>:num<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Identifier">return</span> <span class="Normal">default</span>-space:space
 ]
 <span class="Comment"># both calls to foo should have received the same default-space</span>
 <span class="traceContains">+mem: storing 1 in location 3</span>
@@ -243,9 +249,9 @@ def foo [
 <span class="Delimiter">:(scenario local_scope_frees_up_addresses)</span>
 def main [
   local-scope
-  <span class="Normal">x</span>:address:array:character<span class="Special"> &lt;- </span><span class="Normal">new</span> [abc]
+  <span class="Normal">x</span>:text<span class="Special"> &lt;- </span><span class="Normal">new</span> [abc]
 ]
-<span class="traceContains">+mem: clearing x:address:array:character</span>
+<span class="traceContains">+mem: clearing x:text</span>
 
 <span class="Delimiter">:(before &quot;End Rewrite Instruction(curr, recipe result)&quot;)</span>
 <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;local-scope&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
@@ -340,21 +346,21 @@ Update_refcounts_in_write_memory = <span class="Constant">true</span><span class
   curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">&quot;number-of-locals:literal&quot;</span><span class="Delimiter">));</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span>
     raise &lt;&lt; <span class="Constant">&quot;new-default-space can't take any results</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; 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">&quot;default-space:address:array:location&quot;</span><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">&quot;default-space:space&quot;</span><span class="Delimiter">));</span>
 <span class="Delimiter">}</span>
 
 <span class="Delimiter">:(scenario local_scope_frees_up_addresses_inside_containers)</span>
 container foo [
-  <span class="Normal">x</span>:number
-  <span class="Normal">y</span>:address:number
+  <span class="Normal">x</span>:num
+  <span class="Normal">y</span>:&amp;:num
 ]
 def main [
   local-scope
-  <span class="Normal">x</span>:address:number<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
-  <span class="Normal">y</span>:foo<span class="Special"> &lt;- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> x:address:number
+  <span class="Normal">x</span>:&amp;:num<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
+  <span class="Normal">y</span>:foo<span class="Special"> &lt;- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> x:&amp;:num
   <span class="Comment"># x and y are both cleared when main returns</span>
 ]
-<span class="traceContains">+mem: clearing x:address:number</span>
+<span class="traceContains">+mem: clearing x:&amp;:num</span>
 <span class="traceContains">+mem: decrementing refcount of 1006: 2 -&gt; 1</span>
 <span class="traceContains">+mem: clearing y:foo</span>
 <span class="traceContains">+mem: decrementing refcount of 1006: 1 -&gt; 0</span>
@@ -362,24 +368,24 @@ def main [
 
 <span class="Delimiter">:(scenario local_scope_returns_addresses_inside_containers)</span>
 container foo [
-  <span class="Normal">x</span>:number
-  <span class="Normal">y</span>:address:number
+  <span class="Normal">x</span>:num
+  <span class="Normal">y</span>:&amp;:num
 ]
 def f [
   local-scope
-  <span class="Normal">x</span>:address:number<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
-  *x:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
-  <span class="Normal">y</span>:foo<span class="Special"> &lt;- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> x:address:number
+  <span class="Normal">x</span>:&amp;:num<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
+  *x:&amp;:num<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+  <span class="Normal">y</span>:foo<span class="Special"> &lt;- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> x:&amp;:num
   <span class="Comment"># since y is 'escaping' f, it should not be cleared</span>
   <span class="Identifier">return</span> y:foo
 ]
 def main [
   <span class="Constant">1</span>:foo<span class="Special"> &lt;- </span>f
-  <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>get <span class="Constant">1</span>:foo<span class="Delimiter">,</span> x:offset
-  <span class="Constant">4</span>:address:number<span class="Special"> &lt;- </span>get <span class="Constant">1</span>:foo<span class="Delimiter">,</span> y:offset
-  <span class="Constant">5</span>:number<span class="Special"> &lt;- </span>copy *<span class="Constant">4</span>:address:number
+  <span class="Constant">3</span>:num<span class="Special"> &lt;- </span>get <span class="Constant">1</span>:foo<span class="Delimiter">,</span> x:offset
+  <span class="Constant">4</span>:&amp;:num<span class="Special"> &lt;- </span>get <span class="Constant">1</span>:foo<span class="Delimiter">,</span> y:offset
+  <span class="Constant">5</span>:num<span class="Special"> &lt;- </span>copy *<span class="Constant">4</span>:&amp;:num
   <span class="Constant">1</span>:foo<span class="Special"> &lt;- </span>put <span class="Constant">1</span>:foo<span class="Delimiter">,</span> y:offset<span class="Delimiter">,</span> <span class="Constant">0</span>
-  <span class="Constant">4</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="Constant">4</span>:&amp;:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 <span class="traceContains">+mem: storing 34 in location 1</span>
 <span class="traceContains">+mem: storing 1006 in location 2</span>
@@ -399,8 +405,8 @@ def main [
 <span class="Delimiter">:(scenario local_scope_claims_return_values_when_not_saved)</span>
 def f [
   local-scope
-  <span class="Normal">x</span>:address:number<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
-  reply x:address:number
+  <span class="Normal">x</span>:&amp;:num<span class="Special"> &lt;- </span><span class="Normal">new</span> number:type
+  reply x:&amp;:num
 ]
 def main [
   f  <span class="Comment"># doesn't save result</span>