about summary refs log tree commit diff stats
path: root/059shape_shifting_recipe.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-19 23:18:03 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-19 23:18:03 -0800
commit455fbac64f101b05f7eaca89b84470569e4df3fd (patch)
tree32cfd5b092ad86086e4d15992bb10fd06a12bf13 /059shape_shifting_recipe.cc
parent7163e18a774781c62f0c0542e4cb9037f6a71d22 (diff)
downloadmu-455fbac64f101b05f7eaca89b84470569e4df3fd.tar.gz
2576 - distinguish allocated addresses from others
This is the one major refinement on the C programming model I'm planning
to introduce in mu. Instead of Rust's menagerie of pointer types and
static checking, I want to introduce just one new type, and use it to
perform ref-counting at runtime.

So far all we're doing is updating new's interface. The actual
ref-counting implementation is next.

One implication: I might sometimes need duplicate implementations for a
recipe with allocated vs vanilla addresses of the same type. So far it
seems I can get away with just always passing in allocated addresses;
the situations when you want to pass an unallocated address to a recipe
should be few and far between.
Diffstat (limited to '059shape_shifting_recipe.cc')
-rw-r--r--059shape_shifting_recipe.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc
index 6cce844f..3811dd36 100644
--- a/059shape_shifting_recipe.cc
+++ b/059shape_shifting_recipe.cc
@@ -535,14 +535,14 @@ container foo:_t [
 
 :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient)
 recipe main [
-  1:address:foo:point <- bar 3
-  11:foo:point <- copy *1:address:foo:point
+  1:address:shared:foo:point <- bar 3
+  11:foo:point <- copy *1:address:shared:foo:point
 ]
 container foo:_t [
   x:_t
   y:number
 ]
-recipe bar x:number -> result:address:foo:_t [
+recipe bar x:number -> result:address:shared:foo:_t [
   local-scope
   load-ingredients
   # new refers to _t in its ingredient *value*
@@ -554,10 +554,10 @@ recipe bar x:number -> result:address:foo:_t [
 
 :(scenario shape_shifting_recipe_handles_shape_shifting_new_ingredient_2)
 recipe main [
-  1:address:foo:point <- bar 3
-  11:foo:point <- copy *1:address:foo:point
+  1:address:shared:foo:point <- bar 3
+  11:foo:point <- copy *1:address:shared:foo:point
 ]
-recipe bar x:number -> result:address:foo:_t [
+recipe bar x:number -> result:address:shared:foo:_t [
   local-scope
   load-ingredients
   # new refers to _t in its ingredient *value*
@@ -574,11 +574,11 @@ container foo:_t [
 
 :(scenario shape_shifting_recipe_supports_compound_types)
 recipe main [
-  1:address:point <- new point:type
-  2:address:number <- get-address *1:address:point, y:offset
+  1:address:shared:point <- new point:type
+  2:address:number <- get-address *1:address:shared:point, y:offset
   *2:address:number <- copy 34
-  3:address:point <- bar 1:address:point  # specialize _t to address:point
-  4:point <- copy *3:address:point
+  3:address:shared:point <- bar 1:address:shared:point  # specialize _t to address:shared:point
+  4:point <- copy *3:address:shared:point
 ]
 recipe bar a:_t -> result:_t [
   local-scope
@@ -716,7 +716,7 @@ container d2:_elem [
 # static dispatch between shape-shifting variants, _including pointer lookups_
 recipe main [
   e1:d1:number <- merge 3
-  e2:address:d2:number <- new {(d2 number): type}
+  e2:address:shared:d2:number <- new {(d2 number): type}
   1:number/raw <- foo e1
   2:number/raw <- foo *e2  # different from previous scenario
 ]
@@ -799,15 +799,15 @@ recipe foo x:_elem -> y:number [
 :(scenarios run)
 :(scenario specialize_most_similar_variant)
 recipe main [
-  1:address:number <- new number:type
-  2:number <- foo 1:address:number
+  1:address:shared:number <- new number:type
+  2:number <- foo 1:address:shared:number
 ]
 recipe foo x:_elem -> y:number [
   local-scope
   load-ingredients
   reply 34
 ]
-recipe foo x:address:_elem -> y:number [
+recipe foo x:address:shared:_elem -> y:number [
   local-scope
   load-ingredients
   reply 35