| 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/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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 i++; | 308 i++; |
| 309 } | 309 } |
| 310 | 310 |
| 311 // We did not read a keyword. | 311 // We did not read a keyword. |
| 312 current_token_.kind = Token::kIDENT; | 312 current_token_.kind = Token::kIDENT; |
| 313 String& literal = | 313 String& literal = |
| 314 String::ZoneHandle(Symbols::New(source_, ident_pos, ident_length)); | 314 String::ZoneHandle(Symbols::New(source_, ident_pos, ident_length)); |
| 315 if (ident_char0 == kPrivateIdentifierStart) { | 315 if (ident_char0 == Library::kPrivateIdentifierStart) { |
| 316 // Private identifiers are mangled on a per library basis. | 316 // Private identifiers are mangled on a per library basis. |
| 317 literal = String::Concat(literal, private_key_); | 317 literal = String::Concat(literal, private_key_); |
| 318 literal = Symbols::New(literal); | 318 literal = Symbols::New(literal); |
| 319 } | 319 } |
| 320 current_token_.literal = &literal; | 320 current_token_.literal = &literal; |
| 321 } | 321 } |
| 322 | 322 |
| 323 | 323 |
| 324 // Parse integer or double number literal of format: | 324 // Parse integer or double number literal of format: |
| 325 // NUMBER = INTEGER | DOUBLE | 325 // NUMBER = INTEGER | DOUBLE |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 if (currentLine != td.position.line) { | 925 if (currentLine != td.position.line) { |
| 926 currentLine = td.position.line; | 926 currentLine = td.position.line; |
| 927 OS::Print("\n%d (%d): ", currentLine, i); | 927 OS::Print("\n%d (%d): ", currentLine, i); |
| 928 } | 928 } |
| 929 OS::Print("%s ", Token::Name(td.kind)); | 929 OS::Print("%s ", Token::Name(td.kind)); |
| 930 } | 930 } |
| 931 OS::Print("\n"); | 931 OS::Print("\n"); |
| 932 } | 932 } |
| 933 | 933 |
| 934 | 934 |
| 935 RawString* Scanner::AllocatePrivateKey(const Library& library) { | |
| 936 const String& url = String::Handle(library.url()); | |
| 937 intptr_t key_value = url.Hash(); | |
| 938 while (Library::IsKeyUsed(key_value)) { | |
| 939 key_value++; | |
| 940 } | |
| 941 char private_key[32]; | |
| 942 OS::SNPrint(private_key, sizeof(private_key), | |
| 943 "%c%#" Px "", kPrivateKeySeparator, key_value); | |
| 944 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | |
| 945 return result.raw(); | |
| 946 } | |
| 947 | |
| 948 | |
| 949 void Scanner::InitOnce() { | 935 void Scanner::InitOnce() { |
| 950 ASSERT(Isolate::Current() == Dart::vm_isolate()); | 936 ASSERT(Isolate::Current() == Dart::vm_isolate()); |
| 951 for (int i = 0; i < Token::numKeywords; i++) { | 937 for (int i = 0; i < Token::numKeywords; i++) { |
| 952 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i); | 938 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i); |
| 953 keywords_[i].kind = token; | 939 keywords_[i].kind = token; |
| 954 keywords_[i].keyword_chars = Token::Str(token); | 940 keywords_[i].keyword_chars = Token::Str(token); |
| 955 keywords_[i].keyword_len = strlen(Token::Str(token)); | 941 keywords_[i].keyword_len = strlen(Token::Str(token)); |
| 956 keywords_[i].keyword_symbol = &Symbols::Keyword(token); | 942 keywords_[i].keyword_symbol = &Symbols::Keyword(token); |
| 957 } | 943 } |
| 958 } | 944 } |
| 959 | 945 |
| 960 } // namespace dart | 946 } // namespace dart |
| OLD | NEW |