about summary refs log tree commit diff stats
path: root/081run_interactive.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-02 22:18:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-02 22:18:19 -0700
commitcfb142b9601cc648f15bf5738a3df09a23835e41 (patch)
tree670f168fbbf2693b17d679939bd1c203de1c3837 /081run_interactive.cc
parent37900254f083364dcfbb80cf7119c230a0b603d6 (diff)
downloadmu-cfb142b9601cc648f15bf5738a3df09a23835e41.tar.gz
1923
Still iterating on the right way to handle incorrect number of
ingredients. My first idea of creating null results doesn't really work
once they're used in later instructions. Just add a warning at one place
in the run loop, but otherwise only add products when there's something
to save in them.

Undoes some work around commit 1886.
Diffstat (limited to '081run_interactive.cc')
-rw-r--r--081run_interactive.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 59c79432..e627b0f6 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -27,7 +27,6 @@ Recipe_ordinal["run-interactive"] = RUN_INTERACTIVE;
 //? cerr << "run-interactive: " << RUN_INTERACTIVE << '\n'; //? 1
 :(before "End Primitive Recipe Implementations")
 case RUN_INTERACTIVE: {
-  products.resize(4);
   if (SIZE(ingredients) != 1) {
     raise << current_recipe_name() << ": 'run-interactive' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
     break;
@@ -38,6 +37,7 @@ case RUN_INTERACTIVE: {
   }
   bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(0));
   if (!new_code_pushed_to_stack) {
+    products.resize(4);
     products.at(0).push_back(0);
     products.at(1).push_back(trace_contents("warn"));
     products.at(2).push_back(0);
@@ -153,6 +153,14 @@ void record_products(const instruction& instruction, const vector<vector<double>
     // string
     if (i < SIZE(instruction.products)) {
       if (is_mu_string(instruction.products.at(i))) {
+        if (!scalar(products.at(i))) {
+          tb_shutdown();
+          cerr << read_mu_string(trace_contents("warn")) << '\n';
+          cerr << SIZE(products.at(i)) << ": ";
+          for (long long int j = 0; j < SIZE(products.at(i)); ++j)
+            cerr << products.at(i).at(j) << ' ';
+          cerr << '\n';
+        }
         assert(scalar(products.at(i)));
         out << read_mu_string(products.at(i).at(0)) << '\n';
         continue;
@@ -281,7 +289,6 @@ RELOAD,
 Recipe_ordinal["reload"] = RELOAD;
 :(before "End Primitive Recipe Implementations")
 case RELOAD: {
-  products.resize(1);
   if (SIZE(ingredients) != 1) {
     raise << current_recipe_name() << ": 'reload' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
     break;
@@ -302,6 +309,7 @@ case RELOAD: {
   Trace_stream->newline();  // flush trace
   Disable_redefine_warnings = false;
   Hide_warnings = false;
+  products.resize(1);
   products.at(0).push_back(trace_contents("warn"));
   // hack: assume collect_layers isn't set anywhere else
   if (Trace_stream->is_narrowly_collecting("warn")) {
7:40:25 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-04-20 17:40:25 -0700 1115 - another pass at names: console and display' href='/akkartik/mu/commit/cpp/070display?h=hlt&id=ec961781d0dd952384d08639b74f4b5a14942259'>ec961781 ^
54d48b25 ^
ec961781 ^
54d48b25 ^
ec961781 ^
5f128523 ^
00b808d9 ^
54d48b25 ^


be16deb0 ^


54d48b25 ^
12d73ee8 ^




5f128523 ^

12d73ee8 ^








ac0e9db5 ^

5f128523 ^



12d73ee8 ^








5f128523 ^
ac0e9db5 ^


827898fc ^
dc1323e9 ^

5f128523 ^






dc1323e9 ^








64ac91c5 ^





dc1323e9 ^

5f128523 ^


12d73ee8 ^








0487a30e ^


12d73ee8 ^








ac0e9db5 ^
827898fc ^
ac0e9db5 ^
827898fc ^
5f128523 ^

12d73ee8 ^


0012c703 ^





dc1323e9 ^
ac0e9db5 ^
dc1323e9 ^




0012c703 ^








dc1323e9 ^




0012c703 ^








dc1323e9 ^
ac0e9db5 ^
dc1323e9 ^




0012c703 ^








dc1323e9 ^




0012c703 ^


12d73ee8 ^


f08a13e1 ^
54d48b25 ^
f08a13e1 ^
54d48b25 ^
f08a13e1 ^
5f128523 ^
bbff2a35 ^


0487a30e ^

bbff2a35 ^










0487a30e ^

f8c0ef3e ^
0487a30e ^
f8c0ef3e ^
af336c44 ^


0487a30e ^
bbff2a35 ^
0487a30e ^


54d48b25 ^

5f128523 ^


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