Merge branch 'transforms-transformer' into transforms-printer

This commit is contained in:
Ron Buckton 2016-02-16 16:01:32 -08:00
commit 8ec393244b
3 changed files with 16 additions and 12 deletions

View file

@ -180,6 +180,7 @@ namespace ts {
block.statements = createNodeArray(statements);
return block;
}
export function createVariableDeclaration(name: BindingPattern | Identifier, initializer?: Expression, location?: TextRange): VariableDeclaration {
const node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration, location);
node.name = name;
@ -203,17 +204,17 @@ namespace ts {
export function createLiteral(value: string): StringLiteral;
export function createLiteral(value: number): LiteralExpression;
export function createLiteral(value: string | number | boolean): PrimaryExpression;
export function createLiteral<T extends PrimaryExpression>(value: string | number | boolean): T {
export function createLiteral(value: string | number | boolean): PrimaryExpression {
if (typeof value === "number") {
const node = <T & LiteralExpression>createNode(SyntaxKind.NumericLiteral);
const node = <LiteralExpression>createNode(SyntaxKind.NumericLiteral);
node.text = value.toString();
return node;
}
else if (typeof value === "boolean") {
return <T>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
return <PrimaryExpression>createNode(value ? SyntaxKind.TrueKeyword : SyntaxKind.FalseKeyword);
}
else {
const node = <T & StringLiteral>createNode(SyntaxKind.StringLiteral);
const node = <StringLiteral>createNode(SyntaxKind.StringLiteral);
node.text = String(value);
return node;
}

View file

@ -229,14 +229,16 @@ namespace ts {
}
/**
* Records a hoisted variable declaration within a lexical environment.
* Records a hoisted variable declaration for the provided name within a lexical environment.
*/
function hoistVariableDeclaration(name: Identifier): void {
const decl = createVariableDeclaration(name);
if (!hoistedVariableDeclarations) {
hoistedVariableDeclarations = [];
hoistedVariableDeclarations = [decl];
}
else {
hoistedVariableDeclarations.push(decl);
}
hoistedVariableDeclarations.push(createVariableDeclaration(name));
}
/**
@ -244,10 +246,11 @@ namespace ts {
*/
function hoistFunctionDeclaration(func: FunctionDeclaration): void {
if (!hoistedFunctionDeclarations) {
hoistedFunctionDeclarations = [];
hoistedFunctionDeclarations = [func];
}
else {
hoistedFunctionDeclarations.push(func);
}
hoistedFunctionDeclarations.push(func);
}
/**

View file

@ -2795,7 +2795,7 @@ namespace ts {
EmitSuperHelper = 1 << 2, // Emit the basic _super helper for async methods.
EmitAdvancedSuperHelper = 1 << 3, // Emit the advanced _super helper for async methods.
UMDDefine = 1 << 4, // This node should be replaced with the UMD define helper.
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node.
NoLexicalEnvironment = 1 << 5, // A new LexicalEnvironment should *not* be introduced when emitting this node, this is primarily used when printing a SystemJS module.
SingleLine = 1 << 6, // The contents of this node should be emit on a single line.
MultiLine = 1 << 7, // The contents of this node should be emit on multiple lines.
AdviseOnEmitNode = 1 << 8, // The node printer should invoke the onBeforeEmitNode and onAfterEmitNode callbacks when printing this node.