| OLD | NEW |
| 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/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 void Scanner::ScanTo(intptr_t token_index) { | 888 void Scanner::ScanTo(intptr_t token_index) { |
| 889 int index = 0; | 889 int index = 0; |
| 890 Reset(); | 890 Reset(); |
| 891 do { | 891 do { |
| 892 Scan(); | 892 Scan(); |
| 893 index++; | 893 index++; |
| 894 } while ((token_index >= index) && (current_token_.kind != Token::kEOS)); | 894 } while ((token_index >= index) && (current_token_.kind != Token::kEOS)); |
| 895 } | 895 } |
| 896 | 896 |
| 897 | 897 |
| 898 void Scanner::TokenRangeAtLine(intptr_t line_number, | |
| 899 intptr_t* first_token_index, | |
| 900 intptr_t* last_token_index) { | |
| 901 ASSERT(line_number > 0); | |
| 902 ASSERT((first_token_index != NULL) && (last_token_index != NULL)); | |
| 903 Reset(); | |
| 904 *first_token_index = -1; | |
| 905 *last_token_index = -1; | |
| 906 int token_index = 0; | |
| 907 do { | |
| 908 Scan(); | |
| 909 if (current_token_.position.line >= line_number) { | |
| 910 *first_token_index = token_index; | |
| 911 break; | |
| 912 } | |
| 913 token_index++; | |
| 914 } while (current_token_.kind != Token::kEOS); | |
| 915 if (current_token_.kind == Token::kEOS) { | |
| 916 return; | |
| 917 } | |
| 918 if (current_token_.position.line > line_number) { | |
| 919 // *last_token_index is -1 to signal that the first token is past | |
| 920 // the requested line. | |
| 921 return; | |
| 922 } | |
| 923 ASSERT(current_token_.position.line == line_number); | |
| 924 while ((current_token_.kind != Token::kEOS) && | |
| 925 (current_token_.position.line == line_number)) { | |
| 926 *last_token_index = token_index; | |
| 927 Scan(); | |
| 928 token_index++; | |
| 929 } | |
| 930 } | |
| 931 | |
| 932 | |
| 933 const Scanner::GrowableTokenStream& Scanner::GetStream() { | 898 const Scanner::GrowableTokenStream& Scanner::GetStream() { |
| 934 GrowableTokenStream* ts = new GrowableTokenStream(128); | 899 GrowableTokenStream* ts = new GrowableTokenStream(128); |
| 935 ScanAll(ts); | 900 ScanAll(ts); |
| 936 if (FLAG_print_tokens) { | 901 if (FLAG_print_tokens) { |
| 937 Scanner::PrintTokens(*ts); | 902 Scanner::PrintTokens(*ts); |
| 938 } | 903 } |
| 939 return *ts; | 904 return *ts; |
| 940 } | 905 } |
| 941 | 906 |
| 942 | 907 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 965 "%c%#" Px "", kPrivateKeySeparator, key_value); | 930 "%c%#" Px "", kPrivateKeySeparator, key_value); |
| 966 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 931 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
| 967 return result.raw(); | 932 return result.raw(); |
| 968 } | 933 } |
| 969 | 934 |
| 970 | 935 |
| 971 void Scanner::InitOnce() { | 936 void Scanner::InitOnce() { |
| 972 } | 937 } |
| 973 | 938 |
| 974 } // namespace dart | 939 } // namespace dart |
| OLD | NEW |