:(scenario surrounding_space)
def main [
10:number <- copy 0
11:number <- copy 5
20:number <- copy 0
21:number <- copy 5
default-space:address:shared:array:location <- copy 10/unsafe
0:address:shared:array:location/names:dummy <- copy 20/unsafe
1:number <- copy 32
1:number/space:1 <- copy 33
]
def dummy [
]
+mem: storing 20 in location 12
+mem: storing 32 in location 13
+mem: storing 33 in location 23
:(replace{} "long long int space_base(const reagent& x)")
long long int space_base(const reagent& x) {
long long int base = current_call().default_space ? (current_call().default_space+1) : 0;
return space_base(x, space_index(x), base);
}
long long int space_base(const reagent& x, long long int space_index, long long int base) {
if (space_index == 0)
return base;
long long int result = space_base(x, space_index-1, get_or_insert(Memory, base+1))+1;
return result;
}
long long int space_index(const reagent& x) {
for (long long int i = 0; i < SIZE(x.properties); ++i) {
if (x.properties.at(i).first == "space") {
if (!x.properties.at(i).second || x.properties.at(i).second->right)
raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in " << x.original_string << '\n' << end();
return to_integer(x.properties.at(i).second->value);
}
}
return 0;
}
:(scenario permit_space_as_variable_name)
def main [
space:number <- copy 0
]