Changeset 244038 in webkit
- Timestamp:
- Apr 8, 2019, 1:43:18 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/arrow-function-and-use-strict-directive.js (added)
-
JSTests/stress/arrow-function-syntax.js (added)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/runtime/parse-expected.txt (modified) (2 diffs)
-
LayoutTests/inspector/runtime/parse.html (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/parser/ASTBuilder.h (modified) (1 diff)
-
Source/JavaScriptCore/parser/Lexer.cpp (modified) (8 diffs)
-
Source/JavaScriptCore/parser/Lexer.h (modified) (5 diffs)
-
Source/JavaScriptCore/parser/Parser.cpp (modified) (15 diffs)
-
Source/JavaScriptCore/parser/Parser.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244028 r244038 1 2019-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 1 11 2019-04-08 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/LayoutTests/ChangeLog
r244037 r244038 1 2019-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 1 11 2019-04-08 Antti Koivisto <antti@apple.com> 2 12 -
trunk/LayoutTests/inspector/runtime/parse-expected.txt
r211319 r244038 76 76 PASS: Should be SyntaxErrorType Recoverable. 77 77 Source: ( 78 ^79 Error Message: Unexpected end of script 80 Error Range: {"startOffset": 0,"endOffset":1}78 ^ 79 Error Message: Unexpected end of script 80 Error Range: {"startOffset":1,"endOffset":1} 81 81 82 82 PASS: Should be SyntaxErrorType Recoverable. 83 83 Source: { 84 ^85 Error Message: Unexpected end of script 86 Error Range: {"startOffset": 0,"endOffset":1}84 ^ 85 Error Message: Unexpected end of script 86 Error Range: {"startOffset":1,"endOffset":1} 87 87 88 88 PASS: Should be SyntaxErrorType Recoverable. 89 89 Source: ! 90 ^91 Error Message: Unexpected end of script 92 Error Range: {"startOffset": 0,"endOffset":1}90 ^ 91 Error Message: Unexpected end of script 92 Error Range: {"startOffset":1,"endOffset":1} 93 93 94 94 PASS: Should be SyntaxErrorType Recoverable. 95 95 Source: - 96 ^97 Error Message: Unexpected end of script 98 Error Range: {"startOffset": 0,"endOffset":1}96 ^ 97 Error Message: Unexpected end of script 98 Error Range: {"startOffset":1,"endOffset":1} 99 99 100 100 PASS: Should be SyntaxErrorType Recoverable. 101 101 Source: + 102 ^103 Error Message: Unexpected end of script 104 Error Range: {"startOffset": 0,"endOffset":1}102 ^ 103 Error Message: Unexpected end of script 104 Error Range: {"startOffset":1,"endOffset":1} 105 105 106 106 PASS: Should be SyntaxErrorType Recoverable. 107 107 Source: ~ 108 ^109 Error Message: Unexpected end of script 110 Error Range: {"startOffset": 0,"endOffset":1}108 ^ 109 Error Message: Unexpected end of script 110 Error Range: {"startOffset":1,"endOffset":1} 111 111 112 112 PASS: Should be SyntaxErrorType Recoverable. 113 113 Source: 1, 114 ^115 Error Message: Unexpected end of script 116 Error Range: {"startOffset": 1,"endOffset":2}114 ^ 115 Error Message: Unexpected end of script 116 Error Range: {"startOffset":2,"endOffset":2} 117 117 118 118 PASS: Should be SyntaxErrorType Recoverable. 119 119 Source: var 120 ^~~121 Error Message: Unexpected end of script 122 Error Range: {"startOffset": 0,"endOffset":3}120 ^ 121 Error Message: Unexpected end of script 122 Error Range: {"startOffset":3,"endOffset":3} 123 123 124 124 PASS: Should be SyntaxErrorType Recoverable. 125 125 Source: 'use strict'; let 126 ^~~127 Error Message: Unexpected end of script 128 Error Range: {"startOffset":1 4,"endOffset":17}126 ^ 127 Error Message: Unexpected end of script 128 Error Range: {"startOffset":17,"endOffset":17} 129 129 130 130 PASS: Should be SyntaxErrorType Recoverable. 131 131 Source: const 132 ^~~~~133 Error Message: Unexpected end of script 134 Error Range: {"startOffset": 0,"endOffset":5}132 ^ 133 Error Message: Unexpected end of script 134 Error Range: {"startOffset":5,"endOffset":5} 135 135 136 136 PASS: Should be SyntaxErrorType Recoverable. 137 137 Source: var {x 138 ^ 139 Error Message: Unexpected end of script 140 Error Range: {"startOffset":6,"endOffset":6} 141 142 PASS: Should be SyntaxErrorType Recoverable. 143 Source: var [x 144 ^ 145 Error Message: Unexpected end of script 146 Error Range: {"startOffset":6,"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":6,"endOffset":6} 153 154 PASS: Should be SyntaxErrorType Recoverable. 155 Source: if(1) 138 156 ^ 139 157 Error Message: Unexpected end of script 140 Error Range: {"startOffset":5,"endOffset":6} 141 142 PASS: Should be SyntaxErrorType Recoverable. 143 Source: var [x 158 Error Range: {"startOffset":5,"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":6,"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":11,"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":12,"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":8,"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":9,"endOffset":9} 189 190 PASS: Should be SyntaxErrorType Recoverable. 191 Source: for(;;) 192 ^ 193 Error Message: Unexpected end of script 194 Error Range: {"startOffset":7,"endOffset":7} 195 196 PASS: Should be SyntaxErrorType Recoverable. 197 Source: for(;;){ 198 ^ 199 Error Message: Unexpected end of script 200 Error Range: {"startOffset":8,"endOffset":8} 201 202 PASS: Should be SyntaxErrorType Recoverable. 203 Source: ()=> 204 ^ 205 Error Message: Unexpected end of script 206 Error Range: {"startOffset":4,"endOffset":4} 207 208 PASS: Should be SyntaxErrorType Recoverable. 209 Source: ()=>{ 144 210 ^ 145 211 Error 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} 212 Error Range: {"startOffset":5,"endOffset":5} 213 213 214 214 PASS: Should be SyntaxErrorType Recoverable. … … 232 232 PASS: Should be SyntaxErrorType Recoverable. 233 233 Source: `${ 234 ^~~235 Error Message: Unexpected end of script 236 Error Range: {"startOffset": 0,"endOffset":3}234 ^ 235 Error Message: Unexpected end of script 236 Error Range: {"startOffset":3,"endOffset":3} 237 237 238 238 PASS: Should be SyntaxErrorType Recoverable. 239 239 Source: function 240 ^~~~~~~~241 Error Message: Unexpected end of script 242 Error Range: {"startOffset": 0,"endOffset":8}240 ^ 241 Error Message: Unexpected end of script 242 Error Range: {"startOffset":8,"endOffset":8} 243 243 244 244 PASS: Should be SyntaxErrorType Recoverable. 245 245 Source: function foo 246 ^~~247 Error Message: Unexpected end of script 248 Error Range: {"startOffset": 9,"endOffset":12}246 ^ 247 Error Message: Unexpected end of script 248 Error Range: {"startOffset":12,"endOffset":12} 249 249 250 250 PASS: Should be SyntaxErrorType Recoverable. 251 251 Source: function foo( 252 ^253 Error Message: Unexpected end of script 254 Error Range: {"startOffset":1 2,"endOffset":13}252 ^ 253 Error Message: Unexpected end of script 254 Error Range: {"startOffset":13,"endOffset":13} 255 255 256 256 PASS: Should be SyntaxErrorType Recoverable. 257 257 Source: function foo(){ 258 ^ 259 Error Message: Unexpected end of script 260 Error Range: {"startOffset":15,"endOffset":15} 261 262 PASS: Should be SyntaxErrorType Recoverable. 263 Source: (function() { 264 ^ 265 Error Message: Unexpected end of script 266 Error Range: {"startOffset":13,"endOffset":13} 267 268 PASS: Should be SyntaxErrorType Recoverable. 269 Source: (function() {} 258 270 ^ 259 271 Error 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} 272 Error Range: {"startOffset":14,"endOffset":14} 273 273 274 274 PASS: Should be SyntaxErrorType Recoverable. 275 275 Source: (function() {})( 276 ^277 Error Message: Unexpected end of script 278 Error Range: {"startOffset":1 5,"endOffset":16}276 ^ 277 Error Message: Unexpected end of script 278 Error Range: {"startOffset":16,"endOffset":16} 279 279 280 280 PASS: Should be SyntaxErrorType Recoverable. 281 281 Source: switch(x) 282 ^283 Error Message: Unexpected end of script 284 Error Range: {"startOffset": 8,"endOffset":9}282 ^ 283 Error Message: Unexpected end of script 284 Error Range: {"startOffset":9,"endOffset":9} 285 285 286 286 PASS: Should be SyntaxErrorType Recoverable. 287 287 Source: switch(x){ 288 ^ 289 Error Message: Unexpected end of script 290 Error Range: {"startOffset":10,"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":14,"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":16,"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":17,"endOffset":17} 309 310 PASS: Should be SyntaxErrorType Recoverable. 311 Source: class 312 ^ 313 Error Message: Unexpected end of script 314 Error Range: {"startOffset":5,"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":11,"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":13,"endOffset":13} 327 328 PASS: Should be SyntaxErrorType Recoverable. 329 Source: var x = { 288 330 ^ 289 331 Error 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} 332 Error Range: {"startOffset":9,"endOffset":9} 333 333 334 334 PASS: Should be SyntaxErrorType Recoverable. 335 335 Source: var x = {prop 336 ^~~~337 Error Message: Unexpected end of script 338 Error Range: {"startOffset": 9,"endOffset":13}336 ^ 337 Error Message: Unexpected end of script 338 Error Range: {"startOffset":13,"endOffset":13} 339 339 340 340 PASS: Should be SyntaxErrorType Recoverable. 341 341 Source: var x = {prop: 342 ^343 Error Message: Unexpected end of script 344 Error Range: {"startOffset":1 3,"endOffset":14}342 ^ 343 Error Message: Unexpected end of script 344 Error Range: {"startOffset":14,"endOffset":14} 345 345 346 346 PASS: Should be SyntaxErrorType Recoverable. 347 347 Source: var x = {prop:123 348 ^~~349 Error Message: Unexpected end of script 350 Error Range: {"startOffset":1 4,"endOffset":17}348 ^ 349 Error Message: Unexpected end of script 350 Error Range: {"startOffset":17,"endOffset":17} 351 351 352 352 PASS: Should be SyntaxErrorType Recoverable. 353 353 Source: var x = {prop:123 354 ^~~355 Error Message: Unexpected end of script 356 Error Range: {"startOffset":1 4,"endOffset":17}354 ^ 355 Error Message: Unexpected end of script 356 Error Range: {"startOffset":18,"endOffset":18} 357 357 358 358 PASS: Should be SyntaxErrorType Recoverable. 359 359 Source: var x = {prop:123, 360 ^361 Error Message: Unexpected end of script 362 Error Range: {"startOffset":1 7,"endOffset":18}360 ^ 361 Error Message: Unexpected end of script 362 Error Range: {"startOffset":18,"endOffset":18} 363 363 364 364 PASS: Should be SyntaxErrorType Recoverable. 365 365 Source: var x = {prop:123, 366 ^367 Error Message: Unexpected end of script 368 Error Range: {"startOffset":1 7,"endOffset":18}366 ^ 367 Error Message: Unexpected end of script 368 Error Range: {"startOffset":19,"endOffset":19} 369 369 370 370 PASS: Should be SyntaxErrorType Recoverable. 371 371 Source: var x = {prop:123, 'prop2' 372 ^~~~~~~373 Error Message: Unexpected end of script 374 Error Range: {"startOffset": 19,"endOffset":26}372 ^ 373 Error Message: Unexpected end of script 374 Error Range: {"startOffset":26,"endOffset":26} 375 375 376 376 PASS: Should be SyntaxErrorType Recoverable. 377 377 Source: var x = {prop:123, [12 378 ^~379 Error Message: Unexpected end of script 380 Error Range: {"startOffset":2 0,"endOffset":22}378 ^ 379 Error Message: Unexpected end of script 380 Error Range: {"startOffset":22,"endOffset":22} 381 381 382 382 PASS: Should be SyntaxErrorType Recoverable. 383 383 Source: var x = {prop:123, [12] 384 ^385 Error Message: Unexpected end of script 386 Error Range: {"startOffset":2 2,"endOffset":23}384 ^ 385 Error Message: Unexpected end of script 386 Error Range: {"startOffset":23,"endOffset":23} 387 387 388 388 PASS: Should be SyntaxErrorType Recoverable. 389 389 Source: var x = {prop:123, [12]: 390 ^391 Error Message: Unexpected end of script 392 Error Range: {"startOffset":2 3,"endOffset":24}390 ^ 391 Error Message: Unexpected end of script 392 Error Range: {"startOffset":24,"endOffset":24} 393 393 394 394 PASS: Should be SyntaxErrorType Recoverable. 395 395 Source: var x = {prop:123, [12]:567 396 ^~~397 Error Message: Unexpected end of script 398 Error Range: {"startOffset":2 4,"endOffset":27}396 ^ 397 Error Message: Unexpected end of script 398 Error Range: {"startOffset":27,"endOffset":27} 399 399 400 400 PASS: Should be SyntaxErrorType Recoverable. 401 401 Source: var x = [ 402 ^403 Error Message: Unexpected end of script 404 Error Range: {"startOffset": 8,"endOffset":9}402 ^ 403 Error Message: Unexpected end of script 404 Error Range: {"startOffset":9,"endOffset":9} 405 405 406 406 PASS: Should be SyntaxErrorType Recoverable. 407 407 Source: var x = [1 408 ^409 Error Message: Unexpected end of script 410 Error Range: {"startOffset": 9,"endOffset":10}408 ^ 409 Error Message: Unexpected end of script 410 Error Range: {"startOffset":10,"endOffset":10} 411 411 412 412 PASS: Should be SyntaxErrorType Recoverable. 413 413 Source: var x = [1, 414 ^415 Error Message: Unexpected end of script 416 Error Range: {"startOffset":1 0,"endOffset":11}414 ^ 415 Error Message: Unexpected end of script 416 Error Range: {"startOffset":11,"endOffset":11} 417 417 418 418 PASS: Should be SyntaxErrorType Recoverable. 419 419 Source: var x = [1,[] 420 ^421 Error Message: Unexpected end of script 422 Error Range: {"startOffset":1 2,"endOffset":13}420 ^ 421 Error Message: Unexpected end of script 422 Error Range: {"startOffset":13,"endOffset":13} 423 423 424 424 PASS: Should be SyntaxErrorType Recoverable. 425 425 Source: var x = [1,{} 426 ^427 Error Message: Unexpected end of script 428 Error Range: {"startOffset":1 2,"endOffset":13}426 ^ 427 Error Message: Unexpected end of script 428 Error Range: {"startOffset":13,"endOffset":13} 429 429 430 430 -
trunk/LayoutTests/inspector/runtime/parse.html
r210062 r244038 10 10 str += " ".repeat(range.startOffset); 11 11 str += "^"; 12 str += "~".repeat( range.endOffset - range.startOffset - 1);12 str += "~".repeat(Math.max(range.endOffset - range.startOffset - 1, 0)); 13 13 InspectorTest.log(str); 14 14 } -
trunk/Source/JavaScriptCore/ChangeLog
r244028 r244038 1 2019-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 1 37 2019-04-08 Ryan Haddad <ryanhaddad@apple.com> 2 38 -
trunk/Source/JavaScriptCore/parser/ASTBuilder.h
r244028 r244038 242 242 ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string) 243 243 { 244 ASSERT(string); 244 245 incConstants(); 245 246 return new (m_parserArena) StringNode(location, *string); -
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r244028 r244038 1692 1692 if (isLineTerminator(m_current)) { 1693 1693 shiftLineTerminator(); 1694 m_ terminator= true;1694 m_hasLineTerminatorBeforeToken = true; 1695 1695 } else 1696 1696 shift(); … … 1771 1771 1772 1772 template <typename T> 1773 JSTokenType Lexer<T>::lex (JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)1773 JSTokenType Lexer<T>::lexWithoutClearingLineTerminator(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode) 1774 1774 { 1775 1775 JSTokenData* tokenData = &tokenRecord->m_data; … … 1782 1782 1783 1783 JSTokenType token = ERRORTOK; 1784 m_terminator = false;1785 1784 1786 1785 start: 1787 1786 skipWhitespace(); 1788 1787 1789 if (atEnd())1790 return EOFTOK;1791 1792 1788 tokenLocation->startOffset = currentOffset(); 1793 1789 ASSERT(currentOffset() >= currentLineStartOffset()); 1794 1790 tokenRecord->m_startPosition = currentPosition(); 1791 1792 if (atEnd()) { 1793 token = EOFTOK; 1794 goto returnToken; 1795 } 1795 1796 1796 1797 CharacterType type; … … 1903 1904 if (m_current == '+') { 1904 1905 shift(); 1905 token = (!m_ terminator) ? PLUSPLUS : AUTOPLUSPLUS;1906 token = (!m_hasLineTerminatorBeforeToken) ? PLUSPLUS : AUTOPLUSPLUS; 1906 1907 break; 1907 1908 } … … 1917 1918 if (m_current == '-') { 1918 1919 shift(); 1919 if ((m_atLineStart || m_ terminator) && m_current == '>') {1920 if ((m_atLineStart || m_hasLineTerminatorBeforeToken) && m_current == '>') { 1920 1921 if (m_scriptMode == JSParserScriptMode::Classic) { 1921 1922 shift(); … … 1923 1924 } 1924 1925 } 1925 token = (!m_ terminator) ? MINUSMINUS : AUTOMINUSMINUS;1926 token = (!m_hasLineTerminatorBeforeToken) ? MINUSMINUS : AUTOMINUSMINUS; 1926 1927 break; 1927 1928 } … … 2294 2295 shiftLineTerminator(); 2295 2296 m_atLineStart = true; 2296 m_ terminator= true;2297 m_hasLineTerminatorBeforeToken = true; 2297 2298 m_lineStart = m_code; 2298 2299 goto start; … … 2334 2335 2335 2336 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 } 2338 2342 shift(); 2339 2343 } 2340 2344 shiftLineTerminator(); 2341 2345 m_atLineStart = true; 2342 m_ terminator= true;2346 m_hasLineTerminatorBeforeToken = true; 2343 2347 m_lineStart = m_code; 2344 2348 if (!lastTokenWasRestrKeyword()) -
trunk/Source/JavaScriptCore/parser/Lexer.h
r244028 r244038 66 66 67 67 JSTokenType lex(JSToken*, unsigned, bool strictMode); 68 JSTokenType lexWithoutClearingLineTerminator(JSToken*, unsigned, bool strictMode); 68 69 bool nextTokenIsColon(); 69 70 int lineNumber() const { return m_lineNumber; } … … 78 79 void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; } 79 80 int lastLineNumber() const { return m_lastLineNumber; } 80 bool prevTerminator() const { return m_terminator; }81 bool hasLineTerminatorBeforeToken() const { return m_hasLineTerminatorBeforeToken; } 81 82 JSTokenType scanRegExp(JSToken*, UChar patternPrefix = 0); 82 83 enum class RawStringsBuildMode { BuildRawStrings, DontBuildRawStrings }; … … 111 112 m_lineNumber = line; 112 113 } 113 void set Terminator(bool terminator)114 void setHasLineTerminatorBeforeToken(bool terminator) 114 115 { 115 m_ terminator= terminator;116 m_hasLineTerminatorBeforeToken = terminator; 116 117 } 117 118 … … 203 204 Vector<UChar> m_buffer16; 204 205 Vector<UChar> m_bufferForRawTemplateString16; 205 bool m_ terminator;206 bool m_hasLineTerminatorBeforeToken; 206 207 int m_lastToken; 207 208 … … 404 405 } 405 406 407 template <typename T> 408 ALWAYS_INLINE JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode) 409 { 410 m_hasLineTerminatorBeforeToken = false; 411 return lexWithoutClearingLineTerminator(tokenRecord, lexerFlags, strictMode); 412 } 413 406 414 } // namespace JSC -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r244028 r244038 346 346 bool Parser<LexerType>::allowAutomaticSemicolon() 347 347 { 348 return match(CLOSEBRACE) || match(EOFTOK) || m_lexer-> prevTerminator();348 return match(CLOSEBRACE) || match(EOFTOK) || m_lexer->hasLineTerminatorBeforeToken(); 349 349 } 350 350 … … 626 626 if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) { 627 627 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"); 629 629 statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition); 630 630 break; … … 697 697 SavePoint savePoint = createSavePoint(); 698 698 next(); 699 if (UNLIKELY(match(FUNCTION) && !m_lexer-> prevTerminator())) {699 if (UNLIKELY(match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken())) { 700 700 result = parseAsyncFunctionDeclaration(context); 701 701 break; … … 2027 2027 SavePoint savePoint = createSavePoint(); 2028 2028 next(); 2029 if (match(FUNCTION) && !m_lexer-> prevTerminator()) {2029 if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) { 2030 2030 const bool isAsync = true; 2031 2031 result = parseFunctionDeclarationStatement(context, isAsync, parentAllowsFunctionDeclarationAsStatement); … … 2422 2422 matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration"); 2423 2423 2424 if (m_lexer-> prevTerminator())2424 if (m_lexer->hasLineTerminatorBeforeToken()) 2425 2425 failDueToUnexpectedToken(); 2426 2426 … … 2613 2613 newInfo = SourceProviderCacheItem::create(parameters); 2614 2614 } 2615 2616 bool functionScopeWasStrictMode = functionScope->strictMode(); 2615 2617 2616 2618 popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo); … … 2619 2621 matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body"); 2620 2622 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(); 2621 2632 } 2622 2633 … … 2877 2888 ident = m_token.m_data.ident; 2878 2889 next(); 2879 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer-> prevTerminator())2890 if (match(OPENPAREN) || match(COLON) || match(EQUAL) || m_lexer->hasLineTerminatorBeforeToken()) 2880 2891 break; 2881 2892 if (UNLIKELY(consume(TIMES))) … … 3397 3408 SavePoint savePoint = createSavePoint(); 3398 3409 next(); 3399 if (match(FUNCTION) && !m_lexer-> prevTerminator()) {3410 if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) { 3400 3411 next(); 3401 3412 if (match(IDENT)) … … 3542 3553 if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) { 3543 3554 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"); 3545 3556 DepthManager statementDepth(&m_statementDepth); 3546 3557 m_statementDepth = 1; … … 3660 3671 if (matchContextualKeyword(m_vm->propertyNames->async)) { 3661 3672 next(); 3662 isAsyncArrow = !m_lexer-> prevTerminator();3673 isAsyncArrow = !m_lexer->hasLineTerminatorBeforeToken(); 3663 3674 } 3664 3675 } … … 3777 3788 SavePoint savePoint = createSavePoint(); 3778 3789 next(); 3779 if (m_lexer-> prevTerminator())3790 if (m_lexer->hasLineTerminatorBeforeToken()) 3780 3791 return context.createYield(location); 3781 3792 … … 3937 3948 } 3938 3949 3939 failIfTrue(m_lexer-> prevTerminator(), "Expected a property name following keyword 'async'");3950 failIfTrue(m_lexer->hasLineTerminatorBeforeToken(), "Expected a property name following keyword 'async'"); 3940 3951 if (UNLIKELY(consume(TIMES))) 3941 3952 parseMode = SourceParseMode::AsyncGeneratorWrapperMethodMode; … … 4486 4497 JSTokenLocation location(tokenLocation()); 4487 4498 next(); 4488 if (match(FUNCTION) && !m_lexer-> prevTerminator())4499 if (match(FUNCTION) && !m_lexer->hasLineTerminatorBeforeToken()) 4489 4500 return parseAsyncFunctionExpression(context); 4490 4501 … … 4752 4763 base = parsePrimaryExpression(context); 4753 4764 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())) { 4755 4766 if (matchSpecIdentifier()) { 4756 4767 // AsyncArrowFunction -
trunk/Source/JavaScriptCore/parser/Parser.h
r244028 r244038 1364 1364 } 1365 1365 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 1366 1376 ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0) 1367 1377 { … … 1372 1382 m_lexer->setLastLineNumber(lastLine); 1373 1383 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); 1374 1390 } 1375 1391 … … 1763 1779 unsigned oldLastLineNumber; 1764 1780 unsigned oldLineNumber; 1781 bool hasLineTerminatorBeforeToken; 1765 1782 }; 1766 1783 … … 1776 1793 result.oldLastLineNumber = m_lexer->lastLineNumber(); 1777 1794 result.oldLineNumber = m_lexer->lineNumber(); 1795 result.hasLineTerminatorBeforeToken = m_lexer->hasLineTerminatorBeforeToken(); 1778 1796 ASSERT(static_cast<unsigned>(result.startOffset) >= result.oldLineStartOffset); 1779 1797 return result; … … 1785 1803 m_lexer->setOffset(lexerState.startOffset, lexerState.oldLineStartOffset); 1786 1804 m_lexer->setLineNumber(lexerState.oldLineNumber); 1787 next(); 1805 m_lexer->setHasLineTerminatorBeforeToken(lexerState.hasLineTerminatorBeforeToken); 1806 nextWithoutClearingLineTerminator(); 1788 1807 m_lexer->setLastLineNumber(lexerState.oldLastLineNumber); 1789 1808 }
Note:
See TracChangeset
for help on using the changeset viewer.