@@ -211,36 +211,35 @@ int main(int argc, char **argv)
211
211
data._reservedKeywords .push (" end_def" );
212
212
213
213
// /Instructions
214
- data._instructions .push_back (new codeg::Instruction_set ());
215
- data._instructions .push_back (new codeg::Instruction_unset ());
216
- data._instructions .push_back (new codeg::Instruction_var ());
217
- data._instructions .push_back (new codeg::Instruction_label ());
218
- data._instructions .push_back (new codeg::Instruction_jump ());
219
- data._instructions .push_back (new codeg::Instruction_restart ());
220
- data._instructions .push_back (new codeg::Instruction_affect ());
221
- data._instructions .push_back (new codeg::Instruction_get ());
222
- data._instructions .push_back (new codeg::Instruction_write ());
223
- data._instructions .push_back (new codeg::Instruction_choose ());
224
- data._instructions .push_back (new codeg::Instruction_do ());
225
- data._instructions .push_back (new codeg::Instruction_tick ());
226
- data._instructions .push_back (new codeg::Instruction_brut ());
227
- data._instructions .push_back (new codeg::Instruction_function ());
228
- data._instructions .push_back (new codeg::Instruction_if ());
229
- data._instructions .push_back (new codeg::Instruction_else ());
230
- data._instructions .push_back (new codeg::Instruction_ifnot ());
231
- data._instructions .push_back (new codeg::Instruction_end ());
232
- data._instructions .push_back (new codeg::Instruction_call ());
233
- data._instructions .push_back (new codeg::Instruction_clock ());
234
- data._instructions .push_back (new codeg::Instruction_pool ());
235
- data._instructions .push_back (new codeg::Instruction_import ());
236
- data._instructions .push_back (new codeg::Instruction_definition ());
237
- data._instructions .push_back (new codeg::Instruction_enddef ());
214
+ data._instructions .push (new codeg::Instruction_set ());
215
+ data._instructions .push (new codeg::Instruction_unset ());
216
+ data._instructions .push (new codeg::Instruction_var ());
217
+ data._instructions .push (new codeg::Instruction_label ());
218
+ data._instructions .push (new codeg::Instruction_jump ());
219
+ data._instructions .push (new codeg::Instruction_restart ());
220
+ data._instructions .push (new codeg::Instruction_affect ());
221
+ data._instructions .push (new codeg::Instruction_get ());
222
+ data._instructions .push (new codeg::Instruction_write ());
223
+ data._instructions .push (new codeg::Instruction_choose ());
224
+ data._instructions .push (new codeg::Instruction_do ());
225
+ data._instructions .push (new codeg::Instruction_tick ());
226
+ data._instructions .push (new codeg::Instruction_brut ());
227
+ data._instructions .push (new codeg::Instruction_function ());
228
+ data._instructions .push (new codeg::Instruction_if ());
229
+ data._instructions .push (new codeg::Instruction_else ());
230
+ data._instructions .push (new codeg::Instruction_ifnot ());
231
+ data._instructions .push (new codeg::Instruction_end ());
232
+ data._instructions .push (new codeg::Instruction_call ());
233
+ data._instructions .push (new codeg::Instruction_clock ());
234
+ data._instructions .push (new codeg::Instruction_pool ());
235
+ data._instructions .push (new codeg::Instruction_import ());
236
+ data._instructions .push (new codeg::Instruction_definition ());
237
+ data._instructions .push (new codeg::Instruction_enddef ());
238
238
239
239
// /Code
240
240
data._code .resize (65536 );
241
241
242
242
std::string readedLine;
243
- bool validInstruction = false ;
244
243
245
244
try
246
245
{
@@ -253,28 +252,21 @@ int main(int argc, char **argv)
253
252
254
253
if (data._decomposer ._keywords .size () > 0 )
255
254
{
256
- validInstruction = false ;
257
-
258
- for (auto && instruction : data._instructions )
259
- {
260
- if (instruction->getName () == data._decomposer ._keywords [0 ])
261
- {
262
- validInstruction = true ;
263
-
264
- if ( data._writeLinesIntoDefinition )
265
- {// Compile in a definition (detect the end_def keyword)
266
- instruction->compileDefinition (data._decomposer , data);
267
- }
268
- else
269
- {// Compile
270
- instruction->compile (data._decomposer , data);
271
- }
272
- break ;
255
+ codeg::Instruction* instruction = data._instructions .get ( data._decomposer ._keywords [0 ] );
256
+
257
+ if (instruction != nullptr )
258
+ {// Instruction founded
259
+ if ( data._writeLinesIntoDefinition )
260
+ {// Compile in a definition (detect the end_def keyword)
261
+ instruction->compileDefinition (data._decomposer , data);
262
+ }
263
+ else
264
+ {// Compile
265
+ instruction->compile (data._decomposer , data);
273
266
}
274
267
}
275
-
276
- if (!validInstruction)
277
- {
268
+ else
269
+ {// Bad instruction
278
270
throw codeg::FatalError (" unknown instruction \" " +data._decomposer ._keywords [0 ]+" \" " );
279
271
}
280
272
}
0 commit comments