about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-28 06:27:01 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-28 06:27:01 -0700
commit67573caf07392a89df841ef47cc98e5b91a13205 (patch)
tree82698363791699f96fbfb6fd6a9e9749996476f4
parent5810092d53f44e639c7bfd4e62d1960c323dcb6f (diff)
downloadmu-67573caf07392a89df841ef47cc98e5b91a13205.tar.gz
2297
-rw-r--r--034call.cc11
-rw-r--r--035call_ingredient.cc20
-rw-r--r--043new.cc2
-rw-r--r--044space.cc10
-rw-r--r--045space_surround.cc2
-rw-r--r--072scenario_screen.cc4
6 files changed, 27 insertions, 22 deletions
diff --git a/034call.cc b/034call.cc
index 87d0d601..f33e6053 100644
--- a/034call.cc
+++ b/034call.cc
@@ -64,22 +64,27 @@ routine::routine(recipe_ordinal r) {
   // End routine Constructor
 }
 
+:(code)
+inline call& current_call() {
+  return Current_routine->calls.front();
+}
+
 //:: now update routine's helpers
 
 :(replace{} "inline long long int& current_step_index()")
 inline long long int& current_step_index() {
   assert(!Current_routine->calls.empty());
-  return Current_routine->calls.front().running_step_index;
+  return current_call().running_step_index;
 }
 :(replace{} "inline const string& current_recipe_name()")
 inline const string& current_recipe_name() {
   assert(!Current_routine->calls.empty());
-  return Recipe[Current_routine->calls.front().running_recipe].name;
+  return Recipe[current_call().running_recipe].name;
 }
 :(replace{} "inline const instruction& current_instruction()")
 inline const instruction& current_instruction() {
   assert(!Current_routine->calls.empty());
-  return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index);
+  return Recipe[current_call().running_recipe].steps.at(current_call().running_step_index);
 }
 
 :(after "Defined Recipe Checks")
diff --git a/035call_ingredient.cc b/035call_ingredient.cc
index 01036728..41e7811b 100644
--- a/035call_ingredient.cc
+++ b/035call_ingredient.cc
@@ -29,8 +29,8 @@ next_ingredient_to_process = 0;
 
 :(before "End Call Housekeeping")
 for (long long int i = 0; i < SIZE(ingredients); ++i) {
-  Current_routine->calls.front().ingredient_atoms.push_back(ingredients.at(i));
-  Current_routine->calls.front().ingredient_types.push_back(call_instruction.ingredients.at(i).type);
+  current_call().ingredient_atoms.push_back(ingredients.at(i));
+  current_call().ingredient_types.push_back(call_instruction.ingredients.at(i).type);
 }
 
 :(before "End Primitive Recipe Declarations")
@@ -48,12 +48,12 @@ case NEXT_INGREDIENT: {
 :(before "End Primitive Recipe Implementations")
 case NEXT_INGREDIENT: {
   assert(!Current_routine->calls.empty());
-  if (Current_routine->calls.front().next_ingredient_to_process < SIZE(Current_routine->calls.front().ingredient_atoms)) {
+  if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) {
     products.push_back(
-        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
+        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
     assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
     products.at(1).push_back(1);
-    ++Current_routine->calls.front().next_ingredient_to_process;
+    ++current_call().next_ingredient_to_process;
   }
   else {
     if (SIZE(current_instruction().products) < 2)
@@ -105,7 +105,7 @@ case REWIND_INGREDIENTS: {
 }
 :(before "End Primitive Recipe Implementations")
 case REWIND_INGREDIENTS: {
-  Current_routine->calls.front().next_ingredient_to_process = 0;
+  current_call().next_ingredient_to_process = 0;
   break;
 }
 
@@ -138,13 +138,13 @@ case INGREDIENT: {
 }
 :(before "End Primitive Recipe Implementations")
 case INGREDIENT: {
-  if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(Current_routine->calls.front().ingredient_atoms)) {
-    Current_routine->calls.front().next_ingredient_to_process = ingredients.at(0).at(0);
+  if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) {
+    current_call().next_ingredient_to_process = ingredients.at(0).at(0);
     products.push_back(
-        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
+        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
     assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
     products.at(1).push_back(1);
-    ++Current_routine->calls.front().next_ingredient_to_process;
+    ++current_call().next_ingredient_to_process;
   }
   else {
     if (SIZE(current_instruction().products) > 1) {
diff --git a/043new.cc b/043new.cc
index 34ccf18b..4604a4fa 100644
--- a/043new.cc
+++ b/043new.cc
@@ -367,7 +367,7 @@ Current_routine = main_routine;
 for (long long int i = 1; i < argc; ++i) {
   vector<double> arg;
   arg.push_back(new_mu_string(argv[i]));
-  Current_routine->calls.front().ingredient_atoms.push_back(arg);
+  current_call().ingredient_atoms.push_back(arg);
 }
 
 //: stash recognizes strings
diff --git a/044space.cc b/044space.cc
index 598c8847..57faa054 100644
--- a/044space.cc
+++ b/044space.cc
@@ -174,7 +174,7 @@ void try_reclaim_locals() {
   if (Recipe[r].steps.empty()) return;
   const instruction& inst = Recipe[r].steps.at(0);
   if (inst.name != "local-scope") return;
-  abandon(Current_routine->calls.front().default_space,
+  abandon(current_call().default_space,
           /*array length*/1+/*number-of-locals*/Name[r][""]);
 }
 
@@ -192,8 +192,8 @@ void rewrite_default_space_instruction(instruction& curr) {
 //:: helpers
 
 :(code)
-long long int space_base(const reagent& x) {
-  return Current_routine->calls.front().default_space;
+long long int space_base(const reagent& x) {  // temporary
+  return current_call().default_space;
 }
 
 long long int address(long long int offset, long long int base) {
@@ -217,7 +217,7 @@ long long int address(long long int offset, long long int base) {
         || x.type->right->right->right) {
       raise_error << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end();
     }
-    Current_routine->calls.front().default_space = data.at(0);
+    current_call().default_space = data.at(0);
     return;
   }
 
@@ -231,6 +231,6 @@ recipe main [
 :(after "vector<double> read_memory(reagent x)")
   if (x.name == "default-space") {
     vector<double> result;
-    result.push_back(Current_routine->calls.front().default_space);
+    result.push_back(current_call().default_space);
     return result;
   }
diff --git a/045space_surround.cc b/045space_surround.cc
index b55c5e04..880c350e 100644
--- a/045space_surround.cc
+++ b/045space_surround.cc
@@ -27,7 +27,7 @@ recipe main [
 
 :(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);
+  return space_base(x, space_index(x), current_call().default_space);
 }
 
 long long int space_base(const reagent& x, long long int space_index, long long int base) {
diff --git a/072scenario_screen.cc b/072scenario_screen.cc
index 4ecbbd4d..ed2ddad3 100644
--- a/072scenario_screen.cc
+++ b/072scenario_screen.cc
@@ -197,7 +197,7 @@ struct raw_string_stream {
 
 :(code)
 void check_screen(const string& expected_contents, const int color) {
-  assert(!Current_routine->calls.front().default_space);  // not supported
+  assert(!current_call().default_space);  // not supported
   long long int screen_location = Memory[SCREEN];
   int data_offset = find_element_name(Type_ordinal["screen"], "data", "");
   assert(data_offset >= 0);
@@ -332,7 +332,7 @@ case _DUMP_SCREEN: {
 
 :(code)
 void dump_screen() {
-  assert(!Current_routine->calls.front().default_space);  // not supported
+  assert(!current_call().default_space);  // not supported
   long long int screen_location = Memory[SCREEN];
   int width_offset = find_element_name(Type_ordinal["screen"], "num-columns", "");
   long long int screen_width = Memory[screen_location+width_offset];
v class='alt'>
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^



















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^



















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^



















7a583220 ^
fd91f7f6 ^











71eb22a5 ^
7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^
fd91f7f6 ^
2a2a5b1e ^

6070c23e ^
fd91f7f6 ^
71eb22a5 ^
2a2a5b1e ^
fd91f7f6 ^


6070c23e ^
fd91f7f6 ^
71eb22a5 ^
fd91f7f6 ^



6070c23e ^
fd91f7f6 ^


6070c23e ^
fd91f7f6 ^


6070c23e ^
fd91f7f6 ^










7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^






71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^



71eb22a5 ^
7a583220 ^
fd91f7f6 ^





71eb22a5 ^
fd91f7f6 ^
2a2a5b1e ^

fd91f7f6 ^
fd91f7f6 ^



6070c23e ^
fd91f7f6 ^



7a583220 ^
fd91f7f6 ^




7a583220 ^
fd91f7f6 ^







71eb22a5 ^
fd91f7f6 ^
























71eb22a5 ^
fd91f7f6 ^


















7a583220 ^
fd91f7f6 ^




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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623