Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Side by Side Diff: runtime/vm/scanner.cc

Issue 1968143002: Small fix in Scanner (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/scanner.h" 5 #include "vm/scanner.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // Script::GenerateLineNumberArray to stay in sync. 907 // Script::GenerateLineNumberArray to stay in sync.
908 empty_string_token_.position.line = current_token_.position.line; 908 empty_string_token_.position.line = current_token_.position.line;
909 token_stream->Add(empty_string_token_); 909 token_stream->Add(empty_string_token_);
910 } 910 }
911 token_stream->Add(current_token_); 911 token_stream->Add(current_token_);
912 prev_token_line_ = current_token_.position.line; 912 prev_token_line_ = current_token_.position.line;
913 } while (current_token_.kind != Token::kEOS); 913 } while (current_token_.kind != Token::kEOS);
914 } 914 }
915 915
916 916
917 void Scanner::ScanTo(TokenPosition token_index) { 917 void Scanner::ScanTo(intptr_t token_index) {
918 TokenPosition index = TokenPosition::kMinSource; 918 ASSERT(token_index >= 0);
919 intptr_t index = 0;
919 Reset(); 920 Reset();
920 do { 921 do {
921 Scan(); 922 Scan();
922 923
923 bool inserted_new_lines = false; 924 bool inserted_new_lines = false;
924 for (intptr_t diff = current_token_.position.line - prev_token_line_; 925 for (intptr_t diff = current_token_.position.line - prev_token_line_;
925 diff > 0; 926 diff > 0;
926 diff--) { 927 diff--) {
927 // Advance the index to account for tokens added in ScanAll. 928 // Advance the index to account for tokens added in ScanAll.
928 index.Next(); 929 index++;
929 inserted_new_lines = true; 930 inserted_new_lines = true;
930 } 931 }
931 932
932 if (inserted_new_lines && 933 if (inserted_new_lines &&
933 ((current_token_.kind == Token::kINTERPOL_VAR) || 934 ((current_token_.kind == Token::kINTERPOL_VAR) ||
934 (current_token_.kind == Token::kINTERPOL_START))) { 935 (current_token_.kind == Token::kINTERPOL_START))) {
935 // Advance the index to account for tokens added in ScanAll. 936 // Advance the index to account for tokens added in ScanAll.
936 index.Next(); 937 index++;
937 } 938 }
938 index.Next(); 939 index++;
939 prev_token_line_ = current_token_.position.line; 940 prev_token_line_ = current_token_.position.line;
940 } while ((token_index >= index) && (current_token_.kind != Token::kEOS)); 941 } while ((token_index >= index) && (current_token_.kind != Token::kEOS));
941 } 942 }
942 943
943 944
944 const Scanner::GrowableTokenStream& Scanner::GetStream() { 945 const Scanner::GrowableTokenStream& Scanner::GetStream() {
945 GrowableTokenStream* ts = new(Z) GrowableTokenStream(128); 946 GrowableTokenStream* ts = new(Z) GrowableTokenStream(128);
946 ScanAll(ts); 947 ScanAll(ts);
947 if (FLAG_print_tokens) { 948 if (FLAG_print_tokens) {
948 Scanner::PrintTokens(*ts); 949 Scanner::PrintTokens(*ts);
(...skipping 29 matching lines...) Expand all
978 keywords_[i].keyword_symbol = &Symbols::Token(token); 979 keywords_[i].keyword_symbol = &Symbols::Token(token);
979 980
980 int ch = keywords_[i].keyword_chars[0] - 'a'; 981 int ch = keywords_[i].keyword_chars[0] - 'a';
981 if (keywords_char_offset_[ch] == Token::kNumKeywords) { 982 if (keywords_char_offset_[ch] == Token::kNumKeywords) {
982 keywords_char_offset_[ch] = i; 983 keywords_char_offset_[ch] = i;
983 } 984 }
984 } 985 }
985 } 986 }
986 987
987 } // namespace dart 988 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698