Process loop interruption.
| 10300 | |
| 10301 | // Process loop interruption. |
| 10302 | static USHORT dsqlPassLabel(DsqlCompilerScratch* dsqlScratch, bool breakContinue, MetaName* label) |
| 10303 | { |
| 10304 | // look for a label, if specified |
| 10305 | |
| 10306 | USHORT position = 0; |
| 10307 | |
| 10308 | if (label) |
| 10309 | { |
| 10310 | int index = dsqlScratch->loopLevel; |
| 10311 | |
| 10312 | for (Stack<MetaName*>::iterator stack(dsqlScratch->labels); stack.hasData(); ++stack) |
| 10313 | { |
| 10314 | const MetaName* obj = stack.object(); |
| 10315 | if (obj && *label == *obj) |
| 10316 | { |
| 10317 | position = index; |
| 10318 | break; |
| 10319 | } |
| 10320 | |
| 10321 | --index; |
| 10322 | } |
| 10323 | } |
| 10324 | |
| 10325 | USHORT number = 0; |
| 10326 | |
| 10327 | if (breakContinue) |
| 10328 | { |
| 10329 | if (position > 0) |
| 10330 | { |
| 10331 | // break/continue the specified loop |
| 10332 | number = position; |
| 10333 | } |
| 10334 | else if (label) |
| 10335 | { |
| 10336 | // ERROR: Label %s is not found in the current scope |
| 10337 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << |
| 10338 | Arg::Gds(isc_dsql_command_err) << |
| 10339 | Arg::Gds(isc_dsql_invalid_label) << *label << |
| 10340 | Arg::Str("is not found")); |
| 10341 | } |
| 10342 | else |
| 10343 | { |
| 10344 | // break/continue the current loop |
| 10345 | number = dsqlScratch->loopLevel; |
| 10346 | } |
| 10347 | } |
| 10348 | else |
| 10349 | { |
| 10350 | if (position > 0) |
| 10351 | { |
| 10352 | // ERROR: Label %s already exists in the current scope |
| 10353 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << |
| 10354 | Arg::Gds(isc_dsql_command_err) << |
| 10355 | Arg::Gds(isc_dsql_invalid_label) << *label << |
| 10356 | Arg::Str("already exists")); |
| 10357 | } |
| 10358 | else |
| 10359 | { |