From a6c55058814f819c32f75f44dca2f76a36aefc9a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 18 Feb 2015 12:10:00 -0800 Subject: [PATCH] Created a combined 'createAndRecordTempVariable' function. --- src/compiler/emitter.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 40338636c3e..06648fb90db 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2002,13 +2002,20 @@ module ts { return result; } - function recordTempDeclaration(name: Identifier) { + function recordTempDeclaration(name: Identifier): void { if (!tempVariables) { tempVariables = []; } tempVariables.push(name); } + function createAndRecordTempVariable(location: Node): Identifier { + var temp = createTempVariable(location, /*forLoopVariable*/ false); + recordTempDeclaration(temp); + + return temp; + } + function emitTempDeclarations(newLine: boolean) { if (tempVariables) { if (newLine) { @@ -2505,8 +2512,7 @@ module ts { // For computed properties, we need to create a unique handle to the object // literal so we can modify it without risking internal assignments tainting the object. - var tempVar = createTempVariable(node); - recordTempDeclaration(tempVar); + var tempVar = createAndRecordTempVariable(node); // Write out the first non-computed properties // (or all properties if none of them are computed), @@ -2735,8 +2741,8 @@ module ts { emit(node); return node; } - var temp = createTempVariable(node); - recordTempDeclaration(temp); + var temp = createAndRecordTempVariable(node); + write("("); emit(temp); write(" = ");