perf: run flow code in flow plugin
This commit is contained in:
parent
a1eac37bd2
commit
c2e41588aa
@ -1935,7 +1935,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
// ensure that inside flow types, we bypass the jsx parser plugin
|
// ensure that inside flow types, we bypass the jsx parser plugin
|
||||||
getTokenFromCode(code: number): void {
|
getTokenFromCode(code: number): void {
|
||||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||||
if (
|
if (code === charCodes.leftCurlyBrace && next === charCodes.verticalBar) {
|
||||||
|
return this.finishOp(tt.braceBarL, 2);
|
||||||
|
} else if (
|
||||||
this.state.inType &&
|
this.state.inType &&
|
||||||
(code === charCodes.greaterThan || code === charCodes.lessThan)
|
(code === charCodes.greaterThan || code === charCodes.lessThan)
|
||||||
) {
|
) {
|
||||||
@ -2701,6 +2703,20 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
super.readToken_mult_modulo(code);
|
super.readToken_mult_modulo(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readToken_pipe_amp(code: number): void {
|
||||||
|
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||||
|
if (
|
||||||
|
code === charCodes.verticalBar &&
|
||||||
|
next === charCodes.rightCurlyBrace
|
||||||
|
) {
|
||||||
|
// '|}'
|
||||||
|
this.finishOp(tt.braceBarR, 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.readToken_pipe_amp(code);
|
||||||
|
}
|
||||||
|
|
||||||
parseTopLevel(file: N.File, program: N.Program): N.File {
|
parseTopLevel(file: N.File, program: N.Program): N.File {
|
||||||
const fileNode = super.parseTopLevel(file, program);
|
const fileNode = super.parseTopLevel(file, program);
|
||||||
if (this.state.hasFlowComment) {
|
if (this.state.hasFlowComment) {
|
||||||
|
|||||||
@ -482,7 +482,7 @@ export default class Tokenizer extends LocationParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readToken_pipe_amp(code: number): void {
|
readToken_pipe_amp(code: number): void {
|
||||||
// '|&'
|
// '||' '&&' '||=' '&&='
|
||||||
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
const next = this.state.input.charCodeAt(this.state.pos + 1);
|
||||||
|
|
||||||
if (next === code) {
|
if (next === code) {
|
||||||
@ -504,10 +504,6 @@ export default class Tokenizer extends LocationParser {
|
|||||||
if (next === charCodes.greaterThan) {
|
if (next === charCodes.greaterThan) {
|
||||||
this.finishOp(tt.pipeline, 2);
|
this.finishOp(tt.pipeline, 2);
|
||||||
return;
|
return;
|
||||||
} else if (next === charCodes.rightCurlyBrace && this.hasPlugin("flow")) {
|
|
||||||
// '|}'
|
|
||||||
this.finishOp(tt.braceBarR, 2);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,20 +684,10 @@ export default class Tokenizer extends LocationParser {
|
|||||||
++this.state.pos;
|
++this.state.pos;
|
||||||
this.finishToken(tt.bracketR);
|
this.finishToken(tt.bracketR);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case charCodes.leftCurlyBrace:
|
case charCodes.leftCurlyBrace:
|
||||||
if (
|
++this.state.pos;
|
||||||
this.hasPlugin("flow") &&
|
this.finishToken(tt.braceL);
|
||||||
this.state.input.charCodeAt(this.state.pos + 1) ===
|
|
||||||
charCodes.verticalBar
|
|
||||||
) {
|
|
||||||
this.finishOp(tt.braceBarL, 2);
|
|
||||||
} else {
|
|
||||||
++this.state.pos;
|
|
||||||
this.finishToken(tt.braceL);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case charCodes.rightCurlyBrace:
|
case charCodes.rightCurlyBrace:
|
||||||
++this.state.pos;
|
++this.state.pos;
|
||||||
this.finishToken(tt.braceR);
|
this.finishToken(tt.braceR);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user