add ensureBlock path method

This commit is contained in:
Sebastian McKenzie 2015-06-21 23:59:14 +01:00
parent 4b0f624fb3
commit ebaa06f4a2
6 changed files with 15 additions and 7 deletions

View File

@ -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";

View File

@ -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);

View File

@ -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) {

View File

@ -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,

View File

@ -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];

View File

@ -22,3 +22,11 @@ export function toComputedKey(): Object {
return key;
}
/**
* Description
*/
export function ensureBlock() {
return t.ensureBlock(this.node);
}