Skip to content

Commit b73ce26

Browse files
committed
Dont emit names index mapping into the sourcemap
Since sourcemap spec is not very clear about symbol translation and use of nameIndex of the mapping, dont emit it
1 parent bd84b84 commit b73ce26

1 file changed

Lines changed: 0 additions & 107 deletions

File tree

src/compiler/emitter.ts

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
548548
* @param emitFn if given will be invoked to emit the text instead of actual token emit */
549549
let emitToken = emitTokenText;
550550

551-
/** Called to before starting the lexical scopes as in function/class in the emitted code because of node
552-
* @param scopeDeclaration node that starts the lexical scope
553-
* @param scopeName Optional name of this scope instead of deducing one from the declaration node */
554-
let scopeEmitStart = function(scopeDeclaration: Node, scopeName?: string) { };
555-
556-
/** Called after coming out of the scope */
557-
let scopeEmitEnd = function() { };
558-
559551
/** Sourcemap data that will get encoded */
560552
let sourceMapData: SourceMapData;
561553

@@ -753,13 +745,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
753745
// Current source map file and its index in the sources list
754746
let sourceMapSourceIndex = -1;
755747

756-
// Names and its index map
757-
const sourceMapNameIndexMap: Map<number> = {};
758-
const sourceMapNameIndices: number[] = [];
759-
function getSourceMapNameIndex() {
760-
return sourceMapNameIndices.length ? lastOrUndefined(sourceMapNameIndices) : -1;
761-
}
762-
763748
// Last recorded and encoded spans
764749
let lastRecordedSourceMapSpan: SourceMapSpan;
765750
let lastEncodedSourceMapSpan: SourceMapSpan = {
@@ -769,7 +754,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
769754
sourceColumn: 1,
770755
sourceIndex: 0
771756
};
772-
let lastEncodedNameIndex = 0;
773757

774758
// Encoding for sourcemap span
775759
function encodeLastRecordedSourceMapSpan() {
@@ -805,12 +789,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
805789
// 4. Relative sourceColumn 0 based
806790
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn);
807791

808-
// 5. Relative namePosition 0 based
809-
if (lastRecordedSourceMapSpan.nameIndex >= 0) {
810-
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex);
811-
lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex;
812-
}
813-
814792
lastEncodedSourceMapSpan = lastRecordedSourceMapSpan;
815793
sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan);
816794

@@ -876,7 +854,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
876854
emittedColumn: emittedColumn,
877855
sourceLine: sourceLinePos.line,
878856
sourceColumn: sourceLinePos.character,
879-
nameIndex: getSourceMapNameIndex(),
880857
sourceIndex: sourceMapSourceIndex
881858
};
882859
}
@@ -929,69 +906,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
929906
}
930907
}
931908

932-
function recordScopeNameOfNode(node: Node, scopeName?: string) {
933-
function recordScopeNameIndex(scopeNameIndex: number) {
934-
sourceMapNameIndices.push(scopeNameIndex);
935-
}
936-
937-
function recordScopeNameStart(scopeName: string) {
938-
let scopeNameIndex = -1;
939-
if (scopeName) {
940-
const parentIndex = getSourceMapNameIndex();
941-
if (parentIndex !== -1) {
942-
// Child scopes are always shown with a dot (even if they have no name),
943-
// unless it is a computed property. Then it is shown with brackets,
944-
// but the brackets are included in the name.
945-
const name = (<Declaration>node).name;
946-
if (!name || name.kind !== SyntaxKind.ComputedPropertyName) {
947-
scopeName = "." + scopeName;
948-
}
949-
scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName;
950-
}
951-
952-
scopeNameIndex = getProperty(sourceMapNameIndexMap, scopeName);
953-
if (scopeNameIndex === undefined) {
954-
scopeNameIndex = sourceMapData.sourceMapNames.length;
955-
sourceMapData.sourceMapNames.push(scopeName);
956-
sourceMapNameIndexMap[scopeName] = scopeNameIndex;
957-
}
958-
}
959-
recordScopeNameIndex(scopeNameIndex);
960-
}
961-
962-
if (scopeName) {
963-
// The scope was already given a name use it
964-
recordScopeNameStart(scopeName);
965-
}
966-
else if (node.kind === SyntaxKind.FunctionDeclaration ||
967-
node.kind === SyntaxKind.FunctionExpression ||
968-
node.kind === SyntaxKind.MethodDeclaration ||
969-
node.kind === SyntaxKind.MethodSignature ||
970-
node.kind === SyntaxKind.GetAccessor ||
971-
node.kind === SyntaxKind.SetAccessor ||
972-
node.kind === SyntaxKind.ModuleDeclaration ||
973-
node.kind === SyntaxKind.ClassDeclaration ||
974-
node.kind === SyntaxKind.EnumDeclaration) {
975-
// Declaration and has associated name use it
976-
if ((<Declaration>node).name) {
977-
const name = (<Declaration>node).name;
978-
// For computed property names, the text will include the brackets
979-
scopeName = name.kind === SyntaxKind.ComputedPropertyName
980-
? getTextOfNode(name)
981-
: (<Identifier>(<Declaration>node).name).text;
982-
}
983-
recordScopeNameStart(scopeName);
984-
}
985-
else {
986-
// Block just use the name from upper level scope
987-
recordScopeNameIndex(getSourceMapNameIndex());
988-
}
989-
}
990-
991-
function recordScopeNameEnd() {
992-
sourceMapNameIndices.pop();
993-
};
994-
995909
function writeCommentRangeWithMap(currentText: string, currentLineMap: number[], writer: EmitTextWriter, comment: CommentRange, newLine: string) {
996910
recordSourceMapSpan(comment.pos);
997911
writeCommentRange(currentText, currentLineMap, writer, comment, newLine);
@@ -1134,8 +1048,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
11341048
emitStart = recordEmitNodeStartSpan;
11351049
emitEnd = recordEmitNodeEndSpan;
11361050
emitToken = writeTextWithSpanRecord;
1137-
scopeEmitStart = recordScopeNameOfNode;
1138-
scopeEmitEnd = recordScopeNameEnd;
11391051
writeComment = writeCommentRangeWithMap;
11401052
}
11411053

@@ -3124,7 +3036,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
31243036

31253037
emitToken(SyntaxKind.OpenBraceToken, node.pos);
31263038
increaseIndent();
3127-
scopeEmitStart(node.parent);
31283039
if (node.kind === SyntaxKind.ModuleBlock) {
31293040
Debug.assert(node.parent.kind === SyntaxKind.ModuleDeclaration);
31303041
emitCaptureThisForNodeIfNecessary(node.parent);
@@ -3136,7 +3047,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
31363047
decreaseIndent();
31373048
writeLine();
31383049
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
3139-
scopeEmitEnd();
31403050
}
31413051

31423052
function emitEmbeddedStatement(node: Node) {
@@ -4981,8 +4891,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
49814891

49824892
function emitDownLevelExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) {
49834893
write(" {");
4984-
scopeEmitStart(node);
4985-
49864894
increaseIndent();
49874895
const outPos = writer.getTextPos();
49884896
emitDetachedCommentsAndUpdateCommentsInfo(node.body);
@@ -5021,14 +4929,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
50214929
emitStart(node.body);
50224930
write("}");
50234931
emitEnd(node.body);
5024-
5025-
scopeEmitEnd();
50264932
}
50274933

50284934
function emitBlockFunctionBody(node: FunctionLikeDeclaration, body: Block) {
50294935
write(" {");
5030-
scopeEmitStart(node);
5031-
50324936
const initialTextPos = writer.getTextPos();
50334937

50344938
increaseIndent();
@@ -5062,7 +4966,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
50624966
}
50634967

50644968
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
5065-
scopeEmitEnd();
50664969
}
50674970

50684971
function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement {
@@ -5348,7 +5251,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53485251
let startIndex = 0;
53495252

53505253
write(" {");
5351-
scopeEmitStart(node, "constructor");
53525254
increaseIndent();
53535255
if (ctor) {
53545256
// Emit all the directive prologues (like "use strict"). These have to come before
@@ -5398,7 +5300,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53985300
}
53995301
decreaseIndent();
54005302
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
5401-
scopeEmitEnd();
54025303
emitEnd(<Node>ctor || node);
54035304
if (ctor) {
54045305
emitTrailingComments(ctor);
@@ -5535,14 +5436,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
55355436

55365437
write(" {");
55375438
increaseIndent();
5538-
scopeEmitStart(node);
55395439
writeLine();
55405440
emitConstructor(node, baseTypeNode);
55415441
emitMemberFunctionsForES6AndHigher(node);
55425442
decreaseIndent();
55435443
writeLine();
55445444
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
5545-
scopeEmitEnd();
55465445

55475446
// TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now.
55485447

@@ -5629,7 +5528,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
56295528
tempParameters = undefined;
56305529
computedPropertyNamesToGeneratedNames = undefined;
56315530
increaseIndent();
5632-
scopeEmitStart(node);
56335531
if (baseTypeNode) {
56345532
writeLine();
56355533
emitStart(baseTypeNode);
@@ -5662,7 +5560,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
56625560
decreaseIndent();
56635561
writeLine();
56645562
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
5665-
scopeEmitEnd();
56665563
emitStart(node);
56675564
write(")(");
56685565
if (baseTypeNode) {
@@ -6225,12 +6122,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
62256122
emitEnd(node.name);
62266123
write(") {");
62276124
increaseIndent();
6228-
scopeEmitStart(node);
62296125
emitLines(node.members);
62306126
decreaseIndent();
62316127
writeLine();
62326128
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
6233-
scopeEmitEnd();
62346129
write(")(");
62356130
emitModuleMemberName(node);
62366131
write(" || (");
@@ -6354,15 +6249,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
63546249
else {
63556250
write("{");
63566251
increaseIndent();
6357-
scopeEmitStart(node);
63586252
emitCaptureThisForNodeIfNecessary(node);
63596253
writeLine();
63606254
emit(node.body);
63616255
decreaseIndent();
63626256
writeLine();
63636257
const moduleBlock = <ModuleBlock>getInnerMostModuleDeclarationFromDottedModule(node).body;
63646258
emitToken(SyntaxKind.CloseBraceToken, moduleBlock.statements.end);
6365-
scopeEmitEnd();
63666259
}
63676260
write(")(");
63686261
// write moduleDecl = containingModule.m only if it is not exported es6 module member

0 commit comments

Comments
 (0)