| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 NULL | 276 NULL |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); | 279 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); |
| 280 for (int i = 0; programs[i]; i++) { | 280 for (int i = 0; programs[i]; i++) { |
| 281 const char* program = programs[i]; | 281 const char* program = programs[i]; |
| 282 i::Utf8ToUC16CharacterStream stream( | 282 i::Utf8ToUC16CharacterStream stream( |
| 283 reinterpret_cast<const i::byte*>(program), | 283 reinterpret_cast<const i::byte*>(program), |
| 284 static_cast<unsigned>(strlen(program))); | 284 static_cast<unsigned>(strlen(program))); |
| 285 i::CompleteParserRecorder log; | 285 i::CompleteParserRecorder log; |
| 286 i::V8JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); | 286 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); |
| 287 scanner.Initialize(&stream); | 287 scanner.Initialize(&stream); |
| 288 | 288 |
| 289 v8::preparser::PreParser::PreParseResult result = | 289 v8::preparser::PreParser::PreParseResult result = |
| 290 v8::preparser::PreParser::PreParseProgram(&scanner, | 290 v8::preparser::PreParser::PreParseProgram(&scanner, |
| 291 &log, | 291 &log, |
| 292 true, | 292 true, |
| 293 stack_limit); | 293 stack_limit); |
| 294 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | 294 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); |
| 295 i::ScriptDataImpl data(log.ExtractData()); | 295 i::ScriptDataImpl data(log.ExtractData()); |
| 296 CHECK(!data.has_error()); | 296 CHECK(!data.has_error()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 reinterpret_cast<char*>(malloc(kProgramSize + 1))); | 369 reinterpret_cast<char*>(malloc(kProgramSize + 1))); |
| 370 memset(*program, '(', kProgramSize); | 370 memset(*program, '(', kProgramSize); |
| 371 program[kProgramSize] = '\0'; | 371 program[kProgramSize] = '\0'; |
| 372 | 372 |
| 373 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); | 373 uintptr_t stack_limit = i::Isolate::Current()->stack_guard()->real_climit(); |
| 374 | 374 |
| 375 i::Utf8ToUC16CharacterStream stream( | 375 i::Utf8ToUC16CharacterStream stream( |
| 376 reinterpret_cast<const i::byte*>(*program), | 376 reinterpret_cast<const i::byte*>(*program), |
| 377 static_cast<unsigned>(kProgramSize)); | 377 static_cast<unsigned>(kProgramSize)); |
| 378 i::CompleteParserRecorder log; | 378 i::CompleteParserRecorder log; |
| 379 i::V8JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); | 379 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); |
| 380 scanner.Initialize(&stream); | 380 scanner.Initialize(&stream); |
| 381 | 381 |
| 382 | 382 |
| 383 v8::preparser::PreParser::PreParseResult result = | 383 v8::preparser::PreParser::PreParseResult result = |
| 384 v8::preparser::PreParser::PreParseProgram(&scanner, | 384 v8::preparser::PreParser::PreParseProgram(&scanner, |
| 385 &log, | 385 &log, |
| 386 true, | 386 true, |
| 387 stack_limit); | 387 stack_limit); |
| 388 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); | 388 CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); |
| 389 } | 389 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 CHECK_EQU(i, stream.pos()); | 587 CHECK_EQU(i, stream.pos()); |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 #undef CHECK_EQU | 591 #undef CHECK_EQU |
| 592 | 592 |
| 593 void TestStreamScanner(i::UC16CharacterStream* stream, | 593 void TestStreamScanner(i::UC16CharacterStream* stream, |
| 594 i::Token::Value* expected_tokens, | 594 i::Token::Value* expected_tokens, |
| 595 int skip_pos = 0, // Zero means not skipping. | 595 int skip_pos = 0, // Zero means not skipping. |
| 596 int skip_to = 0) { | 596 int skip_to = 0) { |
| 597 i::V8JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); | 597 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); |
| 598 scanner.Initialize(stream); | 598 scanner.Initialize(stream); |
| 599 | 599 |
| 600 int i = 0; | 600 int i = 0; |
| 601 do { | 601 do { |
| 602 i::Token::Value expected = expected_tokens[i]; | 602 i::Token::Value expected = expected_tokens[i]; |
| 603 i::Token::Value actual = scanner.Next(); | 603 i::Token::Value actual = scanner.Next(); |
| 604 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); | 604 CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); |
| 605 if (scanner.location().end_pos == skip_pos) { | 605 if (scanner.location().end_pos == skip_pos) { |
| 606 scanner.SeekForward(skip_to); | 606 scanner.SeekForward(skip_to); |
| 607 } | 607 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 static_cast<unsigned>(strlen(str3))); | 666 static_cast<unsigned>(strlen(str3))); |
| 667 TestStreamScanner(&stream3, expectations3, 1, 1 + i); | 667 TestStreamScanner(&stream3, expectations3, 1, 1 + i); |
| 668 } | 668 } |
| 669 } | 669 } |
| 670 | 670 |
| 671 | 671 |
| 672 void TestScanRegExp(const char* re_source, const char* expected) { | 672 void TestScanRegExp(const char* re_source, const char* expected) { |
| 673 i::Utf8ToUC16CharacterStream stream( | 673 i::Utf8ToUC16CharacterStream stream( |
| 674 reinterpret_cast<const i::byte*>(re_source), | 674 reinterpret_cast<const i::byte*>(re_source), |
| 675 static_cast<unsigned>(strlen(re_source))); | 675 static_cast<unsigned>(strlen(re_source))); |
| 676 i::V8JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); | 676 i::JavaScriptScanner scanner(i::Isolate::Current()->unicode_cache()); |
| 677 scanner.Initialize(&stream); | 677 scanner.Initialize(&stream); |
| 678 | 678 |
| 679 i::Token::Value start = scanner.peek(); | 679 i::Token::Value start = scanner.peek(); |
| 680 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); | 680 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); |
| 681 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); | 681 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); |
| 682 scanner.Next(); // Current token is now the regexp literal. | 682 scanner.Next(); // Current token is now the regexp literal. |
| 683 CHECK(scanner.is_literal_ascii()); | 683 CHECK(scanner.is_literal_ascii()); |
| 684 i::Vector<const char> actual = scanner.literal_ascii_string(); | 684 i::Vector<const char> actual = scanner.literal_ascii_string(); |
| 685 for (int i = 0; i < actual.length(); i++) { | 685 for (int i = 0; i < actual.length(); i++) { |
| 686 CHECK_NE('\0', expected[i]); | 686 CHECK_NE('\0', expected[i]); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 715 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); | 715 TestScanRegExp("/[\\u12]/flipperwald", "[\\u12]"); |
| 716 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); | 716 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); |
| 717 // Escaped ']'s wont end the character class. | 717 // Escaped ']'s wont end the character class. |
| 718 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); | 718 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); |
| 719 // Escaped slashes are not terminating. | 719 // Escaped slashes are not terminating. |
| 720 TestScanRegExp("/\\//flipperwald", "\\/"); | 720 TestScanRegExp("/\\//flipperwald", "\\/"); |
| 721 // Starting with '=' works too. | 721 // Starting with '=' works too. |
| 722 TestScanRegExp("/=/", "="); | 722 TestScanRegExp("/=/", "="); |
| 723 TestScanRegExp("/=?/", "=?"); | 723 TestScanRegExp("/=?/", "=?"); |
| 724 } | 724 } |
| OLD | NEW |