diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 89c39cdc36b..b10c8acb7ef 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2711,126 +2711,6 @@ module ts { return result; } - function emitDownlevelObjectLiteralWithComputedProperties2(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) { - var multiLine = (node.flags & NodeFlags.MultiLine) !== 0; - var properties = node.properties; - - write("("); - - if (multiLine) { - increaseIndent(); - } - - // 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 = createAndRecordTempVariable(node); - - // Write out the first non-computed properties - // (or all properties if none of them are computed), - // then emit the rest through indexing on the temp variable. - emit(tempVar) - write(" = "); - emitObjectLiteralBody(node, firstComputedPropertyIndex); - - - for (var i = firstComputedPropertyIndex, n = properties.length; i < n; i++) { - writeComma(); - - var property = properties[i]; - - emitStart(property) - if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) { - // TODO (drosen): Reconcile with 'emitMemberFunctions'. - var accessors = getAllAccessorDeclarations(node.properties, property); - if (property !== accessors.firstAccessor) { - continue; - } - write("Object.defineProperty("); - emit(tempVar); - write(", "); - emitStart(node.name); - emitExpressionForPropertyName(property.name); - emitEnd(property.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine() - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("})"); - emitEnd(property); - } - else { - emitLeadingComments(property); - emitStart(property.name); - emit(tempVar); - emitMemberAccessForPropertyName(property.name); - emitEnd(property.name); - - write(" = "); - - if (property.kind === SyntaxKind.PropertyAssignment) { - emit((property).initializer); - } - else if (property.kind === SyntaxKind.ShorthandPropertyAssignment) { - emitExpressionIdentifier((property).name); - } - else if (property.kind === SyntaxKind.MethodDeclaration) { - emitFunctionDeclaration(property); - } - else { - Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind); - } - } - - emitEnd(property); - } - - writeComma(); - emit(tempVar); - - if (multiLine) { - decreaseIndent(); - writeLine(); - } - - write(")"); - - function writeComma() { - if (multiLine) { - write(","); - writeLine(); - } - else { - write(", "); - } - } - } - function emitObjectLiteral(node: ObjectLiteralExpression): void { var properties = node.properties;