@@ -197,116 +197,88 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
197
197
198
198
int8_t load8s (Address addr, Name memoryName) override {
199
199
auto it = memories.find (memoryName);
200
- if (it == memories.end ()) {
201
- trap (" load8s on non-existing memory" );
202
- }
200
+ assert (it != memories.end ());
203
201
auto & memory = it->second ;
204
202
return memory.get <int8_t >(addr);
205
203
}
206
204
uint8_t load8u (Address addr, Name memoryName) override {
207
205
auto it = memories.find (memoryName);
208
- if (it == memories.end ()) {
209
- trap (" load8u on non-existing memory" );
210
- }
206
+ assert (it != memories.end ());
211
207
auto & memory = it->second ;
212
208
return memory.get <uint8_t >(addr);
213
209
}
214
210
int16_t load16s (Address addr, Name memoryName) override {
215
211
auto it = memories.find (memoryName);
216
- if (it == memories.end ()) {
217
- trap (" load16s on non-existing memory" );
218
- }
212
+ assert (it != memories.end ());
219
213
auto & memory = it->second ;
220
214
return memory.get <int16_t >(addr);
221
215
}
222
216
uint16_t load16u (Address addr, Name memoryName) override {
223
217
auto it = memories.find (memoryName);
224
- if (it == memories.end ()) {
225
- trap (" load16u on non-existing memory" );
226
- }
218
+ assert (it != memories.end ());
227
219
auto & memory = it->second ;
228
220
return memory.get <uint16_t >(addr);
229
221
}
230
222
int32_t load32s (Address addr, Name memoryName) override {
231
223
auto it = memories.find (memoryName);
232
- if (it == memories.end ()) {
233
- trap (" load32s on non-existing memory" );
234
- }
224
+ assert (it != memories.end ());
235
225
auto & memory = it->second ;
236
226
return memory.get <int32_t >(addr);
237
227
}
238
228
uint32_t load32u (Address addr, Name memoryName) override {
239
229
auto it = memories.find (memoryName);
240
- if (it == memories.end ()) {
241
- trap (" load32u on non-existing memory" );
242
- }
230
+ assert (it != memories.end ());
243
231
auto & memory = it->second ;
244
232
return memory.get <uint32_t >(addr);
245
233
}
246
234
int64_t load64s (Address addr, Name memoryName) override {
247
235
auto it = memories.find (memoryName);
248
- if (it == memories.end ()) {
249
- trap (" load64s on non-existing memory" );
250
- }
236
+ assert (it != memories.end ());
251
237
auto & memory = it->second ;
252
238
return memory.get <int64_t >(addr);
253
239
}
254
240
uint64_t load64u (Address addr, Name memoryName) override {
255
241
auto it = memories.find (memoryName);
256
- if (it == memories.end ()) {
257
- trap (" load64u on non-existing memory" );
258
- }
242
+ assert (it != memories.end ());
259
243
auto & memory = it->second ;
260
244
return memory.get <uint64_t >(addr);
261
245
}
262
246
std::array<uint8_t , 16 > load128 (Address addr, Name memoryName) override {
263
247
auto it = memories.find (memoryName);
264
- if (it == memories.end ()) {
265
- trap (" load128 on non-existing memory" );
266
- }
248
+ assert (it != memories.end ());
267
249
auto & memory = it->second ;
268
250
return memory.get <std::array<uint8_t , 16 >>(addr);
269
251
}
270
252
271
253
void store8 (Address addr, int8_t value, Name memoryName) override {
272
254
auto it = memories.find (memoryName);
273
- if (it == memories.end ()) {
274
- trap (" store8 on non-existing memory" );
275
- }
255
+ assert (it != memories.end ());
276
256
auto & memory = it->second ;
277
257
memory.set <int8_t >(addr, value);
278
258
}
279
259
void store16 (Address addr, int16_t value, Name memoryName) override {
280
260
auto it = memories.find (memoryName);
281
- if (it == memories.end ()) {
282
- trap (" store16 on non-existing memory" );
283
- }
261
+ assert (it != memories.end ());
284
262
auto & memory = it->second ;
285
263
memory.set <int16_t >(addr, value);
286
264
}
287
265
void store32 (Address addr, int32_t value, Name memoryName) override {
288
266
auto it = memories.find (memoryName);
289
- if (it == memories.end ()) {
290
- trap (" store32 on non-existing memory" );
291
- }
267
+ assert (it != memories.end ());
292
268
auto & memory = it->second ;
293
269
memory.set <int32_t >(addr, value);
294
270
}
295
271
void store64 (Address addr, int64_t value, Name memoryName) override {
296
272
auto it = memories.find (memoryName);
297
- if (it == memories.end ()) {
298
- trap (" store64 on non-existing memory" );
299
- }
273
+ assert (it != memories.end ());
300
274
auto & memory = it->second ;
301
275
memory.set <int64_t >(addr, value);
302
276
}
303
277
void store128 (Address addr,
304
278
const std::array<uint8_t , 16 >& value,
305
279
Name memoryName) override {
306
280
auto it = memories.find (memoryName);
307
- if (it == memories.end ()) {
308
- trap (" store128 on non-existing memory" );
309
- }
281
+ assert (it != memories.end ());
310
282
auto & memory = it->second ;
311
283
memory.set <std::array<uint8_t , 16 >>(addr, value);
312
284
}
0 commit comments