| Index: runtime/vm/scanner.cc
|
| diff --git a/runtime/vm/scanner.cc b/runtime/vm/scanner.cc
|
| index cd8abf52caec381b3fd507429e6290fbc8c5e4d8..a34439b6ab3ad33e65ab9c9932c227147dc92b80 100644
|
| --- a/runtime/vm/scanner.cc
|
| +++ b/runtime/vm/scanner.cc
|
| @@ -23,10 +23,10 @@ namespace dart {
|
| class ScanContext : public ZoneAllocated {
|
| public:
|
| explicit ScanContext(Scanner* scanner)
|
| - : next_(scanner->saved_context_),
|
| - string_delimiter_(scanner->string_delimiter_),
|
| - string_is_multiline_(scanner->string_is_multiline_),
|
| - brace_level_(scanner->brace_level_) {}
|
| + : next_(scanner->saved_context_),
|
| + string_delimiter_(scanner->string_delimiter_),
|
| + string_is_multiline_(scanner->string_is_multiline_),
|
| + brace_level_(scanner->brace_level_) {}
|
|
|
| void CopyTo(Scanner* scanner) {
|
| scanner->string_delimiter_ = string_delimiter_;
|
| @@ -100,7 +100,7 @@ void Scanner::ErrorMsg(const char* msg) {
|
|
|
|
|
| void Scanner::PushContext() {
|
| - ScanContext* ctx = new(Z) ScanContext(this);
|
| + ScanContext* ctx = new (Z) ScanContext(this);
|
| saved_context_ = ctx;
|
| string_delimiter_ = '\0';
|
| string_is_multiline_ = false;
|
| @@ -146,9 +146,8 @@ bool Scanner::IsNumberStart(int32_t ch) {
|
|
|
|
|
| bool Scanner::IsHexDigit(int32_t c) {
|
| - return IsDecimalDigit(c)
|
| - || (('A' <= c) && (c <= 'F'))
|
| - || (('a' <= c) && (c <= 'f'));
|
| + return IsDecimalDigit(c) || (('A' <= c) && (c <= 'F')) ||
|
| + (('a' <= c) && (c <= 'f'));
|
| }
|
|
|
|
|
| @@ -169,7 +168,7 @@ bool Scanner::IsIdent(const String& str) {
|
| if (str.Length() == 0 || !IsIdentStartChar(CallCharAt()(str, 0))) {
|
| return false;
|
| }
|
| - for (int i = 1; i < str.Length(); i++) {
|
| + for (int i = 1; i < str.Length(); i++) {
|
| if (!IsIdentChar(CallCharAt()(str, i))) {
|
| return false;
|
| }
|
| @@ -192,16 +191,13 @@ bool Scanner::IsValidInteger(const String& str,
|
| s.Scan();
|
| tokens[2] = s.current_token();
|
|
|
| - if ((tokens[0].kind == Token::kINTEGER) &&
|
| - (tokens[1].kind == Token::kEOS)) {
|
| + if ((tokens[0].kind == Token::kINTEGER) && (tokens[1].kind == Token::kEOS)) {
|
| *is_positive = true;
|
| *value = tokens[0].literal;
|
| return true;
|
| }
|
| - if (((tokens[0].kind == Token::kADD) ||
|
| - (tokens[0].kind == Token::kSUB)) &&
|
| - (tokens[1].kind == Token::kINTEGER) &&
|
| - (tokens[2].kind == Token::kEOS)) {
|
| + if (((tokens[0].kind == Token::kADD) || (tokens[0].kind == Token::kSUB)) &&
|
| + (tokens[1].kind == Token::kINTEGER) && (tokens[2].kind == Token::kEOS)) {
|
| // Check there is no space between "+/-" and number.
|
| if ((tokens[0].offset + 1) != tokens[1].offset) {
|
| return false;
|
| @@ -291,7 +287,7 @@ void Scanner::ConsumeBlockComment() {
|
| }
|
| }
|
| current_token_.kind =
|
| - (nesting_level == 0) ? Token::kWHITESP : Token::kILLEGAL;
|
| + (nesting_level == 0) ? Token::kWHITESP : Token::kILLEGAL;
|
| }
|
|
|
|
|
| @@ -317,7 +313,7 @@ void Scanner::ScanIdentChars(bool allow_dollar) {
|
| int char_pos = 1;
|
| while ((char_pos < ident_length) &&
|
| (keyword[char_pos] ==
|
| - CallCharAt()(source_, ident_pos + char_pos))) {
|
| + CallCharAt()(source_, ident_pos + char_pos))) {
|
| char_pos++;
|
| }
|
| if (char_pos == ident_length) {
|
| @@ -374,8 +370,7 @@ void Scanner::ScanNumber(bool dec_point_seen) {
|
| }
|
| }
|
| if (((c0_ == 'e') || (c0_ == 'E')) &&
|
| - (IsDecimalDigit(LookaheadChar(1)) ||
|
| - (LookaheadChar(1) == '-') ||
|
| + (IsDecimalDigit(LookaheadChar(1)) || (LookaheadChar(1) == '-') ||
|
| (LookaheadChar(1) == '+'))) {
|
| Recognize(Token::kDOUBLE);
|
| if ((c0_ == '-') || (c0_ == '+')) {
|
| @@ -544,8 +539,8 @@ void Scanner::ScanLiteralStringChars(bool is_raw, bool remove_whitespace) {
|
| // Scanned a string piece.
|
| ASSERT(string_chars.data() != NULL);
|
| // Strings are canonicalized: Allocate a symbol.
|
| - current_token_.literal = &String::ZoneHandle(Z,
|
| - Symbols::FromUTF32(T, string_chars.data(), string_chars.length()));
|
| + current_token_.literal = &String::ZoneHandle(
|
| + Z, Symbols::FromUTF32(T, string_chars.data(), string_chars.length()));
|
| // Preserve error tokens.
|
| if (current_token_.kind != Token::kERROR) {
|
| current_token_.kind = Token::kSTRING;
|
| @@ -553,9 +548,8 @@ void Scanner::ScanLiteralStringChars(bool is_raw, bool remove_whitespace) {
|
| return;
|
| } else if (c0_ == string_delimiter_) {
|
| // Check if we are at the end of the string literal.
|
| - if (!string_is_multiline_ ||
|
| - ((LookaheadChar(1) == string_delimiter_) &&
|
| - (LookaheadChar(2) == string_delimiter_))) {
|
| + if (!string_is_multiline_ || ((LookaheadChar(1) == string_delimiter_) &&
|
| + (LookaheadChar(2) == string_delimiter_))) {
|
| if (string_is_multiline_) {
|
| ReadChar(); // Skip two string delimiters.
|
| ReadChar();
|
| @@ -567,9 +561,9 @@ void Scanner::ScanLiteralStringChars(bool is_raw, bool remove_whitespace) {
|
| Recognize(Token::kSTRING);
|
| ASSERT(string_chars.data() != NULL);
|
| // Strings are canonicalized: Allocate a symbol.
|
| - current_token_.literal = &String::ZoneHandle(Z,
|
| - Symbols::FromUTF32(T,
|
| - string_chars.data(), string_chars.length()));
|
| + current_token_.literal =
|
| + &String::ZoneHandle(Z, Symbols::FromUTF32(T, string_chars.data(),
|
| + string_chars.length()));
|
| }
|
| EndStringLiteral();
|
| return;
|
| @@ -877,8 +871,8 @@ void Scanner::Scan() {
|
| char utf8_char[5];
|
| int len = Utf8::Encode(c0_, utf8_char);
|
| utf8_char[len] = '\0';
|
| - OS::SNPrint(msg, sizeof(msg),
|
| - "unexpected character: '%s' (U+%04X)\n", utf8_char, c0_);
|
| + OS::SNPrint(msg, sizeof(msg), "unexpected character: '%s' (U+%04X)\n",
|
| + utf8_char, c0_);
|
| ErrorMsg(msg);
|
| ReadChar();
|
| }
|
| @@ -893,8 +887,7 @@ void Scanner::ScanAll(TokenCollector* collector) {
|
| Scan();
|
| bool inserted_new_lines = false;
|
| for (intptr_t diff = current_token_.position.line - prev_token_line_;
|
| - diff > 0;
|
| - diff--) {
|
| + diff > 0; diff--) {
|
| newline_token_.position.line = current_token_.position.line - diff;
|
| collector->AddToken(newline_token_);
|
| inserted_new_lines = true;
|
| @@ -902,11 +895,11 @@ void Scanner::ScanAll(TokenCollector* collector) {
|
| if (inserted_new_lines &&
|
| ((current_token_.kind == Token::kINTERPOL_VAR) ||
|
| (current_token_.kind == Token::kINTERPOL_START))) {
|
| - // NOTE: If this changes, be sure to update
|
| - // Script::GenerateLineNumberArray to stay in sync.
|
| - empty_string_token_.position.line = current_token_.position.line;
|
| - collector->AddToken(empty_string_token_);
|
| - }
|
| + // NOTE: If this changes, be sure to update
|
| + // Script::GenerateLineNumberArray to stay in sync.
|
| + empty_string_token_.position.line = current_token_.position.line;
|
| + collector->AddToken(empty_string_token_);
|
| + }
|
| collector->AddToken(current_token_);
|
| prev_token_line_ = current_token_.position.line;
|
| } while (current_token_.kind != Token::kEOS);
|
| @@ -921,8 +914,7 @@ void Scanner::ScanTo(intptr_t token_index) {
|
| Scan();
|
| bool inserted_new_lines = false;
|
| for (intptr_t diff = current_token_.position.line - prev_token_line_;
|
| - diff > 0;
|
| - diff--) {
|
| + diff > 0; diff--) {
|
| // Advance the index to account for tokens added in ScanAll.
|
| index++;
|
| inserted_new_lines = true;
|
| @@ -930,8 +922,8 @@ void Scanner::ScanTo(intptr_t token_index) {
|
| if (inserted_new_lines &&
|
| ((current_token_.kind == Token::kINTERPOL_VAR) ||
|
| (current_token_.kind == Token::kINTERPOL_START))) {
|
| - // Advance the index to account for tokens added in ScanAll.
|
| - index++;
|
| + // Advance the index to account for tokens added in ScanAll.
|
| + index++;
|
| }
|
| index++;
|
| prev_token_line_ = current_token_.position.line;
|
|
|