Skip to content

Commit 15546c0

Browse files
committed
refactor(napi/parser, linter/plugins): shorten raw transfer deserializers for Options (#20924)
Refactor. Just shorten the code generated for deserializing `Option`s in raw transfer deserializer.
1 parent 0503a78 commit 15546c0

10 files changed

Lines changed: 630 additions & 620 deletions

File tree

apps/oxlint/src-js/generated/deserialize.js

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -6160,13 +6160,13 @@ function deserializeBoxTSTypeParameterInstantiation(pos) {
61606160
}
61616161

61626162
function deserializeOptionBoxTSTypeParameterInstantiation(pos) {
6163-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6164-
return deserializeBoxTSTypeParameterInstantiation(pos);
6163+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6164+
? null
6165+
: deserializeBoxTSTypeParameterInstantiation(pos);
61656166
}
61666167

61676168
function deserializeOptionStr(pos) {
6168-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6169-
return deserializeStr(pos);
6169+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0 ? null : deserializeStr(pos);
61706170
}
61716171

61726172
function deserializeBoxComputedMemberExpression(pos) {
@@ -6202,8 +6202,7 @@ function deserializeBoxObjectAssignmentTarget(pos) {
62026202
}
62036203

62046204
function deserializeOptionAssignmentTargetMaybeDefault(pos) {
6205-
if (uint8[pos] === 51) return null;
6206-
return deserializeAssignmentTargetMaybeDefault(pos);
6205+
return uint8[pos] === 51 ? null : deserializeAssignmentTargetMaybeDefault(pos);
62076206
}
62086207

62096208
function deserializeVecOptionAssignmentTargetMaybeDefault(pos) {
@@ -6223,8 +6222,9 @@ function deserializeBoxAssignmentTargetRest(pos) {
62236222
}
62246223

62256224
function deserializeOptionBoxAssignmentTargetRest(pos) {
6226-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6227-
return deserializeBoxAssignmentTargetRest(pos);
6225+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6226+
? null
6227+
: deserializeBoxAssignmentTargetRest(pos);
62286228
}
62296229

62306230
function deserializeVecAssignmentTargetProperty(pos) {
@@ -6252,8 +6252,7 @@ function deserializeBoxAssignmentTargetPropertyProperty(pos) {
62526252
}
62536253

62546254
function deserializeOptionExpression(pos) {
6255-
if (uint8[pos] === 51) return null;
6256-
return deserializeExpression(pos);
6255+
return uint8[pos] === 51 ? null : deserializeExpression(pos);
62576256
}
62586257

62596258
function deserializeBoxBlockStatement(pos) {
@@ -6373,23 +6372,23 @@ function deserializeBoxTSTypeAnnotation(pos) {
63736372
}
63746373

63756374
function deserializeOptionBoxTSTypeAnnotation(pos) {
6376-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6377-
return deserializeBoxTSTypeAnnotation(pos);
6375+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6376+
? null
6377+
: deserializeBoxTSTypeAnnotation(pos);
63786378
}
63796379

63806380
function deserializeOptionStatement(pos) {
6381-
if (uint8[pos] === 70) return null;
6382-
return deserializeStatement(pos);
6381+
return uint8[pos] === 70 ? null : deserializeStatement(pos);
63836382
}
63846383

63856384
function deserializeOptionForStatementInit(pos) {
6386-
if (uint8[pos] === 65) return null;
6387-
return deserializeForStatementInit(pos);
6385+
return uint8[pos] === 65 ? null : deserializeForStatementInit(pos);
63886386
}
63896387

63906388
function deserializeOptionLabelIdentifier(pos) {
6391-
if (uint32[(pos + 16) >> 2] === 0 && uint32[(pos + 20) >> 2] === 0) return null;
6392-
return deserializeLabelIdentifier(pos);
6389+
return uint32[(pos + 16) >> 2] === 0 && uint32[(pos + 20) >> 2] === 0
6390+
? null
6391+
: deserializeLabelIdentifier(pos);
63936392
}
63946393

63956394
function deserializeVecSwitchCase(pos) {
@@ -6409,18 +6408,19 @@ function deserializeBoxCatchClause(pos) {
64096408
}
64106409

64116410
function deserializeOptionBoxCatchClause(pos) {
6412-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6413-
return deserializeBoxCatchClause(pos);
6411+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6412+
? null
6413+
: deserializeBoxCatchClause(pos);
64146414
}
64156415

64166416
function deserializeOptionBoxBlockStatement(pos) {
6417-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6418-
return deserializeBoxBlockStatement(pos);
6417+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6418+
? null
6419+
: deserializeBoxBlockStatement(pos);
64196420
}
64206421

64216422
function deserializeOptionCatchParameter(pos) {
6422-
if (uint8[pos + 16] === 4) return null;
6423-
return deserializeCatchParameter(pos);
6423+
return uint8[pos + 16] === 4 ? null : deserializeCatchParameter(pos);
64246424
}
64256425

64266426
function deserializeBoxBindingIdentifier(pos) {
@@ -6456,13 +6456,13 @@ function deserializeBoxBindingRestElement(pos) {
64566456
}
64576457

64586458
function deserializeOptionBoxBindingRestElement(pos) {
6459-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6460-
return deserializeBoxBindingRestElement(pos);
6459+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6460+
? null
6461+
: deserializeBoxBindingRestElement(pos);
64616462
}
64626463

64636464
function deserializeOptionBindingPattern(pos) {
6464-
if (uint8[pos] === 4) return null;
6465-
return deserializeBindingPattern(pos);
6465+
return uint8[pos] === 4 ? null : deserializeBindingPattern(pos);
64666466
}
64676467

64686468
function deserializeVecOptionBindingPattern(pos) {
@@ -6478,26 +6478,29 @@ function deserializeVecOptionBindingPattern(pos) {
64786478
}
64796479

64806480
function deserializeOptionBindingIdentifier(pos) {
6481-
if (uint32[(pos + 16) >> 2] === 0 && uint32[(pos + 20) >> 2] === 0) return null;
6482-
return deserializeBindingIdentifier(pos);
6481+
return uint32[(pos + 16) >> 2] === 0 && uint32[(pos + 20) >> 2] === 0
6482+
? null
6483+
: deserializeBindingIdentifier(pos);
64836484
}
64846485

64856486
function deserializeBoxTSTypeParameterDeclaration(pos) {
64866487
return deserializeTSTypeParameterDeclaration(uint32[pos >> 2]);
64876488
}
64886489

64896490
function deserializeOptionBoxTSTypeParameterDeclaration(pos) {
6490-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6491-
return deserializeBoxTSTypeParameterDeclaration(pos);
6491+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6492+
? null
6493+
: deserializeBoxTSTypeParameterDeclaration(pos);
64926494
}
64936495

64946496
function deserializeBoxTSThisParameter(pos) {
64956497
return deserializeTSThisParameter(uint32[pos >> 2]);
64966498
}
64976499

64986500
function deserializeOptionBoxTSThisParameter(pos) {
6499-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6500-
return deserializeBoxTSThisParameter(pos);
6501+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6502+
? null
6503+
: deserializeBoxTSThisParameter(pos);
65016504
}
65026505

65036506
function deserializeBoxFormalParameters(pos) {
@@ -6509,8 +6512,9 @@ function deserializeBoxFunctionBody(pos) {
65096512
}
65106513

65116514
function deserializeOptionBoxFunctionBody(pos) {
6512-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6513-
return deserializeBoxFunctionBody(pos);
6515+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6516+
? null
6517+
: deserializeBoxFunctionBody(pos);
65146518
}
65156519

65166520
function deserializeVecFormalParameter(pos) {
@@ -6542,13 +6546,13 @@ function deserializeBoxExpression(pos) {
65426546
}
65436547

65446548
function deserializeOptionBoxExpression(pos) {
6545-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6546-
return deserializeBoxExpression(pos);
6549+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6550+
? null
6551+
: deserializeBoxExpression(pos);
65476552
}
65486553

65496554
function deserializeOptionTSAccessibility(pos) {
6550-
if (uint8[pos] === 3) return null;
6551-
return deserializeTSAccessibility(pos);
6555+
return uint8[pos] === 3 ? null : deserializeTSAccessibility(pos);
65526556
}
65536557

65546558
function deserializeVecTSClassImplements(pos) {
@@ -6624,8 +6628,7 @@ function deserializeBoxTSNamespaceExportDeclaration(pos) {
66246628
}
66256629

66266630
function deserializeOptionImportPhase(pos) {
6627-
if (uint8[pos] === 2) return null;
6628-
return deserializeImportPhase(pos);
6631+
return uint8[pos] === 2 ? null : deserializeImportPhase(pos);
66296632
}
66306633

66316634
function deserializeVecImportDeclarationSpecifier(pos) {
@@ -6641,17 +6644,19 @@ function deserializeVecImportDeclarationSpecifier(pos) {
66416644
}
66426645

66436646
function deserializeOptionVecImportDeclarationSpecifier(pos) {
6644-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6645-
return deserializeVecImportDeclarationSpecifier(pos);
6647+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6648+
? null
6649+
: deserializeVecImportDeclarationSpecifier(pos);
66466650
}
66476651

66486652
function deserializeBoxWithClause(pos) {
66496653
return deserializeWithClause(uint32[pos >> 2]);
66506654
}
66516655

66526656
function deserializeOptionBoxWithClause(pos) {
6653-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6654-
return deserializeBoxWithClause(pos);
6657+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6658+
? null
6659+
: deserializeBoxWithClause(pos);
66556660
}
66566661

66576662
function deserializeBoxImportSpecifier(pos) {
@@ -6679,8 +6684,7 @@ function deserializeVecImportAttribute(pos) {
66796684
}
66806685

66816686
function deserializeOptionDeclaration(pos) {
6682-
if (uint8[pos] === 31) return null;
6683-
return deserializeDeclaration(pos);
6687+
return uint8[pos] === 31 ? null : deserializeDeclaration(pos);
66846688
}
66856689

66866690
function deserializeVecExportSpecifier(pos) {
@@ -6696,13 +6700,11 @@ function deserializeVecExportSpecifier(pos) {
66966700
}
66976701

66986702
function deserializeOptionStringLiteral(pos) {
6699-
if (uint8[pos + 12] === 2) return null;
6700-
return deserializeStringLiteral(pos);
6703+
return uint8[pos + 12] === 2 ? null : deserializeStringLiteral(pos);
67016704
}
67026705

67036706
function deserializeOptionModuleExportName(pos) {
6704-
if (uint8[pos] === 3) return null;
6705-
return deserializeModuleExportName(pos);
6707+
return uint8[pos] === 3 ? null : deserializeModuleExportName(pos);
67066708
}
67076709

67086710
function deserializeF64(pos) {
@@ -6734,8 +6736,9 @@ function deserializeBoxJSXClosingElement(pos) {
67346736
}
67356737

67366738
function deserializeOptionBoxJSXClosingElement(pos) {
6737-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
6738-
return deserializeBoxJSXClosingElement(pos);
6739+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
6740+
? null
6741+
: deserializeBoxJSXClosingElement(pos);
67396742
}
67406743

67416744
function deserializeVecJSXAttributeItem(pos) {
@@ -6771,8 +6774,7 @@ function deserializeBoxJSXSpreadAttribute(pos) {
67716774
}
67726775

67736776
function deserializeOptionJSXAttributeValue(pos) {
6774-
if (uint8[pos] === 4) return null;
6775-
return deserializeJSXAttributeValue(pos);
6777+
return uint8[pos] === 4 ? null : deserializeJSXAttributeValue(pos);
67766778
}
67776779

67786780
function deserializeBoxJSXExpressionContainer(pos) {
@@ -6984,8 +6986,7 @@ function deserializeBoxTSQualifiedName(pos) {
69846986
}
69856987

69866988
function deserializeOptionTSType(pos) {
6987-
if (uint8[pos] === 38) return null;
6988-
return deserializeTSType(pos);
6989+
return uint8[pos] === 38 ? null : deserializeTSType(pos);
69896990
}
69906991

69916992
function deserializeVecTSTypeParameter(pos) {
@@ -7057,8 +7058,7 @@ function deserializeVecTSIndexSignatureName(pos) {
70577058
}
70587059

70597060
function deserializeOptionTSModuleDeclarationBody(pos) {
7060-
if (uint8[pos] === 2) return null;
7061-
return deserializeTSModuleDeclarationBody(pos);
7061+
return uint8[pos] === 2 ? null : deserializeTSModuleDeclarationBody(pos);
70627062
}
70637063

70647064
function deserializeBoxTSModuleBlock(pos) {
@@ -7070,22 +7070,21 @@ function deserializeBoxTSTypeParameter(pos) {
70707070
}
70717071

70727072
function deserializeOptionBoxObjectExpression(pos) {
7073-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
7074-
return deserializeBoxObjectExpression(pos);
7073+
return uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0
7074+
? null
7075+
: deserializeBoxObjectExpression(pos);
70757076
}
70767077

70777078
function deserializeOptionTSImportTypeQualifier(pos) {
7078-
if (uint8[pos] === 2) return null;
7079-
return deserializeTSImportTypeQualifier(pos);
7079+
return uint8[pos] === 2 ? null : deserializeTSImportTypeQualifier(pos);
70807080
}
70817081

70827082
function deserializeBoxTSImportTypeQualifiedName(pos) {
70837083
return deserializeTSImportTypeQualifiedName(uint32[pos >> 2]);
70847084
}
70857085

70867086
function deserializeOptionTSMappedTypeModifierOperator(pos) {
7087-
if (uint8[pos] === 3) return null;
7088-
return deserializeTSMappedTypeModifierOperator(pos);
7087+
return uint8[pos] === 3 ? null : deserializeTSMappedTypeModifierOperator(pos);
70897088
}
70907089

70917090
function deserializeBoxTSExternalModuleReference(pos) {

0 commit comments

Comments
 (0)