Skip to content

Commit

Permalink
fix(parser): performance improvements
Browse files Browse the repository at this point in the history
@axefrog You mentioned before on the Cherow repo that it maybe should be easy to extend the parser?

Well. I have to admit now after one day in h*** that changing any bit masks in this parser
provides unforeseen side effects resulting in at least 2000 broken edge case tests. And it took me 1 day to track and fix it :( :(  And when I finaly fixed it, well 450  new broken tests :(

Anyway. The base layer is laid for #21 , but the language itself have limitations so I'm not sure how to fix that either.
  • Loading branch information
KFlash committed Jul 17, 2019
1 parent b5512e0 commit 7f2c32f
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 144 deletions.
13 changes: 7 additions & 6 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const enum Context {
SuperCall = 1 << 19,
InYieldContext = 1 << 21,
InAwaitContext = 1 << 22,
InArgList = 1 << 23,
InArgumentList = 1 << 23,
InConstructor = 1 << 24,
InMethod = 1 << 25,
AllowNewTarget = 1 << 26,
Expand Down Expand Up @@ -58,12 +58,13 @@ export const enum PropertyKind {
GetSet = Getter | Setter
}

export const enum BindingType {
export const enum BindingKind {
None = 0,
ArgList = 1 << 0,
ArgumentList = 1 << 0,
EmptyBinding = 1 << 1,
Variable = 1 << 2,
Let = 1 << 3,
Const = 1 << 4
Const = 1 << 4,
}

export const enum BindingOrigin {
Expand Down Expand Up @@ -262,7 +263,7 @@ export function reinterpretToPattern(state: ParserState, node: any): void {
export function validateBindingIdentifier(
parser: ParserState,
context: Context,
type: BindingType,
type: BindingKind,
t: Token,
skipEvalArgCheck: 0 | 1
): void {
Expand Down Expand Up @@ -290,7 +291,7 @@ export function validateBindingIdentifier(
report(parser, Errors.KeywordNotId);
}

if (type & (BindingType.Let | BindingType.Const) && t === Token.LetKeyword) {
if (type & (BindingKind.Let | BindingKind.Const) && t === Token.LetKeyword) {
report(parser, Errors.InvalidLetConstBinding);
}

Expand Down
Loading

0 comments on commit 7f2c32f

Please sign in to comment.