about summary refs log tree commit diff stats
path: root/cpp/019address
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/019address')
-rw-r--r--cpp/019address52
1 files changed, 4 insertions, 48 deletions
diff --git a/cpp/019address b/cpp/019address
index 13d59465..0b39c71d 100644
--- a/cpp/019address
+++ b/cpp/019address
@@ -98,33 +98,8 @@ recipe main [
 +run: product 0 is 34
 +mem: storing 34 in location 4
 
-:(replace{} "case GET:")
-case GET: {
-  trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name;
-  reagent base = canonize(instructions[pc].ingredients[0]);
-  int base_address = base.value;
-  int base_type = base.types[0];
-  assert(Type[base_type].is_record);
-  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
-  assert(isa_literal(instructions[pc].ingredients[1]));
-  size_t offset = instructions[pc].ingredients[1].value;
-  int src = base_address;
-  for (size_t i = 0; i < offset; ++i) {
-    src += size_of(Type[base_type].elements[i]);
-  }
-  trace("run") << "address to copy is " << src;
-  assert(Type[base_type].is_record);
-  assert(Type[base_type].elements.size() > offset);
-  int src_type = Type[base_type].elements[offset][0];
-  trace("run") << "its type is " << src_type;
-  reagent tmp;
-  tmp.set_value(src);
-  tmp.types.push_back(src_type);
-  vector<int> result(read_memory(tmp));
-  trace("run") << "product 0 is " << result[0];
-  write_memory(instructions[pc].products[0], result);
-  break;
-}
+:(after "reagent base = " following "case GET:")
+base = canonize(base);
 
 :(scenario "get_address_indirect")
 # 'get' can read from record address
@@ -138,24 +113,5 @@ recipe main [
 +run: address to copy is 2
 +run: product 0 is 2
 
-:(replace{} "case GET_ADDRESS:")
-case GET_ADDRESS: {
-  trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name;
-  reagent base = canonize(instructions[pc].ingredients[0]);
-  int base_address = base.value;
-  int base_type = base.types[0];
-  assert(Type[base_type].is_record);
-  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
-  assert(isa_literal(instructions[pc].ingredients[1]));
-  size_t offset = instructions[pc].ingredients[1].value;
-  int src = base_address;
-  for (size_t i = 0; i < offset; ++i) {
-    src += size_of(Type[base_type].elements[i]);
-  }
-  trace("run") << "address to copy is " << src;
-  vector<int> result;
-  result.push_back(src);
-  trace("run") << "product 0 is " << result[0];
-  write_memory(instructions[pc].products[0], result);
-  break;
-}
+:(after "reagent base = " following "case GET_ADDRESS:")
+base = canonize(base);
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307