( loopPath: NodePath<t.Loop>, captured: string[], updatedBindingsUsages: Map<string, NodePath<t.Identifier>[]>, pluginPass: PluginPass, )
| 307 | } |
| 308 | |
| 309 | export function wrapLoopBody( |
| 310 | loopPath: NodePath<t.Loop>, |
| 311 | captured: string[], |
| 312 | updatedBindingsUsages: Map<string, NodePath<t.Identifier>[]>, |
| 313 | pluginPass: PluginPass, |
| 314 | ) { |
| 315 | const loopNode = loopPath.node; |
| 316 | const state: CompletionsAndVarsState = { |
| 317 | breaksContinues: [], |
| 318 | returns: [], |
| 319 | labelsStack: [], |
| 320 | labellessBreakTargets: 0, |
| 321 | labellessContinueTargets: 0, |
| 322 | vars: [], |
| 323 | loopNode, |
| 324 | hasTryFinally: false, |
| 325 | }; |
| 326 | loopPath.traverse( |
| 327 | { |
| 328 | FunctionParent(path) { |
| 329 | path.skip(); |
| 330 | }, |
| 331 | LabeledStatement: { |
| 332 | enter({ node }, state) { |
| 333 | state.labelsStack.push(node.label.name); |
| 334 | }, |
| 335 | exit({ node }, state) { |
| 336 | const popped = state.labelsStack.pop(); |
| 337 | if (popped !== node.label.name) { |
| 338 | throw new Error( |
| 339 | "Assertion failure. Please report this bug to Babel.", |
| 340 | ); |
| 341 | } |
| 342 | }, |
| 343 | }, |
| 344 | Loop: { |
| 345 | enter(_, state) { |
| 346 | state.labellessContinueTargets++; |
| 347 | state.labellessBreakTargets++; |
| 348 | }, |
| 349 | exit(_, state) { |
| 350 | state.labellessContinueTargets--; |
| 351 | state.labellessBreakTargets--; |
| 352 | }, |
| 353 | }, |
| 354 | SwitchStatement: { |
| 355 | enter(_, state) { |
| 356 | state.labellessBreakTargets++; |
| 357 | }, |
| 358 | exit(_, state) { |
| 359 | state.labellessBreakTargets--; |
| 360 | }, |
| 361 | }, |
| 362 | "BreakStatement|ContinueStatement"( |
| 363 | path: NodePath<t.BreakStatement | t.ContinueStatement>, |
| 364 | state, |
| 365 | ) { |
| 366 | const { label } = path.node; |
no test coverage detected