Fix issues after merge

This commit is contained in:
Ron Buckton
2016-05-17 22:44:19 -07:00
parent 83b4cbb2d8
commit 4ae83fa8d3
3 changed files with 65 additions and 59 deletions
+41 -41
View File
@@ -112,7 +112,7 @@ namespace ts {
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange, emitOptions?: NodeEmitOptions): StringLiteral;
export function createLiteral(value: string, location?: TextRange, emitOptions?: NodeEmitOptions): StringLiteral;
export function createLiteral(value: number, location?: TextRange, emitOptions?: NodeEmitOptions): LiteralExpression;
export function createLiteral(value: number, location?: TextRange, emitOptions?: NodeEmitOptions): NumericLiteral;
export function createLiteral(value: string | number | boolean, location?: TextRange, emitOptions?: NodeEmitOptions): PrimaryExpression;
export function createLiteral(value: string | number | boolean | StringLiteral | Identifier, location?: TextRange, emitOptions?: NodeEmitOptions): PrimaryExpression {
if (typeof value === "number") {
@@ -505,7 +505,7 @@ namespace ts {
return node;
}
export function createCaseBlock(clauses: CaseClause[], location?: TextRange): CaseBlock {
export function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock {
const node = <CaseBlock>createNode(SyntaxKind.CaseBlock, location);
node.clauses = createNodeArray(clauses);
return node;
@@ -570,13 +570,6 @@ namespace ts {
return node;
}
export function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): ReturnStatement {
const node = <SwitchStatement>createNode(SyntaxKind.SwitchStatement, location);
node.expression = expression;
node.caseBlock = caseBlock;
return node;
}
export function createThrow(expression: Expression, location?: TextRange): ReturnStatement {
const node = <ThrowStatement>createNode(SyntaxKind.ThrowStatement, location);
node.expression = expression;
@@ -626,12 +619,6 @@ namespace ts {
return node;
}
export function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange) {
const node = <CaseBlock>createNode(SyntaxKind.CaseBlock, location);
node.clauses = createNodeArray(clauses);
return node;
}
export function createExportDefault(expression: Expression) {
const node = <ExportAssignment>createNode(SyntaxKind.ExportAssignment);
node.isExportEquals = false;
@@ -1262,34 +1249,47 @@ namespace ts {
function createExpressionForAccessorDeclaration(properties: NodeArray<Declaration>, property: AccessorDeclaration, receiver: Expression, multiLine: boolean) {
const { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(properties, property);
if (property === firstAccessor) {
return aggregateTransformFlags(
createObjectDefineProperty(
const properties: ObjectLiteralElement[] = [];
if (getAccessor) {
const getterFunction = createFunctionExpression(
/*asteriskToken*/ undefined,
/*name*/ undefined,
getAccessor.parameters,
getAccessor.body,
/*location*/ getAccessor,
/*original*/ getAccessor
);
const getter = createPropertyAssignment("get", getterFunction);
properties.push(getter);
}
if (setAccessor) {
const setterFunction = createFunctionExpression(
/*asteriskToken*/ undefined,
/*name*/ undefined,
setAccessor.parameters,
setAccessor.body,
/*location*/ setAccessor,
/*original*/ setAccessor
);
const setter = createPropertyAssignment("set", setterFunction);
properties.push(setter);
}
properties.push(createPropertyAssignment("enumerable", createLiteral(true)));
properties.push(createPropertyAssignment("configurable", createLiteral(true)));
const expression = createCall(
createPropertyAccess(createIdentifier("Object"), "defineProperty"),
[
receiver,
createExpressionForPropertyName(property.name, /*location*/ property.name),
{
get: getAccessor && createFunctionExpression(
/*asteriskToken*/ undefined,
/*name*/ undefined,
getAccessor.parameters,
getAccessor.body,
/*location*/ getAccessor,
/*original*/ getAccessor
),
set: setAccessor && createFunctionExpression(
/*asteriskToken*/ undefined,
/*name*/ undefined,
setAccessor.parameters,
setAccessor.body,
/*location*/ setAccessor,
/*original*/ setAccessor
),
enumerable: true,
configurable: true
},
multiLine,
/*location*/ firstAccessor
)
createExpressionForPropertyName(property.name),
createObjectLiteral(properties, /*location*/ undefined, multiLine)
],
/*location*/ firstAccessor
);
return aggregateTransformFlags(expression);
}
return undefined;
-8
View File
@@ -2129,14 +2129,6 @@ const _super = (function (geti, seti) {
}
}
function shouldEmitCaseOrDefaultClauseStatementOnSameLine(parentNode: Node, statement: Statement) {
if (statement.startsOnNewLine || nodeIsSynthesized(parentNode)) {
return false;
}
return nodeIsSynthesized(statement) || rangeStartPositionsAreOnSameLine(parentNode, statement);
}
function emitHeritageClause(node: HeritageClause) {
write(" ");
writeTokenText(node.token);
+24 -10
View File
@@ -235,11 +235,13 @@ namespace ts {
endLexicalEnvironment,
hoistFunctionDeclaration,
hoistVariableDeclaration,
setSourceMapRange,
setCommentRange
} = context;
const resolver = context.getEmitResolver();
const previousExpressionSubstitution = context.expressionSubstitution;
context.expressionSubstitution = substituteExpression;
const previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
let renamedCatchVariables: Map<boolean>;
let renamedCatchVariableDeclarations: Map<Identifier>;
@@ -994,7 +996,7 @@ namespace ts {
// .mark resumeLabel
// _b.apply(_a, _c.concat([%sent%, 2]));
const { target, thisArg } = createCallBinding(node.expression);
const { target, thisArg } = createCallBinding(node.expression, hoistVariableDeclaration);
return setOriginalNode(
createFunctionApply(
cacheExpression(visitNode(target, visitor, isLeftHandSideExpression)),
@@ -1022,7 +1024,7 @@ namespace ts {
// .mark resumeLabel
// new (_b.apply(_a, _c.concat([%sent%, 2])));
const { target, thisArg } = createCallBinding(createPropertyAccess(node.expression, "bind"));
const { target, thisArg } = createCallBinding(createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration);
return setOriginalNode(
createNew(
createFunctionApply(
@@ -1807,8 +1809,15 @@ namespace ts {
return -1;
}
function onSubstituteNode(node: Node, isExpression: boolean): Node {
node = previousOnSubstituteNode(node, isExpression);
if (isExpression) {
return substituteExpression(<Expression> node);
}
return node;
}
function substituteExpression(node: Expression): Expression {
node = previousExpressionSubstitution(node);
if (isIdentifier(node)) {
return substituteExpressionIdentifier(node);
}
@@ -1823,7 +1832,10 @@ namespace ts {
if (declaration) {
const name = getProperty(renamedCatchVariableDeclarations, String(getOriginalNodeId(declaration)));
if (name) {
return getRelocatedClone(name, /*location*/ node);
const clone = getMutableClone(name);
setSourceMapRange(clone, node);
setCommentRange(clone, node);
return clone;
}
}
}
@@ -1842,7 +1854,7 @@ namespace ts {
temp = createUniqueName(node.text);
}
else {
temp = createTempVariable();
temp = createTempVariable(hoistVariableDeclaration);
}
emitAssignment(temp, node, /*location*/ node);
@@ -1852,7 +1864,7 @@ namespace ts {
function declareLocal(name?: string): Identifier {
const temp = name
? createUniqueName(name)
: createTempVariable();
: createTempVariable(hoistVariableDeclaration);
hoistVariableDeclaration(temp);
return temp;
}
@@ -1991,7 +2003,7 @@ namespace ts {
if (!renamedCatchVariables) {
renamedCatchVariables = {};
renamedCatchVariableDeclarations = {};
context.enableExpressionSubstitution(SyntaxKind.Identifier);
context.enableSubstitution(SyntaxKind.Identifier);
}
renamedCatchVariables[text] = true;
@@ -2300,7 +2312,9 @@ namespace ts {
* Creates a numeric literal for the provided instruction.
*/
function createInstruction(instruction: Instruction): NumericLiteral {
return createLiteral(instruction, /*location*/ undefined, instructionNames[instruction]);
const literal = createLiteral(instruction);
literal.trailingComment = instructionNames[instruction];
return literal;
}
/**