| Index: src/scanner-base.cc
|
| ===================================================================
|
| --- src/scanner-base.cc (revision 7563)
|
| +++ src/scanner-base.cc (working copy)
|
| @@ -27,7 +27,13 @@
|
|
|
| // Features shared by parsing and pre-parsing scanners.
|
|
|
| +#include "v8.h"
|
| +
|
| +/*
|
| +TODO(isolates): I incldue v8.h instead of these because we need Isolate and
|
| +some classes (NativeAllocationChecker) are moved into isolate.h
|
| #include "../include/v8stdint.h"
|
| +*/
|
| #include "scanner-base.h"
|
| #include "char-predicates-inl.h"
|
|
|
| @@ -35,16 +41,6 @@
|
| namespace internal {
|
|
|
| // ----------------------------------------------------------------------------
|
| -// Character predicates
|
| -
|
| -unibrow::Predicate<IdentifierStart, 128> ScannerConstants::kIsIdentifierStart;
|
| -unibrow::Predicate<IdentifierPart, 128> ScannerConstants::kIsIdentifierPart;
|
| -unibrow::Predicate<unibrow::WhiteSpace, 128> ScannerConstants::kIsWhiteSpace;
|
| -unibrow::Predicate<unibrow::LineTerminator, 128>
|
| - ScannerConstants::kIsLineTerminator;
|
| -
|
| -StaticResource<ScannerConstants::Utf8Decoder> ScannerConstants::utf8_decoder_;
|
| -
|
| // Compound predicates.
|
|
|
| bool ScannerConstants::IsIdentifier(unibrow::CharacterStream* buffer) {
|
| @@ -64,8 +60,10 @@
|
| // ----------------------------------------------------------------------------
|
| // Scanner
|
|
|
| -Scanner::Scanner()
|
| - : octal_pos_(kNoOctalLocation) { }
|
| +Scanner::Scanner(Isolate* isolate)
|
| + : scanner_constants_(isolate->scanner_constants()),
|
| + octal_pos_(kNoOctalLocation) {
|
| +}
|
|
|
|
|
| uc32 Scanner::ScanHexEscape(uc32 c, int length) {
|
| @@ -122,7 +120,7 @@
|
| // ----------------------------------------------------------------------------
|
| // JavaScriptScanner
|
|
|
| -JavaScriptScanner::JavaScriptScanner() : Scanner() {}
|
| +JavaScriptScanner::JavaScriptScanner(Isolate* isolate) : Scanner(isolate) {}
|
|
|
|
|
| Token::Value JavaScriptScanner::Next() {
|
| @@ -151,9 +149,9 @@
|
| while (true) {
|
| // We treat byte-order marks (BOMs) as whitespace for better
|
| // compatibility with Spidermonkey and other JavaScript engines.
|
| - while (ScannerConstants::kIsWhiteSpace.get(c0_) || IsByteOrderMark(c0_)) {
|
| + while (scanner_constants_->IsWhiteSpace(c0_) || IsByteOrderMark(c0_)) {
|
| // IsWhiteSpace() includes line terminators!
|
| - if (ScannerConstants::kIsLineTerminator.get(c0_)) {
|
| + if (scanner_constants_->IsLineTerminator(c0_)) {
|
| // Ignore line terminators, but remember them. This is necessary
|
| // for automatic semicolon insertion.
|
| has_line_terminator_before_next_ = true;
|
| @@ -193,7 +191,7 @@
|
| // separately by the lexical grammar and becomes part of the
|
| // stream of input elements for the syntactic grammar (see
|
| // ECMA-262, section 7.4, page 12).
|
| - while (c0_ >= 0 && !ScannerConstants::kIsLineTerminator.get(c0_)) {
|
| + while (c0_ >= 0 && !scanner_constants_->IsLineTerminator(c0_)) {
|
| Advance();
|
| }
|
|
|
| @@ -458,7 +456,7 @@
|
| break;
|
|
|
| default:
|
| - if (ScannerConstants::kIsIdentifierStart.get(c0_)) {
|
| + if (scanner_constants_->IsIdentifierStart(c0_)) {
|
| token = ScanIdentifierOrKeyword();
|
| } else if (IsDecimalDigit(c0_)) {
|
| token = ScanNumber(false);
|
| @@ -506,7 +504,7 @@
|
| Advance();
|
|
|
| // Skip escaped newlines.
|
| - if (ScannerConstants::kIsLineTerminator.get(c)) {
|
| + if (scanner_constants_->IsLineTerminator(c)) {
|
| // Allow CR+LF newlines in multiline string literals.
|
| if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance();
|
| // Allow LF+CR newlines in multiline string literals.
|
| @@ -549,7 +547,7 @@
|
|
|
| LiteralScope literal(this);
|
| while (c0_ != quote && c0_ >= 0
|
| - && !ScannerConstants::kIsLineTerminator.get(c0_)) {
|
| + && !scanner_constants_->IsLineTerminator(c0_)) {
|
| uc32 c = c0_;
|
| Advance();
|
| if (c == '\\') {
|
| @@ -648,7 +646,7 @@
|
| // not be an identifier start or a decimal digit; see ECMA-262
|
| // section 7.8.3, page 17 (note that we read only one decimal digit
|
| // if the value is 0).
|
| - if (IsDecimalDigit(c0_) || ScannerConstants::kIsIdentifierStart.get(c0_))
|
| + if (IsDecimalDigit(c0_) || scanner_constants_->IsIdentifierStart(c0_))
|
| return Token::ILLEGAL;
|
|
|
| literal.Complete();
|
| @@ -670,14 +668,14 @@
|
|
|
|
|
| Token::Value JavaScriptScanner::ScanIdentifierOrKeyword() {
|
| - ASSERT(ScannerConstants::kIsIdentifierStart.get(c0_));
|
| + ASSERT(scanner_constants_->IsIdentifierStart(c0_));
|
| LiteralScope literal(this);
|
| KeywordMatcher keyword_match;
|
| // Scan identifier start character.
|
| if (c0_ == '\\') {
|
| uc32 c = ScanIdentifierUnicodeEscape();
|
| // Only allow legal identifier start characters.
|
| - if (!ScannerConstants::kIsIdentifierStart.get(c)) return Token::ILLEGAL;
|
| + if (!scanner_constants_->IsIdentifierStart(c)) return Token::ILLEGAL;
|
| AddLiteralChar(c);
|
| return ScanIdentifierSuffix(&literal);
|
| }
|
| @@ -690,7 +688,7 @@
|
| }
|
|
|
| // Scan the rest of the identifier characters.
|
| - while (ScannerConstants::kIsIdentifierPart.get(c0_)) {
|
| + while (scanner_constants_->IsIdentifierPart(c0_)) {
|
| if (c0_ != '\\') {
|
| uc32 next_char = c0_;
|
| Advance();
|
| @@ -708,11 +706,11 @@
|
|
|
| Token::Value JavaScriptScanner::ScanIdentifierSuffix(LiteralScope* literal) {
|
| // Scan the rest of the identifier characters.
|
| - while (ScannerConstants::kIsIdentifierPart.get(c0_)) {
|
| + while (scanner_constants_->IsIdentifierPart(c0_)) {
|
| if (c0_ == '\\') {
|
| uc32 c = ScanIdentifierUnicodeEscape();
|
| // Only allow legal identifier part characters.
|
| - if (!ScannerConstants::kIsIdentifierPart.get(c)) return Token::ILLEGAL;
|
| + if (!scanner_constants_->IsIdentifierPart(c)) return Token::ILLEGAL;
|
| AddLiteralChar(c);
|
| } else {
|
| AddLiteralChar(c0_);
|
| @@ -742,10 +740,10 @@
|
| AddLiteralChar('=');
|
|
|
| while (c0_ != '/' || in_character_class) {
|
| - if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false;
|
| + if (scanner_constants_->IsLineTerminator(c0_) || c0_ < 0) return false;
|
| if (c0_ == '\\') { // Escape sequence.
|
| AddLiteralCharAdvance();
|
| - if (ScannerConstants::kIsLineTerminator.get(c0_) || c0_ < 0) return false;
|
| + if (scanner_constants_->IsLineTerminator(c0_) || c0_ < 0) return false;
|
| AddLiteralCharAdvance();
|
| // If the escape allows more characters, i.e., \x??, \u????, or \c?,
|
| // only "safe" characters are allowed (letters, digits, underscore),
|
| @@ -771,7 +769,7 @@
|
| bool JavaScriptScanner::ScanRegExpFlags() {
|
| // Scan regular expression flags.
|
| LiteralScope literal(this);
|
| - while (ScannerConstants::kIsIdentifierPart.get(c0_)) {
|
| + while (scanner_constants_->IsIdentifierPart(c0_)) {
|
| if (c0_ == '\\') {
|
| uc32 c = ScanIdentifierUnicodeEscape();
|
| if (c != static_cast<uc32>(unibrow::Utf8::kBadChar)) {
|
|
|