* Process a list of labels that are contained within the given `BlockStatement`. * * @param {Object} ast The `BlockStatement` that contains the labels. * @param {Object} parent The `FunctionExpression` or `FunctionDeclaration` that contains the label. * @param {Object} labels The
(ast, parent, labels, options)
| 297 | * @return {Object} The processed AST. |
| 298 | */ |
| 299 | function processLabels(ast, parent, labels, options) { |
| 300 | OBLIGATIONS.precondition(ast && typeof ast === 'object'); |
| 301 | OBLIGATIONS.precondition(ast.type === 'BlockStatement'); |
| 302 | OBLIGATIONS.precondition(labels && typeof labels === 'object'); |
| 303 | OBLIGATIONS.precondition(parent && typeof parent === 'object'); |
| 304 | OBLIGATIONS.precondition(parent.type === 'FunctionDeclaration' || parent.type === 'FunctionExpression'); |
| 305 | OBLIGATIONS.precondition(options && typeof options === 'object'); |
| 306 | OBLIGATIONS.precondition(typeof options.supported === 'object'); |
| 307 | var __result; |
| 308 | var keys = Object.keys(labels), total = keys.length, key, index, label, i; |
| 309 | for (i = 0; i < total; i++) { |
| 310 | key = keys[i]; |
| 311 | label = labels[key]; |
| 312 | index = ast.body.indexOf(label); |
| 313 | if (~index) { |
| 314 | ast.body.splice.apply(ast.body, [ |
| 315 | index, |
| 316 | 1 |
| 317 | ].concat(processLabel(label, labels, parent, options))); |
| 318 | } |
| 319 | } |
| 320 | __result = ast; |
| 321 | OBLIGATIONS.postcondition(__result && typeof __result === 'object'); |
| 322 | return __result; |
| 323 | } |
| 324 | /** |
| 325 | * Process a magic label. |
| 326 | * |
no test coverage detected