about summary refs log tree commit diff stats
path: root/043space.cc
diff options
context:
space:
mode:
Diffstat (limited to '043space.cc')
-rw-r--r--043space.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/043space.cc b/043space.cc
index 4f6d2c35..211d7630 100644
--- a/043space.cc
+++ b/043space.cc
@@ -2,6 +2,12 @@
 //: and all addresses in arguments are implicitly based on the 'default-space'
 //: (unless they have the /raw property)
 
+//: A space is just an array of any scalar location.
+:(before "End Mu Types Initialization")
+put(Type_abbreviations, "space", new_type_tree("address:array:location"));
+//: Spaces are often called 'scopes' in other languages.
+put(Type_abbreviations, "scope", new_type_tree("address:array:location"));
+
 :(scenario set_default_space)
 # if default-space is 10, and if an array of 5 locals lies from location 12 to 16 (inclusive),
 # then local 0 is really location 12, local 1 is really location 13, and so on.
@@ -9,7 +15,7 @@ def main [
   # pretend address:array:location; in practice we'll use new
   10:num <- copy 0  # refcount
   11:num <- copy 5  # length
-  default-space:&:@:location <- copy 10/unsafe
+  default-space:space <- copy 10/unsafe
   1:num <- copy 23
 ]
 +mem: storing 23 in location 13
@@ -22,7 +28,7 @@ def main [
   1000:num <- copy 0  # refcount
   1001:num <- copy 5  # length
   # actual start of this recipe
-  default-space:&:@:location <- copy 1000/unsafe
+  default-space:space <- copy 1000/unsafe
   1:&:num <- copy 2000/unsafe  # even local variables always contain raw addresses
   8:num/raw <- copy *1:&:num
 ]
@@ -95,8 +101,8 @@ bool is_space(const reagent& r) {
 
 :(scenario get_default_space)
 def main [
-  default-space:&:@:location <- copy 10/unsafe
-  1:&:@:location/raw <- copy default-space:&:@:location
+  default-space:space <- copy 10/unsafe
+  1:space/raw <- copy default-space:space
 ]
 +mem: storing 10 in location 1
 
@@ -118,7 +124,7 @@ def main [
   1000:num <- copy 0  # refcount
   1001:num <- copy 5  # length
   # actual start of this recipe
-  default-space:&:@:location <- copy 1000/unsafe
+  default-space:space <- copy 1000/unsafe
   1:&:point <- copy 2000/unsafe
   9:num/raw <- get *1:&:point, 1:offset
 ]
@@ -139,7 +145,7 @@ def main [
   1000:num <- copy 0  # refcount
   1001:num <- copy 5  # length
   # actual start of this recipe
-  default-space:&:@:location <- copy 1000/unsafe
+  default-space:space <- copy 1000/unsafe
   1:&:@:num <- copy 2000/unsafe
   9:num/raw <- index *1:&:@:num, 1
 ]
@@ -168,7 +174,7 @@ if (s == "number-of-locals") return true;
 
 :(before "End Rewrite Instruction(curr, recipe result)")
 // rewrite `new-default-space` to
-//   `default-space:&:@:location <- new location:type, number-of-locals:literal`
+//   `default-space:space <- new location:type, number-of-locals:literal`
 // where N is Name[recipe][""]
 if (curr.name == "new-default-space") {
   rewrite_default_space_instruction(curr);
@@ -199,7 +205,7 @@ def main [
 def foo [
   local-scope
   x:num <- copy 34
-  return default-space:&:@:location
+  return default-space:space
 ]
 # both calls to foo should have received the same default-space
 +mem: storing 1 in location 3
@@ -304,7 +310,7 @@ void rewrite_default_space_instruction(instruction& curr) {
   curr.ingredients.push_back(reagent("number-of-locals:literal"));
   if (!curr.products.empty())
     raise << "new-default-space can't take any results\n" << end();
-  curr.products.push_back(reagent("default-space:&:@:location"));
+  curr.products.push_back(reagent("default-space:space"));
 }
 
 :(scenario local_scope_frees_up_addresses_inside_containers)