Skip to content

Commit 4e45af6

Browse files
committed
Move auto-generated identifier info into separate object
1 parent eb9252e commit 4e45af6

File tree

11 files changed

+96
-59
lines changed

11 files changed

+96
-59
lines changed

after.log

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$ node --log-deopt --redirect-code-traces --redirect-code-traces-to=\\.\NUL --log-ic --log-maps --log-maps-details --log-code --log-source-code --prof --log-internal-timer-events --detailed-line-info --logfile=monaco-autoGenerate-v8.log --no-logfile-per-isolate D:/dev/TypeScript-Polymorph/built/local/tsc.js -p D:\Dev\TypeScript\internal\cases\perf\solutions\monaco\ --outDir C:\Users\rbuckton\AppData\Local\Temp\perf-outDir
2+
error TS2318: Cannot find global type 'Extract'.
3+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/base/dom/builder.ts(86,43): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
4+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/base/dom/mockDom.ts(189,14): error TS2420: Class 'MockElement' incorrectly implements interface 'Element'.
5+
Types of property 'addEventListener' are incompatible.
6+
Type '(type: string, listener: EventListener, useCapture?: boolean) => void' is not assignable to type '{ (type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; (type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; (type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; (type: "pointerup", listener: (ev: PointerEvent) =>...'.
7+
Types of parameters 'listener' and 'listener' are incompatible.
8+
Types of parameters 'ev' and 'evt' are incompatible.
9+
Type 'Event' is not assignable to type 'PointerEvent'.
10+
Type 'Event' is missing the following properties from type 'PointerEvent': width, rotation, pressure, pointerType, and 38 more.
11+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/base/ui/widgets/tree/treeDefaults.ts(108,8): error TS1345: An expression of type 'void' cannot be tested for truthiness.
12+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/editor/contrib/goToDeclaration/goToDeclaration.ts(246,15): error TS1345: An expression of type 'void' cannot be tested for truthiness.
13+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/monarch/monarch.ts(336,4): error TS2559: Type 'string' has no properties in common with type 'IAction'.
14+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/monarch/monarchCompile.ts(222,3): error TS2559: Type 'string' has no properties in common with type 'IAction'.
15+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/monarch/monarchCompile.ts(301,4): error TS2322: Type '(id: string, matches: string[], state: string, eos: boolean) => string | IAction' is not assignable to type '(id: string, matches: string[], state: string, eos: boolean) => IAction'.
16+
Type 'string | IAction' is not assignable to type 'IAction'.
17+
Type 'string' has no properties in common with type 'IAction'.
18+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/monarch/monarchCompile.ts(315,3): error TS2559: Type '""' has no properties in common with type 'IAction'.
19+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/typescript/lib/ts09/typescriptServices09.d.ts(266,16): error TS2416: Property 'every' in type 'DualStringHashTable' is not assignable to the same property in base type 'IHashTable'.
20+
Types of parameters 'fn' and 'fn' are incompatible.
21+
Type 'void' is not assignable to type 'boolean'.
22+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/typescript/lib/ts09/typescriptServices09.d.ts(267,16): error TS2416: Property 'some' in type 'DualStringHashTable' is not assignable to the same property in base type 'IHashTable'.
23+
Types of parameters 'fn' and 'fn' are incompatible.
24+
Type 'void' is not assignable to type 'boolean'.
25+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/languages/typescript/resources/errorCollection.ts(15,14): error TS2559: Type 'UnitErrors' has no properties in common with type 'ILinkedResource'.
26+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/platform/markers/markersWorker.ts(75,9): error TS2416: Property 'forEach' in type 'SingleMarkerReadAccessor' is not assignable to the same property in base type 'IMarkerReadAccessor'.
27+
Type '(callback: (marker: IMarker, index: number) => void) => void' is not assignable to type '(callback: (marker: IMarker, index: number, values: IMarker[]) => void) => void'.
28+
Types of parameters 'callback' and 'callback' are incompatible.
29+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/platform/markers/markersWorker.ts(135,13): error TS2345: Argument of type 'SingleMarkerReadAccessor' is not assignable to parameter of type 'IMarkerReadAccessor'.
30+
Types of property 'forEach' are incompatible.
31+
Type '(callback: (marker: IMarker, index: number) => void) => void' is not assignable to type '(callback: (marker: IMarker, index: number, values: IMarker[]) => void) => void'.
32+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/workbench/contrib/debug/debuggerActions.ts(35,29): error TS2845: This condition will always return 'false'.
33+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/workbench/contrib/files/explorerActions.ts(393,35): error TS2345: Argument of type '(c: () => void, e: () => void, p: () => void) => any' is not assignable to parameter of type '(complete: ValueCallback, error: ErrorCallback, progress: ProgressCallback) => void'.
34+
Types of parameters 'c' and 'complete' are incompatible.
35+
../TypeScript/internal/cases/perf/solutions/monaco/client/vs/workbench/contrib/work/workViewlet.ts(361,9): error TS2610: 'id' is defined as an accessor in class 'Action', but is overridden here in 'ViewletAction' as an instance property.

src/compiler/emitter.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,15 +5628,15 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
56285628
* Generate the text for a generated identifier.
56295629
*/
56305630
function generateName(name: GeneratedIdentifier | GeneratedPrivateIdentifier) {
5631-
if ((name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask) === GeneratedIdentifierFlags.Node) {
5631+
if ((name.autoGenerate.flags & GeneratedIdentifierFlags.KindMask) === GeneratedIdentifierFlags.Node) {
56325632
// Node names generate unique names based on their original node
56335633
// and are cached based on that node's id.
5634-
return generateNameCached(getNodeForGeneratedName(name), isPrivateIdentifier(name), name.autoGenerateFlags, name.autoGeneratePrefix, name.autoGenerateSuffix);
5634+
return generateNameCached(getNodeForGeneratedName(name), isPrivateIdentifier(name), name.autoGenerate.flags, name.autoGenerate.prefix, name.autoGenerate.suffix);
56355635
}
56365636
else {
56375637
// Auto, Loop, and Unique names are cached based on their unique
56385638
// autoGenerateId.
5639-
const autoGenerateId = name.autoGenerateId!;
5639+
const autoGenerateId = name.autoGenerate.id;
56405640
return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
56415641
}
56425642
}
@@ -5889,27 +5889,27 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
58895889
* Generates a unique identifier for a node.
58905890
*/
58915891
function makeName(name: GeneratedIdentifier | GeneratedPrivateIdentifier) {
5892-
const prefix = formatGeneratedNamePart(name.autoGeneratePrefix, generateName);
5893-
const suffix = formatGeneratedNamePart (name.autoGenerateSuffix);
5894-
switch (name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask) {
5892+
const prefix = formatGeneratedNamePart(name.autoGenerate.prefix, generateName);
5893+
const suffix = formatGeneratedNamePart (name.autoGenerate.suffix);
5894+
switch (name.autoGenerate.flags & GeneratedIdentifierFlags.KindMask) {
58955895
case GeneratedIdentifierFlags.Auto:
5896-
return makeTempVariableName(TempFlags.Auto, !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes), isPrivateIdentifier(name), prefix, suffix);
5896+
return makeTempVariableName(TempFlags.Auto, !!(name.autoGenerate.flags & GeneratedIdentifierFlags.ReservedInNestedScopes), isPrivateIdentifier(name), prefix, suffix);
58975897
case GeneratedIdentifierFlags.Loop:
58985898
Debug.assertNode(name, isIdentifier);
5899-
return makeTempVariableName(TempFlags._i, !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes), /*privateName*/ false, prefix, suffix);
5899+
return makeTempVariableName(TempFlags._i, !!(name.autoGenerate.flags & GeneratedIdentifierFlags.ReservedInNestedScopes), /*privateName*/ false, prefix, suffix);
59005900
case GeneratedIdentifierFlags.Unique:
59015901
return makeUniqueName(
59025902
idText(name),
5903-
(name.autoGenerateFlags & GeneratedIdentifierFlags.FileLevel) ? isFileLevelUniqueName : isUniqueName,
5904-
!!(name.autoGenerateFlags & GeneratedIdentifierFlags.Optimistic),
5905-
!!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes),
5903+
(name.autoGenerate.flags & GeneratedIdentifierFlags.FileLevel) ? isFileLevelUniqueName : isUniqueName,
5904+
!!(name.autoGenerate.flags & GeneratedIdentifierFlags.Optimistic),
5905+
!!(name.autoGenerate.flags & GeneratedIdentifierFlags.ReservedInNestedScopes),
59065906
isPrivateIdentifier(name),
59075907
prefix,
59085908
suffix
59095909
);
59105910
}
59115911

5912-
return Debug.fail(`Unsupported GeneratedIdentifierKind: ${Debug.formatEnum(name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask, (ts as any).GeneratedIdentifierFlags, /*isFlags*/ true)}.`);
5912+
return Debug.fail(`Unsupported GeneratedIdentifierKind: ${Debug.formatEnum(name.autoGenerate.flags & GeneratedIdentifierFlags.KindMask, (ts as any).GeneratedIdentifierFlags, /*isFlags*/ true)}.`);
59135913
}
59145914

59155915
// Comments

src/compiler/factory/nodeFactory.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,16 +1154,24 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
11541154
const node = baseFactory.createBaseIdentifierNode(SyntaxKind.Identifier) as Mutable<Identifier>;
11551155
node.originalKeywordKind = originalKeywordKind;
11561156
node.escapedText = escapedText;
1157-
node.autoGenerateFlags = GeneratedIdentifierFlags.None;
1157+
node.autoGenerate = undefined;
1158+
node.typeArguments = undefined;
1159+
node.hasExtendedUnicodeEscape = undefined;
1160+
node.jsDoc = undefined; // initialized by parser (JsDocContainer)
1161+
node.jsDocCache = undefined; // initialized by parser (JsDocContainer)
1162+
node.flowNode = undefined; // initialized by binder (FlowContainer)
1163+
node.symbol = undefined!; // initialized by checker
11581164
return node;
11591165
}
11601166

11611167
function createBaseGeneratedIdentifier(text: string, autoGenerateFlags: GeneratedIdentifierFlags, prefix: string | GeneratedNamePart | undefined, suffix: string | undefined) {
11621168
const node = createBaseIdentifier(escapeLeadingUnderscores(text), /*originalKeywordKind*/ undefined) as Mutable<GeneratedIdentifier>;
1163-
node.autoGenerateFlags = autoGenerateFlags;
1164-
node.autoGenerateId = nextAutoGenerateId;
1165-
node.autoGeneratePrefix = prefix;
1166-
node.autoGenerateSuffix = suffix;
1169+
node.autoGenerate = {
1170+
flags: autoGenerateFlags,
1171+
id: nextAutoGenerateId,
1172+
prefix,
1173+
suffix
1174+
};
11671175
nextAutoGenerateId++;
11681176
return node;
11691177
}
@@ -1180,10 +1188,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
11801188
const node = createBaseIdentifier(escapeLeadingUnderscores(text), originalKeywordKind);
11811189
node.typeArguments = asNodeArray(typeArguments);
11821190
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
1183-
node.jsDoc = undefined; // initialized by parser (JsDocContainer)
1184-
node.jsDocCache = undefined; // initialized by parser (JsDocContainer)
1185-
node.flowNode = undefined; // initialized by binder (FlowContainer)
1186-
node.symbol = undefined!; // initialized by checker
11871191

11881192
// NOTE: we do not include transform flags of typeArguments in an identifier as they do not contribute to transformations
11891193
if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
@@ -1246,7 +1250,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
12461250
function createBasePrivateIdentifier(escapedText: __String) {
12471251
const node = baseFactory.createBasePrivateIdentifierNode(SyntaxKind.PrivateIdentifier) as Mutable<PrivateIdentifier>;
12481252
node.escapedText = escapedText;
1249-
node.autoGenerateFlags = GeneratedIdentifierFlags.None;
1253+
node.autoGenerate = undefined;
12501254
node.transformFlags |= TransformFlags.ContainsClassFields;
12511255
return node;
12521256
}
@@ -1259,10 +1263,12 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
12591263

12601264
function createBaseGeneratedPrivateIdentifier(text: string, autoGenerateFlags: GeneratedIdentifierFlags, prefix: string | GeneratedNamePart | undefined, suffix: string | undefined) {
12611265
const node = createBasePrivateIdentifier(escapeLeadingUnderscores(text));
1262-
node.autoGenerateFlags = autoGenerateFlags;
1263-
node.autoGenerateId = nextAutoGenerateId;
1264-
node.autoGeneratePrefix = prefix;
1265-
node.autoGenerateSuffix = suffix;
1266+
node.autoGenerate = {
1267+
flags: autoGenerateFlags,
1268+
id: nextAutoGenerateId,
1269+
prefix,
1270+
suffix,
1271+
};
12661272
nextAutoGenerateId++;
12671273
return node;
12681274
}
@@ -6374,10 +6380,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
63746380
function cloneGeneratedIdentifier(node: GeneratedIdentifier): GeneratedIdentifier {
63756381
const clone = createBaseIdentifier(node.escapedText, /*originalKeywordKind*/ undefined) as Mutable<GeneratedIdentifier>;
63766382
clone.flags |= node.flags & ~NodeFlags.Synthesized;
6377-
clone.autoGenerateFlags = node.autoGenerateFlags;
6378-
clone.autoGenerateId = node.autoGenerateId;
6379-
clone.autoGeneratePrefix = node.autoGeneratePrefix;
6380-
clone.autoGenerateSuffix = node.autoGenerateSuffix;
6383+
clone.autoGenerate = { ...node.autoGenerate };
63816384
clone.transformFlags = node.transformFlags;
63826385
setOriginalNode(clone, node);
63836386
return clone;
@@ -6400,10 +6403,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
64006403
function cloneGeneratedPrivateIdentifier(node: GeneratedPrivateIdentifier): GeneratedPrivateIdentifier {
64016404
const clone = createBasePrivateIdentifier(node.escapedText) as Mutable<GeneratedPrivateIdentifier>;
64026405
clone.flags |= node.flags & ~NodeFlags.Synthesized;
6403-
clone.autoGenerateFlags = node.autoGenerateFlags;
6404-
clone.autoGenerateId = node.autoGenerateId;
6405-
clone.autoGeneratePrefix = node.autoGeneratePrefix;
6406-
clone.autoGenerateSuffix = node.autoGenerateSuffix;
6406+
clone.autoGenerate = { ...node.autoGenerate };
64076407
clone.transformFlags = node.transformFlags;
64086408
setOriginalNode(clone, node);
64096409
return clone;

src/compiler/factory/utilities.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,17 +1489,18 @@ export function elideNodes<T extends Node>(factory: NodeFactory, nodes: NodeArra
14891489
* @internal
14901490
*/
14911491
export function getNodeForGeneratedName(name: GeneratedIdentifier | GeneratedPrivateIdentifier) {
1492-
if (name.autoGenerateFlags & GeneratedIdentifierFlags.Node) {
1493-
const autoGenerateId = name.autoGenerateId;
1492+
if (name.autoGenerate.flags & GeneratedIdentifierFlags.Node) {
1493+
const autoGenerateId = name.autoGenerate.id;
14941494
let node = name as Node;
14951495
let original = node.original;
14961496
while (original) {
14971497
node = original;
14981498

14991499
// if "node" is a different generated name (having a different "autoGenerateId"), use it and stop traversing.
1500-
if (isMemberName(node)
1501-
&& !!(node.autoGenerateFlags! & GeneratedIdentifierFlags.Node)
1502-
&& node.autoGenerateId !== autoGenerateId) {
1500+
if (isMemberName(node) && (
1501+
node.autoGenerate === undefined ||
1502+
!!(node.autoGenerate.flags & GeneratedIdentifierFlags.Node) &&
1503+
node.autoGenerate.id !== autoGenerateId)) {
15031504
break;
15041505
}
15051506

src/compiler/transformers/classFields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
15121512
// record an alias as the class name is not in scope for statics.
15131513
enableSubstitutionForClassAliases();
15141514
const alias = factory.cloneNode(temp) as GeneratedIdentifier;
1515-
alias.autoGenerateFlags &= ~GeneratedIdentifierFlags.ReservedInNestedScopes;
1515+
alias.autoGenerate.flags &= ~GeneratedIdentifierFlags.ReservedInNestedScopes;
15161516
classAliases[getOriginalNodeId(node)] = alias;
15171517
}
15181518

src/compiler/transformers/module/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
20642064
}
20652065
return node;
20662066
}
2067-
else if (!(isGeneratedIdentifier(node) && !(node.autoGenerateFlags & GeneratedIdentifierFlags.AllowNameSubstitution)) && !isLocalName(node)) {
2067+
else if (!(isGeneratedIdentifier(node) && !(node.autoGenerate.flags & GeneratedIdentifierFlags.AllowNameSubstitution)) && !isLocalName(node)) {
20682068
const exportContainer = resolver.getReferencedExportContainer(node, isExportName(node));
20692069
if (exportContainer && exportContainer.kind === SyntaxKind.SourceFile) {
20702070
return setTextRange(

0 commit comments

Comments
 (0)