:(scenario surrounding_space)
recipe main [
10:number <- copy 5:literal
20:number <- copy 5:literal
default-space:address:array:location <- copy 10:literal
0:address:array:location/names:dummy <- copy 20:literal
1:number <- copy 32:literal
1:number/space:1 <- copy 33:literal
]
+mem: storing 20 in location 11
+mem: storing 32 in location 12
+mem: storing 33 in location 22
:(replace{} "long long int space_base(const reagent& x)")
long long int space_base(const reagent& x) {
return space_base(x, space_index(x), Current_routine->calls.front().default_space);
}
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, Memory[base+1]);
return result;
}
long long int space_index(const reagent& x) {
for (long long int i = 1; i < SIZE(x.properties); ++i) {
if (x.properties.at(i).first == "space") {
if (SIZE(x.properties.at(i).second) != 1)
raise << current_recipe_name() << ": /space metadata should take exactly one value in " << x.original_string << '\n' << end();
return to_integer(x.properties.at(i).second.at(0));
}
}
return 0;
}
:(scenario permit_space_as_variable_name)
recipe main [
space:number <- copy 0:literal
]