add ensureBlock path method
This commit is contained in:
parent
4b0f624fb3
commit
ebaa06f4a2
@ -2,7 +2,7 @@ import * as t from "../../../types";
|
||||
|
||||
export var visitor = {
|
||||
ArrowFunctionExpression(node) {
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
node.expression = false;
|
||||
node.type = "FunctionExpression";
|
||||
|
||||
@ -18,7 +18,7 @@ export var visitor = {
|
||||
t.variableDeclarator(temp)
|
||||
]);
|
||||
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
node.body.body.unshift(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(left, temp)
|
||||
@ -48,7 +48,7 @@ export var visitor = {
|
||||
|
||||
destructuring.init(pattern, key);
|
||||
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
var block = node.body;
|
||||
block.body = nodes.concat(block.body);
|
||||
@ -84,7 +84,7 @@ export var visitor = {
|
||||
destructuring.init(pattern, ref);
|
||||
}
|
||||
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
var block = node.body;
|
||||
block.body = nodes.concat(block.body);
|
||||
|
||||
@ -17,7 +17,7 @@ export var visitor = {
|
||||
var block = loop.body;
|
||||
|
||||
// ensure that it's a block so we can take all its statements
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
// add the value declaration to the new loop body
|
||||
if (declar) {
|
||||
|
||||
@ -27,7 +27,7 @@ export var visitor = {
|
||||
if (!hasDefaults(node)) return;
|
||||
|
||||
// ensure it's a block, useful for arrow functions
|
||||
t.ensureBlock(node);
|
||||
this.ensureBlock();
|
||||
|
||||
var state = {
|
||||
iife: false,
|
||||
|
||||
@ -150,7 +150,7 @@ class TailCallTransformer {
|
||||
|
||||
//
|
||||
|
||||
var body = t.ensureBlock(node).body;
|
||||
var body = this.path.ensureBlock().body;
|
||||
|
||||
for (var i = 0; i < body.length; i++) {
|
||||
var bodyNode = body[i];
|
||||
|
||||
@ -22,3 +22,11 @@ export function toComputedKey(): Object {
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
|
||||
export function ensureBlock() {
|
||||
return t.ensureBlock(this.node);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user