about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/019address35
-rw-r--r--cpp/020array4
2 files changed, 8 insertions, 31 deletions
diff --git a/cpp/019address b/cpp/019address
index a642ceb1..07487499 100644
--- a/cpp/019address
+++ b/cpp/019address
@@ -12,24 +12,8 @@ recipe main [
 +mem: location 2 is 34
 +mem: storing 34 in location 3
 
-:(replace{} "vector<int> read_memory(reagent x)")
-vector<int> read_memory(reagent x) {
-  vector<int> result;
-  if (isa_literal(x)) {
-    result.push_back(x.value);
-    return result;
-  }
-  x = canonize(x);
-  int base = x.value;
-//?   cout << "base: " << base << '\n'; //? 1
-  size_t size = size_of(x);
-  for (size_t offset = 0; offset < size; ++offset) {
-    int val = Memory[base+offset];
-    trace("mem") << "location " << base+offset << " is " << val;
-    result.push_back(val);
-  }
-  return result;
-}
+:(before "int base = x.value" following "vector<int> read_memory(reagent x)")
+x = canonize(x);
 
 //: similarly, write to addresses pointing at other locations using the
 //: 'deref' property
@@ -42,19 +26,8 @@ recipe main [
 +mem: location 1 is 2
 +mem: storing 34 in location 2
 
-:(replace{} "void write_memory(reagent x, vector<int> data)")
-void write_memory(reagent x, vector<int> data) {
-  if (x.name == "_") return;  // dummy results are never stored
-  x = canonize(x);
-//?   cout << x.to_string() << '\n'; //? 1
-  int base = x.value;
-  if (!Type[x.types[0]].is_array && size_of(x) != data.size())
-    raise << "size mismatch in storing to " << x.to_string();
-  for (size_t offset = 0; offset < data.size(); ++offset) {
-    trace("mem") << "storing " << data[offset] << " in location " << base+offset;
-    Memory[base+offset] = data[offset];
-  }
-}
+:(before "int base = x.value" following "void write_memory(reagent x, vector<int> data)")
+x = canonize(x);
 
 :(code)
 reagent canonize(reagent x) {
diff --git a/cpp/020array b/cpp/020array
index aafeacf8..96591366 100644
--- a/cpp/020array
+++ b/cpp/020array
@@ -6,6 +6,10 @@ Type[integer_array].is_array = true;
 Type[integer_array].element.push_back(integer);
 Type[integer_array].name = "integer-array";
 
+//: update size mismatch check
+:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<int> data)")
+if (!Type[x.types[0]].is_array && size_of(x) != data.size())
+
 //: Arrays can be copied around with a single instruction just like integers,
 //: no matter how large they are.
 
danisanti/profani-tty/blame/src/theme.h?id=1a909fd6eb2f1ac5fb302c1c164e346fe9050249'>^
e8b2b719 ^
54cf1dbe ^

ed4391ec ^




c0f099cb ^
ed4391ec ^

71679a31 ^

ed4391ec ^



fcd69532 ^
ed4391ec ^












641410f6 ^
ed4391ec ^
91bc302a ^
ed4391ec ^



2f82f50a ^
5ff36c14 ^
1a3dc91e ^
ed4391ec ^













976e5aac ^


fbc30231 ^

















cd2458c0 ^

0ae975c2 ^

b21edfaa ^
9482ce61 ^
1d5ac1b4 ^















3bb3cc62 ^
aa0f4979 ^
5c53e02d ^
6dbbbe11 ^
ed4391ec ^
c5b4fc4a ^
a2726b6a ^
29f72283 ^
a2726b6a ^

986967ef ^
e8b2b719 ^
a2726b6a ^
ed4391ec ^
a2726b6a ^





802df379 ^
e8b2b719 ^
e8b2b719 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162