Separate Tokens and Identifiers from other Nodes

With some further optimization to their properties, this shrinks the
objects by quite a bit.
This commit is contained in:
Arpad Borsos 2019-09-14 04:06:09 +02:00
parent 72c0961071
commit 391a3c8791
No known key found for this signature in database
GPG Key ID: 908EDF65263368B4

View File

@ -3962,6 +3962,9 @@ namespace ts {
}
export function getModifierFlags(node: Node): ModifierFlags {
if (node.kind >= SyntaxKind.FirstToken && node.kind <= SyntaxKind.LastToken) {
return ModifierFlags.None;
}
if (node.modifierFlagsCache & ModifierFlags.HasComputedFlags) {
return node.modifierFlagsCache & ~ModifierFlags.HasComputedFlags;
}
@ -7149,6 +7152,28 @@ namespace ts {
this.original = undefined;
}
function Token(this: Node, kind: SyntaxKind, pos: number, end: number) {
this.pos = pos;
this.end = end;
this.kind = kind;
this.id = 0;
this.flags = NodeFlags.None;
this.transformFlags = TransformFlags.None;
this.parent = undefined!;
}
function Identifier(this: Node, kind: SyntaxKind, pos: number, end: number) {
this.pos = pos;
this.end = end;
this.kind = kind;
this.id = 0;
this.flags = NodeFlags.None;
this.transformFlags = TransformFlags.None;
this.parent = undefined!;
this.original = undefined;
this.flowNode = undefined;
}
function SourceMapSource(this: SourceMapSource, fileName: string, text: string, skipTrivia?: (pos: number) => number) {
this.fileName = fileName;
this.text = text;
@ -7158,8 +7183,8 @@ namespace ts {
// eslint-disable-next-line prefer-const
export let objectAllocator: ObjectAllocator = {
getNodeConstructor: () => <any>Node,
getTokenConstructor: () => <any>Node,
getIdentifierConstructor: () => <any>Node,
getTokenConstructor: () => <any>Token,
getIdentifierConstructor: () => <any>Identifier,
getSourceFileConstructor: () => <any>Node,
getSymbolConstructor: () => <any>Symbol,
getTypeConstructor: () => <any>Type,