⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244038 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 1:43:18 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

Unreviewed, rolling in r243948 with test fix
https://bugs.webkit.org/show_bug.cgi?id=196486

JSTests:

  • stress/arrow-function-and-use-strict-directive.js: Added.
  • stress/arrow-function-syntax.js: Added.

(checkSyntax):
(checkSyntaxError):

Source/JavaScriptCore:

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createString):

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseMultilineComment):
(JSC::Lexer<T>::lexWithoutClearingLineTerminator):
(JSC::Lexer<T>::lex): Deleted.

  • parser/Lexer.h:

(JSC::Lexer::hasLineTerminatorBeforeToken const):
(JSC::Lexer::setHasLineTerminatorBeforeToken):
(JSC::Lexer<T>::lex):
(JSC::Lexer::prevTerminator const): Deleted.
(JSC::Lexer::setTerminator): Deleted.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::allowAutomaticSemicolon):
(JSC::Parser<LexerType>::parseSingleFunction):
(JSC::Parser<LexerType>::parseStatementListItem):
(JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseYieldExpression):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/Parser.h:

(JSC::Parser::nextWithoutClearingLineTerminator):
(JSC::Parser::lexCurrentTokenAgainUnderCurrentContext):
(JSC::Parser::internalSaveLexerState):
(JSC::Parser::restoreLexerState):

LayoutTests:

The test relied on the wrong EOF token's offset. This patch also fixes the test.

  • inspector/runtime/parse-expected.txt:
  • inspector/runtime/parse.html:
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r244028 r244038  
     12019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Unreviewed, rolling in r243948 with test fix
     4        https://bugs.webkit.org/show_bug.cgi?id=196486
     5
     6        * stress/arrow-function-and-use-strict-directive.js: Added.
     7        * stress/arrow-function-syntax.js: Added.
     8        (checkSyntax):
     9        (checkSyntaxError):
     10
    1112019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/LayoutTests/ChangeLog

    r244037 r244038  
     12019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Unreviewed, rolling in r243948 with test fix
     4        https://bugs.webkit.org/show_bug.cgi?id=196486
     5
     6        The test relied on the wrong EOF token's offset. This patch also fixes the test.
     7
     8        * inspector/runtime/parse-expected.txt:
     9        * inspector/runtime/parse.html:
     10
    1112019-04-08  Antti Koivisto  <antti@apple.com>
    212
  • trunk/LayoutTests/inspector/runtime/parse-expected.txt

    r211319 r244038  
    7676PASS: Should be SyntaxErrorType Recoverable.
    7777Source: (
    78         ^
    79 Error Message: Unexpected end of script
    80 Error Range: {"startOffset":0,"endOffset":1}
     78         ^
     79Error Message: Unexpected end of script
     80Error Range: {"startOffset":1,"endOffset":1}
    8181
    8282PASS: Should be SyntaxErrorType Recoverable.
    8383Source: {
    84         ^
    85 Error Message: Unexpected end of script
    86 Error Range: {"startOffset":0,"endOffset":1}
     84         ^
     85Error Message: Unexpected end of script
     86Error Range: {"startOffset":1,"endOffset":1}
    8787
    8888PASS: Should be SyntaxErrorType Recoverable.
    8989Source: !
    90         ^
    91 Error Message: Unexpected end of script
    92 Error Range: {"startOffset":0,"endOffset":1}
     90         ^
     91Error Message: Unexpected end of script
     92Error Range: {"startOffset":1,"endOffset":1}
    9393
    9494PASS: Should be SyntaxErrorType Recoverable.
    9595Source: -
    96         ^
    97 Error Message: Unexpected end of script
    98 Error Range: {"startOffset":0,"endOffset":1}
     96         ^
     97Error Message: Unexpected end of script
     98Error Range: {"startOffset":1,"endOffset":1}
    9999
    100100PASS: Should be SyntaxErrorType Recoverable.
    101101Source: +
    102         ^
    103 Error Message: Unexpected end of script
    104 Error Range: {"startOffset":0,"endOffset":1}
     102         ^
     103Error Message: Unexpected end of script
     104Error Range: {"startOffset":1,"endOffset":1}
    105105
    106106PASS: Should be SyntaxErrorType Recoverable.
    107107Source: ~
    108         ^
    109 Error Message: Unexpected end of script
    110 Error Range: {"startOffset":0,"endOffset":1}
     108         ^
     109Error Message: Unexpected end of script
     110Error Range: {"startOffset":1,"endOffset":1}
    111111
    112112PASS: Should be SyntaxErrorType Recoverable.
    113113Source: 1,
    114          ^
    115 Error Message: Unexpected end of script
    116 Error Range: {"startOffset":1,"endOffset":2}
     114          ^
     115Error Message: Unexpected end of script
     116Error Range: {"startOffset":2,"endOffset":2}
    117117
    118118PASS: Should be SyntaxErrorType Recoverable.
    119119Source: var
    120         ^~~
    121 Error Message: Unexpected end of script
    122 Error Range: {"startOffset":0,"endOffset":3}
     120           ^
     121Error Message: Unexpected end of script
     122Error Range: {"startOffset":3,"endOffset":3}
    123123
    124124PASS: Should be SyntaxErrorType Recoverable.
    125125Source: 'use strict'; let
    126                       ^~~
    127 Error Message: Unexpected end of script
    128 Error Range: {"startOffset":14,"endOffset":17}
     126                         ^
     127Error Message: Unexpected end of script
     128Error Range: {"startOffset":17,"endOffset":17}
    129129
    130130PASS: Should be SyntaxErrorType Recoverable.
    131131Source: const
    132         ^~~~~
    133 Error Message: Unexpected end of script
    134 Error Range: {"startOffset":0,"endOffset":5}
     132             ^
     133Error Message: Unexpected end of script
     134Error Range: {"startOffset":5,"endOffset":5}
    135135
    136136PASS: Should be SyntaxErrorType Recoverable.
    137137Source: var {x
     138              ^
     139Error Message: Unexpected end of script
     140Error Range: {"startOffset":6,"endOffset":6}
     141
     142PASS: Should be SyntaxErrorType Recoverable.
     143Source: var [x
     144              ^
     145Error Message: Unexpected end of script
     146Error Range: {"startOffset":6,"endOffset":6}
     147
     148PASS: Should be SyntaxErrorType Recoverable.
     149Source: var x,
     150              ^
     151Error Message: Unexpected end of script
     152Error Range: {"startOffset":6,"endOffset":6}
     153
     154PASS: Should be SyntaxErrorType Recoverable.
     155Source: if(1)
    138156             ^
    139157Error Message: Unexpected end of script
    140 Error Range: {"startOffset":5,"endOffset":6}
    141 
    142 PASS: Should be SyntaxErrorType Recoverable.
    143 Source: var [x
     158Error Range: {"startOffset":5,"endOffset":5}
     159
     160PASS: Should be SyntaxErrorType Recoverable.
     161Source: if(1){
     162              ^
     163Error Message: Unexpected end of script
     164Error Range: {"startOffset":6,"endOffset":6}
     165
     166PASS: Should be SyntaxErrorType Recoverable.
     167Source: if(1){}else
     168                   ^
     169Error Message: Unexpected end of script
     170Error Range: {"startOffset":11,"endOffset":11}
     171
     172PASS: Should be SyntaxErrorType Recoverable.
     173Source: if(1){}else{
     174                    ^
     175Error Message: Unexpected end of script
     176Error Range: {"startOffset":12,"endOffset":12}
     177
     178PASS: Should be SyntaxErrorType Recoverable.
     179Source: while(1)
     180                ^
     181Error Message: Unexpected end of script
     182Error Range: {"startOffset":8,"endOffset":8}
     183
     184PASS: Should be SyntaxErrorType Recoverable.
     185Source: while(1){
     186                 ^
     187Error Message: Unexpected end of script
     188Error Range: {"startOffset":9,"endOffset":9}
     189
     190PASS: Should be SyntaxErrorType Recoverable.
     191Source: for(;;)
     192               ^
     193Error Message: Unexpected end of script
     194Error Range: {"startOffset":7,"endOffset":7}
     195
     196PASS: Should be SyntaxErrorType Recoverable.
     197Source: for(;;){
     198                ^
     199Error Message: Unexpected end of script
     200Error Range: {"startOffset":8,"endOffset":8}
     201
     202PASS: Should be SyntaxErrorType Recoverable.
     203Source: ()=>
     204            ^
     205Error Message: Unexpected end of script
     206Error Range: {"startOffset":4,"endOffset":4}
     207
     208PASS: Should be SyntaxErrorType Recoverable.
     209Source: ()=>{
    144210             ^
    145211Error Message: Unexpected end of script
    146 Error Range: {"startOffset":5,"endOffset":6}
    147 
    148 PASS: Should be SyntaxErrorType Recoverable.
    149 Source: var x,
    150              ^
    151 Error Message: Unexpected end of script
    152 Error Range: {"startOffset":5,"endOffset":6}
    153 
    154 PASS: Should be SyntaxErrorType Recoverable.
    155 Source: if(1)
    156             ^
    157 Error Message: Unexpected end of script
    158 Error Range: {"startOffset":4,"endOffset":5}
    159 
    160 PASS: Should be SyntaxErrorType Recoverable.
    161 Source: if(1){
    162              ^
    163 Error Message: Unexpected end of script
    164 Error Range: {"startOffset":5,"endOffset":6}
    165 
    166 PASS: Should be SyntaxErrorType Recoverable.
    167 Source: if(1){}else
    168                ^~~~
    169 Error Message: Unexpected end of script
    170 Error Range: {"startOffset":7,"endOffset":11}
    171 
    172 PASS: Should be SyntaxErrorType Recoverable.
    173 Source: if(1){}else{
    174                    ^
    175 Error Message: Unexpected end of script
    176 Error Range: {"startOffset":11,"endOffset":12}
    177 
    178 PASS: Should be SyntaxErrorType Recoverable.
    179 Source: while(1)
    180                ^
    181 Error Message: Unexpected end of script
    182 Error Range: {"startOffset":7,"endOffset":8}
    183 
    184 PASS: Should be SyntaxErrorType Recoverable.
    185 Source: while(1){
    186                 ^
    187 Error Message: Unexpected end of script
    188 Error Range: {"startOffset":8,"endOffset":9}
    189 
    190 PASS: Should be SyntaxErrorType Recoverable.
    191 Source: for(;;)
    192               ^
    193 Error Message: Unexpected end of script
    194 Error Range: {"startOffset":6,"endOffset":7}
    195 
    196 PASS: Should be SyntaxErrorType Recoverable.
    197 Source: for(;;){
    198                ^
    199 Error Message: Unexpected end of script
    200 Error Range: {"startOffset":7,"endOffset":8}
    201 
    202 PASS: Should be SyntaxErrorType Recoverable.
    203 Source: ()=>
    204           ^~
    205 Error Message: Unexpected end of script
    206 Error Range: {"startOffset":2,"endOffset":4}
    207 
    208 PASS: Should be SyntaxErrorType Recoverable.
    209 Source: ()=>{
    210             ^
    211 Error Message: Unexpected end of script
    212 Error Range: {"startOffset":4,"endOffset":5}
     212Error Range: {"startOffset":5,"endOffset":5}
    213213
    214214PASS: Should be SyntaxErrorType Recoverable.
     
    232232PASS: Should be SyntaxErrorType Recoverable.
    233233Source: `${
    234         ^~~
    235 Error Message: Unexpected end of script
    236 Error Range: {"startOffset":0,"endOffset":3}
     234           ^
     235Error Message: Unexpected end of script
     236Error Range: {"startOffset":3,"endOffset":3}
    237237
    238238PASS: Should be SyntaxErrorType Recoverable.
    239239Source: function
    240         ^~~~~~~~
    241 Error Message: Unexpected end of script
    242 Error Range: {"startOffset":0,"endOffset":8}
     240                ^
     241Error Message: Unexpected end of script
     242Error Range: {"startOffset":8,"endOffset":8}
    243243
    244244PASS: Should be SyntaxErrorType Recoverable.
    245245Source: function foo
    246                  ^~~
    247 Error Message: Unexpected end of script
    248 Error Range: {"startOffset":9,"endOffset":12}
     246                    ^
     247Error Message: Unexpected end of script
     248Error Range: {"startOffset":12,"endOffset":12}
    249249
    250250PASS: Should be SyntaxErrorType Recoverable.
    251251Source: function foo(
    252                     ^
    253 Error Message: Unexpected end of script
    254 Error Range: {"startOffset":12,"endOffset":13}
     252                     ^
     253Error Message: Unexpected end of script
     254Error Range: {"startOffset":13,"endOffset":13}
    255255
    256256PASS: Should be SyntaxErrorType Recoverable.
    257257Source: function foo(){
     258                       ^
     259Error Message: Unexpected end of script
     260Error Range: {"startOffset":15,"endOffset":15}
     261
     262PASS: Should be SyntaxErrorType Recoverable.
     263Source: (function() {
     264                     ^
     265Error Message: Unexpected end of script
     266Error Range: {"startOffset":13,"endOffset":13}
     267
     268PASS: Should be SyntaxErrorType Recoverable.
     269Source: (function() {}
    258270                      ^
    259271Error Message: Unexpected end of script
    260 Error Range: {"startOffset":14,"endOffset":15}
    261 
    262 PASS: Should be SyntaxErrorType Recoverable.
    263 Source: (function() {
    264                     ^
    265 Error Message: Unexpected end of script
    266 Error Range: {"startOffset":12,"endOffset":13}
    267 
    268 PASS: Should be SyntaxErrorType Recoverable.
    269 Source: (function() {}
    270                      ^
    271 Error Message: Unexpected end of script
    272 Error Range: {"startOffset":13,"endOffset":14}
     272Error Range: {"startOffset":14,"endOffset":14}
    273273
    274274PASS: Should be SyntaxErrorType Recoverable.
    275275Source: (function() {})(
    276                        ^
    277 Error Message: Unexpected end of script
    278 Error Range: {"startOffset":15,"endOffset":16}
     276                        ^
     277Error Message: Unexpected end of script
     278Error Range: {"startOffset":16,"endOffset":16}
    279279
    280280PASS: Should be SyntaxErrorType Recoverable.
    281281Source: switch(x)
    282                 ^
    283 Error Message: Unexpected end of script
    284 Error Range: {"startOffset":8,"endOffset":9}
     282                 ^
     283Error Message: Unexpected end of script
     284Error Range: {"startOffset":9,"endOffset":9}
    285285
    286286PASS: Should be SyntaxErrorType Recoverable.
    287287Source: switch(x){
     288                  ^
     289Error Message: Unexpected end of script
     290Error Range: {"startOffset":10,"endOffset":10}
     291
     292PASS: Should be SyntaxErrorType Recoverable.
     293Source: switch(x){case
     294                      ^
     295Error Message: Unexpected end of script
     296Error Range: {"startOffset":14,"endOffset":14}
     297
     298PASS: Should be SyntaxErrorType Recoverable.
     299Source: switch(x){case 1
     300                        ^
     301Error Message: Unexpected end of script
     302Error Range: {"startOffset":16,"endOffset":16}
     303
     304PASS: Should be SyntaxErrorType Recoverable.
     305Source: switch(x){case 1:
     306                         ^
     307Error Message: Unexpected end of script
     308Error Range: {"startOffset":17,"endOffset":17}
     309
     310PASS: Should be SyntaxErrorType Recoverable.
     311Source: class
     312             ^
     313Error Message: Unexpected end of script
     314Error Range: {"startOffset":5,"endOffset":5}
     315
     316PASS: Should be SyntaxErrorType Recoverable.
     317Source: class Klass
     318                   ^
     319Error Message: Unexpected end of script
     320Error Range: {"startOffset":11,"endOffset":11}
     321
     322PASS: Should be SyntaxErrorType Recoverable.
     323Source: class Klass {
     324                     ^
     325Error Message: Unexpected end of script
     326Error Range: {"startOffset":13,"endOffset":13}
     327
     328PASS: Should be SyntaxErrorType Recoverable.
     329Source: var x = {
    288330                 ^
    289331Error Message: Unexpected end of script
    290 Error Range: {"startOffset":9,"endOffset":10}
    291 
    292 PASS: Should be SyntaxErrorType Recoverable.
    293 Source: switch(x){case
    294                   ^~~~
    295 Error Message: Unexpected end of script
    296 Error Range: {"startOffset":10,"endOffset":14}
    297 
    298 PASS: Should be SyntaxErrorType Recoverable.
    299 Source: switch(x){case 1
    300                        ^
    301 Error Message: Unexpected end of script
    302 Error Range: {"startOffset":15,"endOffset":16}
    303 
    304 PASS: Should be SyntaxErrorType Recoverable.
    305 Source: switch(x){case 1:
    306                         ^
    307 Error Message: Unexpected end of script
    308 Error Range: {"startOffset":16,"endOffset":17}
    309 
    310 PASS: Should be SyntaxErrorType Recoverable.
    311 Source: class
    312         ^~~~~
    313 Error Message: Unexpected end of script
    314 Error Range: {"startOffset":0,"endOffset":5}
    315 
    316 PASS: Should be SyntaxErrorType Recoverable.
    317 Source: class Klass
    318               ^~~~~
    319 Error Message: Unexpected end of script
    320 Error Range: {"startOffset":6,"endOffset":11}
    321 
    322 PASS: Should be SyntaxErrorType Recoverable.
    323 Source: class Klass {
    324                     ^
    325 Error Message: Unexpected end of script
    326 Error Range: {"startOffset":12,"endOffset":13}
    327 
    328 PASS: Should be SyntaxErrorType Recoverable.
    329 Source: var x = {
    330                 ^
    331 Error Message: Unexpected end of script
    332 Error Range: {"startOffset":8,"endOffset":9}
     332Error Range: {"startOffset":9,"endOffset":9}
    333333
    334334PASS: Should be SyntaxErrorType Recoverable.
    335335Source: var x = {prop
    336                  ^~~~
    337 Error Message: Unexpected end of script
    338 Error Range: {"startOffset":9,"endOffset":13}
     336                     ^
     337Error Message: Unexpected end of script
     338Error Range: {"startOffset":13,"endOffset":13}
    339339
    340340PASS: Should be SyntaxErrorType Recoverable.
    341341Source: var x = {prop:
    342                      ^
    343 Error Message: Unexpected end of script
    344 Error Range: {"startOffset":13,"endOffset":14}
     342                      ^
     343Error Message: Unexpected end of script
     344Error Range: {"startOffset":14,"endOffset":14}
    345345
    346346PASS: Should be SyntaxErrorType Recoverable.
    347347Source: var x = {prop:123
    348                       ^~~
    349 Error Message: Unexpected end of script
    350 Error Range: {"startOffset":14,"endOffset":17}
     348                         ^
     349Error Message: Unexpected end of script
     350Error Range: {"startOffset":17,"endOffset":17}
    351351
    352352PASS: Should be SyntaxErrorType Recoverable.
    353353Source: var x = {prop:123
    354                       ^~~
    355 Error Message: Unexpected end of script
    356 Error Range: {"startOffset":14,"endOffset":17}
     354                          ^
     355Error Message: Unexpected end of script
     356Error Range: {"startOffset":18,"endOffset":18}
    357357
    358358PASS: Should be SyntaxErrorType Recoverable.
    359359Source: var x = {prop:123,
    360                          ^
    361 Error Message: Unexpected end of script
    362 Error Range: {"startOffset":17,"endOffset":18}
     360                          ^
     361Error Message: Unexpected end of script
     362Error Range: {"startOffset":18,"endOffset":18}
    363363
    364364PASS: Should be SyntaxErrorType Recoverable.
    365365Source: var x = {prop:123,
    366                          ^
    367 Error Message: Unexpected end of script
    368 Error Range: {"startOffset":17,"endOffset":18}
     366                           ^
     367Error Message: Unexpected end of script
     368Error Range: {"startOffset":19,"endOffset":19}
    369369
    370370PASS: Should be SyntaxErrorType Recoverable.
    371371Source: var x = {prop:123, 'prop2'
    372                            ^~~~~~~
    373 Error Message: Unexpected end of script
    374 Error Range: {"startOffset":19,"endOffset":26}
     372                                  ^
     373Error Message: Unexpected end of script
     374Error Range: {"startOffset":26,"endOffset":26}
    375375
    376376PASS: Should be SyntaxErrorType Recoverable.
    377377Source: var x = {prop:123, [12
    378                             ^~
    379 Error Message: Unexpected end of script
    380 Error Range: {"startOffset":20,"endOffset":22}
     378                              ^
     379Error Message: Unexpected end of script
     380Error Range: {"startOffset":22,"endOffset":22}
    381381
    382382PASS: Should be SyntaxErrorType Recoverable.
    383383Source: var x = {prop:123, [12]
    384                               ^
    385 Error Message: Unexpected end of script
    386 Error Range: {"startOffset":22,"endOffset":23}
     384                               ^
     385Error Message: Unexpected end of script
     386Error Range: {"startOffset":23,"endOffset":23}
    387387
    388388PASS: Should be SyntaxErrorType Recoverable.
    389389Source: var x = {prop:123, [12]:
    390                                ^
    391 Error Message: Unexpected end of script
    392 Error Range: {"startOffset":23,"endOffset":24}
     390                                ^
     391Error Message: Unexpected end of script
     392Error Range: {"startOffset":24,"endOffset":24}
    393393
    394394PASS: Should be SyntaxErrorType Recoverable.
    395395Source: var x = {prop:123, [12]:567
    396                                 ^~~
    397 Error Message: Unexpected end of script
    398 Error Range: {"startOffset":24,"endOffset":27}
     396                                   ^
     397Error Message: Unexpected end of script
     398Error Range: {"startOffset":27,"endOffset":27}
    399399
    400400PASS: Should be SyntaxErrorType Recoverable.
    401401Source: var x = [
    402                 ^
    403 Error Message: Unexpected end of script
    404 Error Range: {"startOffset":8,"endOffset":9}
     402                 ^
     403Error Message: Unexpected end of script
     404Error Range: {"startOffset":9,"endOffset":9}
    405405
    406406PASS: Should be SyntaxErrorType Recoverable.
    407407Source: var x = [1
    408                  ^
    409 Error Message: Unexpected end of script
    410 Error Range: {"startOffset":9,"endOffset":10}
     408                  ^
     409Error Message: Unexpected end of script
     410Error Range: {"startOffset":10,"endOffset":10}
    411411
    412412PASS: Should be SyntaxErrorType Recoverable.
    413413Source: var x = [1,
    414                   ^
    415 Error Message: Unexpected end of script
    416 Error Range: {"startOffset":10,"endOffset":11}
     414                   ^
     415Error Message: Unexpected end of script
     416Error Range: {"startOffset":11,"endOffset":11}
    417417
    418418PASS: Should be SyntaxErrorType Recoverable.
    419419Source: var x = [1,[]
    420                     ^
    421 Error Message: Unexpected end of script
    422 Error Range: {"startOffset":12,"endOffset":13}
     420                     ^
     421Error Message: Unexpected end of script
     422Error Range: {"startOffset":13,"endOffset":13}
    423423
    424424PASS: Should be SyntaxErrorType Recoverable.
    425425Source: var x = [1,{}
    426                     ^
    427 Error Message: Unexpected end of script
    428 Error Range: {"startOffset":12,"endOffset":13}
     426                     ^
     427Error Message: Unexpected end of script
     428Error Range: {"startOffset":13,"endOffset":13}
    429429
    430430
  • trunk/LayoutTests/inspector/runtime/parse.html

    r210062 r244038  
    1010        str += " ".repeat(range.startOffset);
    1111        str += "^";
    12         str += "~".repeat(range.endOffset - range.startOffset - 1);
     12        str += "~".repeat(Math.max(range.endOffset - range.startOffset - 1, 0));
    1313        InspectorTest.log(str);
    1414    }
  • trunk/Source/JavaScriptCore/ChangeLog

    r244028 r244038  
     12019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Unreviewed, rolling in r243948 with test fix
     4        https://bugs.webkit.org/show_bug.cgi?id=196486
     5
     6        * parser/ASTBuilder.h:
     7        (JSC::ASTBuilder::createString):
     8        * parser/Lexer.cpp:
     9        (JSC::Lexer<T>::parseMultilineComment):
     10        (JSC::Lexer<T>::lexWithoutClearingLineTerminator):
     11        (JSC::Lexer<T>::lex): Deleted.
     12        * parser/Lexer.h:
     13        (JSC::Lexer::hasLineTerminatorBeforeToken const):
     14        (JSC::Lexer::setHasLineTerminatorBeforeToken):
     15        (JSC::Lexer<T>::lex):
     16        (JSC::Lexer::prevTerminator const): Deleted.
     17        (JSC::Lexer::setTerminator): Deleted.
     18        * parser/Parser.cpp:
     19        (JSC::Parser<LexerType>::allowAutomaticSemicolon):
     20        (JSC::Parser<LexerType>::parseSingleFunction):
     21        (JSC::Parser<LexerType>::parseStatementListItem):
     22        (JSC::Parser<LexerType>::maybeParseAsyncFunctionDeclarationStatement):
     23        (JSC::Parser<LexerType>::parseFunctionInfo):
     24        (JSC::Parser<LexerType>::parseClass):
     25        (JSC::Parser<LexerType>::parseExportDeclaration):
     26        (JSC::Parser<LexerType>::parseAssignmentExpression):
     27        (JSC::Parser<LexerType>::parseYieldExpression):
     28        (JSC::Parser<LexerType>::parseProperty):
     29        (JSC::Parser<LexerType>::parsePrimaryExpression):
     30        (JSC::Parser<LexerType>::parseMemberExpression):
     31        * parser/Parser.h:
     32        (JSC::Parser::nextWithoutClearingLineTerminator):
     33        (JSC::Parser::lexCurrentTokenAgainUnderCurrentContext):
     34        (JSC::Parser::internalSaveLexerState):
     35        (JSC::Parser::restoreLexerState):
     36
    1372019-04-08  Ryan Haddad  <ryanhaddad@apple.com>
    238
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r244028 r244038  
    242242    ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string)
    243243    {
     244        ASSERT(string);
    244245        incConstants();
    245246        return new (m_parserArena) StringNode(location, *string);
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r244028 r244038  
    16921692        if (isLineTerminator(m_current)) {
    16931693            shiftLineTerminator();
    1694             m_terminator = true;
     1694            m_hasLineTerminatorBeforeToken = true;
    16951695        } else
    16961696            shift();
     
    17711771
    17721772template <typename T>
    1773 JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
     1773JSTokenType Lexer<T>::lexWithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
    17741774{
    17751775    JSTokenData* tokenData = &tokenRecord->m_data;
     
    17821782
    17831783    JSTokenType token = ERRORTOK;
    1784     m_terminator = false;
    17851784
    17861785start:
    17871786    skipWhitespace();
    17881787
    1789     if (atEnd())
    1790         return EOFTOK;
    1791    
    17921788    tokenLocation->startOffset = currentOffset();
    17931789    ASSERT(currentOffset() >= currentLineStartOffset());
    17941790    tokenRecord->m_startPosition = currentPosition();
     1791
     1792    if (atEnd()) {
     1793        token = EOFTOK;
     1794        goto returnToken;
     1795    }
    17951796
    17961797    CharacterType type;
     
    19031904        if (m_current == '+') {
    19041905            shift();
    1905             token = (!m_terminator) ? PLUSPLUS : AUTOPLUSPLUS;
     1906            token = (!m_hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS;
    19061907            break;
    19071908        }
     
    19171918        if (m_current == '-') {
    19181919            shift();
    1919             if ((m_atLineStart || m_terminator) && m_current == '>') {
     1920            if ((m_atLineStart || m_hasLineTerminatorBeforeToken) && m_current == '>') {
    19201921                if (m_scriptMode == JSParserScriptMode::Classic) {
    19211922                    shift();
     
    19231924                }
    19241925            }
    1925             token = (!m_terminator) ? MINUSMINUS : AUTOMINUSMINUS;
     1926            token = (!m_hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS;
    19261927            break;
    19271928        }
     
    22942295        shiftLineTerminator();
    22952296        m_atLineStart = true;
    2296         m_terminator = true;
     2297        m_hasLineTerminatorBeforeToken = true;
    22972298        m_lineStart = m_code;
    22982299        goto start;
     
    23342335
    23352336        while (!isLineTerminator(m_current)) {
    2336             if (atEnd())
    2337                 return EOFTOK;
     2337            if (atEnd()) {
     2338                token = EOFTOK;
     2339                fillTokenInfo(tokenRecord, token, lineNumber, endOffset, lineStartOffset, endPosition);
     2340                return token;
     2341            }
    23382342            shift();
    23392343        }
    23402344        shiftLineTerminator();
    23412345        m_atLineStart = true;
    2342         m_terminator = true;
     2346        m_hasLineTerminatorBeforeToken = true;
    23432347        m_lineStart = m_code;
    23442348        if (!lastTokenWasRestrKeyword())
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r244028 r244038  
    6666
    6767    JSTokenType lex(JSToken*, unsigned, bool strictMode);
     68    JSTokenType lexWithoutClearingLineTerminator(JSToken*, unsigned, bool strictMode);
    6869    bool nextTokenIsColon();
    6970    int lineNumber() const { return m_lineNumber; }
     
    7879    void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; }
    7980    int lastLineNumber() const { return m_lastLineNumber; }
    80     bool prevTerminator() const { return m_terminator; }
     81    bool hasLineTerminatorBeforeToken() const { return m_hasLineTerminatorBeforeToken; }
    8182    JSTokenType scanRegExp(JSToken*, UChar patternPrefix = 0);
    8283    enum class RawStringsBuildMode { BuildRawStrings, DontBuildRawStrings };
     
    111112        m_lineNumber = line;
    112113    }
    113     void setTerminator(bool terminator)
     114    void setHasLineTerminatorBeforeToken(bool terminator)
    114115    {
    115         m_terminator = terminator;
     116        m_hasLineTerminatorBeforeToken = terminator;
    116117    }
    117118
     
    203204    Vector<UChar> m_buffer16;
    204205    Vector<UChar> m_bufferForRawTemplateString16;
    205     bool m_terminator;
     206    bool m_hasLineTerminatorBeforeToken;
    206207    int m_lastToken;
    207208
     
    404405}
    405406
     407template <typename T>
     408ALWAYS_INLINE JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
     409{
     410    m_hasLineTerminatorBeforeToken = false;
     411    return lexWithoutClearingLineTerminator(tokenRecord, lexerFlags, strictMode);
     412}
     413
    406414} // namespace JSC
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r244028 r244038  
    346346bool Parser<LexerType>::allowAutomaticSemicolon()
    347347{
    348     return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->prevTerminator();
     348    return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->hasLineTerminatorBeforeToken();
    349349}
    350350
     
    626626        if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
    627627            next();
    628             failIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Cannot parse the async function");
     628            failIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Cannot parse the async function");
    629629            statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition);
    630630            break;
     
    697697            SavePoint savePoint = createSavePoint();
    698698            next();
    699             if (UNLIKELY(match(FUNCTION) && !m_lexer->prevTerminator())) {
     699            if (UNLIKELY(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())) {
    700700                result = parseAsyncFunctionDeclaration(context);
    701701                break;
     
    20272027    SavePoint savePoint = createSavePoint();
    20282028    next();
    2029     if (match(FUNCTION) && !m_lexer->prevTerminator()) {
     2029    if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
    20302030        const bool isAsync = true;
    20312031        result = parseFunctionDeclarationStatement(context, isAsync, parentAllowsFunctionDeclarationAsStatement);
     
    24222422        matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration");
    24232423
    2424         if (m_lexer->prevTerminator())
     2424        if (m_lexer->hasLineTerminatorBeforeToken())
    24252425            failDueToUnexpectedToken();
    24262426
     
    26132613        newInfo = SourceProviderCacheItem::create(parameters);
    26142614    }
     2615
     2616    bool functionScopeWasStrictMode = functionScope->strictMode();
    26152617   
    26162618    popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo);
     
    26192621        matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body");
    26202622        next();
     2623    } else {
     2624        // We need to lex the last token again because the last token is lexed under the different context because of the following possibilities.
     2625        // 1. which may have different strict mode.
     2626        // 2. which may not build strings for tokens.
     2627        // But (1) is not possible because we do not recognize the string literal in ArrowFunctionBodyExpression as directive and this is correct in terms of the spec (`value => "use strict"`).
     2628        // So we only check TreeBuilder's type here.
     2629        ASSERT_UNUSED(functionScopeWasStrictMode, functionScopeWasStrictMode == currentScope()->strictMode());
     2630        if (!std::is_same<TreeBuilder, SyntaxChecker>::value)
     2631            lexCurrentTokenAgainUnderCurrentContext();
    26212632    }
    26222633
     
    28772888                    ident = m_token.m_data.ident;
    28782889                    next();
    2879                     if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->prevTerminator())
     2890                    if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->hasLineTerminatorBeforeToken())
    28802891                        break;
    28812892                    if (UNLIKELY(consume(TIMES)))
     
    33973408            SavePoint savePoint = createSavePoint();
    33983409            next();
    3399             if (match(FUNCTION) && !m_lexer->prevTerminator()) {
     3410            if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) {
    34003411                next();
    34013412                if (match(IDENT))
     
    35423553            if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
    35433554                next();
    3544                 semanticFailIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
     3555                semanticFailIfFalse(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken(), "Expected 'function' keyword following 'async' keyword with no preceding line terminator");
    35453556                DepthManager statementDepth(&m_statementDepth);
    35463557                m_statementDepth = 1;
     
    36603671                if (matchContextualKeyword(m_vm->propertyNames->async)) {
    36613672                    next();
    3662                     isAsyncArrow = !m_lexer->prevTerminator();
     3673                    isAsyncArrow = !m_lexer->hasLineTerminatorBeforeToken();
    36633674                }
    36643675            }
     
    37773788    SavePoint savePoint = createSavePoint();
    37783789    next();
    3779     if (m_lexer->prevTerminator())
     3790    if (m_lexer->hasLineTerminatorBeforeToken())
    37803791        return context.createYield(location);
    37813792
     
    39373948                }
    39383949
    3939                 failIfTrue(m_lexer->prevTerminator(), "Expected a property name following keyword 'async'");
     3950                failIfTrue(m_lexer->hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'");
    39403951                if (UNLIKELY(consume(TIMES)))
    39413952                    parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode;
     
    44864497            JSTokenLocation location(tokenLocation());
    44874498            next();
    4488             if (match(FUNCTION) && !m_lexer->prevTerminator())
     4499            if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())
    44894500                return parseAsyncFunctionExpression(context);
    44904501
     
    47524763        base = parsePrimaryExpression(context);
    47534764        failIfFalse(base, "Cannot parse base expression");
    4754         if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->prevTerminator())) {
     4765        if (UNLIKELY(isAsync && context.isResolve(base) && !m_lexer->hasLineTerminatorBeforeToken())) {
    47554766            if (matchSpecIdentifier()) {
    47564767                // AsyncArrowFunction
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r244028 r244038  
    13641364    }
    13651365
     1366    ALWAYS_INLINE void nextWithoutClearingLineTerminator(unsigned lexerFlags = 0)
     1367    {
     1368        int lastLine = m_token.m_location.line;
     1369        int lastTokenEnd = m_token.m_location.endOffset;
     1370        int lastTokenLineStart = m_token.m_location.lineStartOffset;
     1371        m_lastTokenEndPosition = JSTextPosition(lastLine, lastTokenEnd, lastTokenLineStart);
     1372        m_lexer->setLastLineNumber(lastLine);
     1373        m_token.m_type = m_lexer->lexWithoutClearingLineTerminator(&m_token, lexerFlags, strictMode());
     1374    }
     1375
    13661376    ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0)
    13671377    {
     
    13721382        m_lexer->setLastLineNumber(lastLine);
    13731383        m_token.m_type = m_lexer->lexExpectIdentifier(&m_token, lexerFlags, strictMode());
     1384    }
     1385
     1386    ALWAYS_INLINE void lexCurrentTokenAgainUnderCurrentContext()
     1387    {
     1388        auto savePoint = createSavePoint();
     1389        restoreSavePoint(savePoint);
    13741390    }
    13751391
     
    17631779        unsigned oldLastLineNumber;
    17641780        unsigned oldLineNumber;
     1781        bool hasLineTerminatorBeforeToken;
    17651782    };
    17661783
     
    17761793        result.oldLastLineNumber = m_lexer->lastLineNumber();
    17771794        result.oldLineNumber = m_lexer->lineNumber();
     1795        result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken();
    17781796        ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset);
    17791797        return result;
     
    17851803        m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset);
    17861804        m_lexer->setLineNumber(lexerState.oldLineNumber);
    1787         next();
     1805        m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken);
     1806        nextWithoutClearingLineTerminator();
    17881807        m_lexer->setLastLineNumber(lexerState.oldLastLineNumber);
    17891808    }
Note: See TracChangeset for help on using the changeset viewer.