1
2
3
4
5
6
7 :(scenario surrounding_space)
8
9 def main [
10
11 10:num <- copy 5
12
13 20:num <- copy 5
14
15 default-space:space <- copy 10/unsafe
16
17 0:space/names:dummy <- copy 20/unsafe
18 1:num <- copy 32
19 1:num/space:1 <- copy 33
20 ]
21 def dummy [
22 ]
23
24 +mem: storing 20 in location 11
25
26 +mem: storing 32 in location 12
27
28 +mem: storing 33 in location 22
29
30
31
32
33
34 :(replace{} "int space_base(const reagent& x)")
35 int space_base(const reagent& x) {
36 int base = current_call().default_space ? current_call().default_space : 0;
37 return space_base(x, space_index(x), base);
38 }
39
40 int space_base(const reagent& x, int space_index, int base) {
41 if (space_index == 0)
42 return base;
43 return space_base(x, space_index-1, get_or_insert(Memory, base+1));
44 }
45
46 int space_index(const reagent& x) {
47 for (int i = 0; i < SIZE(x.properties); ++i) {
48 if (x.properties.at(i).first == "space") {
49 if (!x.properties.at(i).second || x.properties.at(i).second->right)
50 raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in '" << x.original_string << "'\n" << end();
51 return to_integer(x.properties.at(i).second->value);
52 }
53 }
54 return 0;
55 }
56
57 :(scenario permit_space_as_variable_name)
58 def main [
59 space:num <- copy 0
60 ]