* Process a magic label. * * @param {Object} ast The `LabeledStatement` to process. * @param {Object} labels The map of label names to labels. * @param {Object} parent The `FunctionExpression` or `FunctionDeclaration` that contains the label. * @param {Object} options
(ast, labels, parent, options)
| 331 | * @return {Object[]} The nodes that should be injected in place of the `LabeledStatement`. |
| 332 | */ |
| 333 | function processLabel(ast, labels, parent, options) { |
| 334 | OBLIGATIONS.precondition(ast.type === 'LabeledStatement'); |
| 335 | OBLIGATIONS.precondition(ast.body.type === 'BlockStatement'); |
| 336 | OBLIGATIONS.precondition(parent && typeof parent === 'object'); |
| 337 | OBLIGATIONS.precondition(parent.type === 'FunctionDeclaration' || parent.type === 'FunctionExpression'); |
| 338 | OBLIGATIONS.precondition(options && typeof options === 'object'); |
| 339 | OBLIGATIONS.precondition(typeof options.supported === 'object'); |
| 340 | var __result; |
| 341 | main: { |
| 342 | if (typeof options.supported[ast.label.name] === 'function') { |
| 343 | __result = options.supported[ast.label.name](ast, options, labels, parent); |
| 344 | break main; |
| 345 | } else { |
| 346 | __result = ast.body.body; |
| 347 | break main; |
| 348 | } |
| 349 | } |
| 350 | OBLIGATIONS.postcondition(Array.isArray(__result)); |
| 351 | return __result; |
| 352 | } |
| 353 | /** |
| 354 | * Remove deletable nodes from the given AST. |
| 355 | * |