Closed Bug 1539821 Opened 5 years ago Closed 5 years ago

Remove ModifierException

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: jorendorff, Assigned: jorendorff)

References

Details

Attachments

(7 files)

ModifierException is part of an assertion scheme that checks our handling of the division operator and RegExp literals. The idea is that the choice of Modifier is error-prone, and it's good to ensure we're making those decisions consistently, and for good reasons.

Unfortunately the assertion scheme itself is also quite complex. "Now you have two problems."

I think there's an easier way to think about the problem that leads to simpler assertions.

Priority: -- → P2

It turns out to be vestigial. The comment being deleted here says,
"Comma/semicolon cases are also gotten as operators (None)", but this is no
longer true. Both are scanned as Operand now; and so are RightCurly,
RightParen, and the various other tokens listed in yieldExpression(), for which
an exception was once necessary.

Also renames ModifierException::OperandIsNone -> AllowRegExpOK, although it
doesn't matter too much, as its days are numbered.

Depends on D25310

This helps us get rid of several uses of addModifierException, as the next few
patches show. It will also be used to implement ASI for fields. (In most
contexts, the next token after a missing semicolon needs to be scanned in
AllowRegExp mode. In a ClassBody it's different; the next token must be neither
Div nor RegExp in a syntactically valid program.)

Depends on D25818

Attachment #9054346 - Attachment description: Bug 1539821 - Part 3: Relax Modifier assertion around mustMatchToken(). r?jwalden → Bug 1539821 - Part 4: Use Modifier::DoNotWantDivOrRegExp in mustMatchToken(). r?jwalden

propertyName() has three callers, corresponding to ObjectLiteral,
ObjectBindingPattern, and ClassDeclaration. In each case the next token must be
neither Div nor RegExp.

Depends on D25820

Attachment #9054345 - Attachment description: Bug 1539821 - Part 2: Simplify TokenStream modifier exceptions. r?jwalden → Bug 1539821 - Part 7: Remove ModifierException. r?jwalden
Attachment #9055237 - Attachment description: Bug 1539821 - Part 2: Rename TokenStream::Operand -> AllowRegExp and TokenStream::None -> AllowDiv. r?jwalden → Bug 1539821 - Part 2: Rename TokenStream::Operand -> SlashIsRegExp and TokenStream::None -> SlashIsDiv. r?jwalden
Attachment #9055238 - Attachment description: Bug 1539821 - Part 3: Add Modifier::DoNotWantDivOrRegExp. r?jwalden → Bug 1539821 - Part 3: Add Modifier::SlashIsInvalid. r?jwalden
Attachment #9054346 - Attachment description: Bug 1539821 - Part 4: Use Modifier::DoNotWantDivOrRegExp in mustMatchToken(). r?jwalden → Bug 1539821 - Part 4: Use Modifier::SlashIsInvalid in mustMatchToken(). r?jwalden
Attachment #9055239 - Attachment description: Bug 1539821 - Part 5: Remove modifier exceptions rendered unnecessary by using DoNotWant mode in mustMatchToken(). r?jwalden → Bug 1539821 - Part 5: Remove modifier exceptions rendered unnecessary by using SlashIsInvalid mode in mustMatchToken(). r?jwalden
Summary: Simplify ModifierException → Remove ModifierException
Pushed by jorendorff@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7114c39413db
Part 1: Delete ModifierException::NoneIsOperand. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/b595a64f80d7
Part 2: Rename TokenStream::Operand -> SlashIsRegExp and TokenStream::None -> SlashIsDiv. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/7e5d87cbcefe
Part 3: Add Modifier::SlashIsInvalid. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/7abd8fbb2582
Part 4: Use Modifier::SlashIsInvalid in mustMatchToken(). r=jwalden
https://hg.mozilla.org/integration/autoland/rev/a0869df70525
Part 5: Remove modifier exceptions rendered unnecessary by using SlashIsInvalid mode in mustMatchToken(). r=jwalden
https://hg.mozilla.org/integration/autoland/rev/06ad5997d161
Part 6: Remove ModifierExceptions for propertyName(). r=jwalden
https://hg.mozilla.org/integration/autoland/rev/4531b9532bd9
Part 7: Remove ModifierException. r=jwalden
Assignee: nobody → jorendorff
You need to log in before you can comment on or make changes to this bug.