| 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" |
| 11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
| 12 #include "vm/thread.h" | 12 #include "vm/thread.h" |
| 13 #include "vm/token.h" | 13 #include "vm/token.h" |
| 14 #include "vm/unicode.h" | 14 #include "vm/unicode.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 DEFINE_FLAG(bool, disable_privacy, false, "Disable library privacy."); | |
| 19 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); | 18 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); |
| 20 | 19 |
| 21 void Scanner::InitKeywordTable() { | 20 void Scanner::InitKeywordTable() { |
| 22 ObjectStore* object_store = Isolate::Current()->object_store(); | 21 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 23 keyword_symbol_table_ = object_store->keyword_symbols(); | 22 keyword_symbol_table_ = object_store->keyword_symbols(); |
| 24 if (keyword_symbol_table_.IsNull()) { | 23 if (keyword_symbol_table_.IsNull()) { |
| 25 object_store->InitKeywordTable(); | 24 object_store->InitKeywordTable(); |
| 26 keyword_symbol_table_ = object_store->keyword_symbols(); | 25 keyword_symbol_table_ = object_store->keyword_symbols(); |
| 27 ASSERT(!keyword_symbol_table_.IsNull()); | 26 ASSERT(!keyword_symbol_table_.IsNull()); |
| 28 String& symbol = String::Handle(); | 27 String& symbol = String::Handle(); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return; | 320 return; |
| 322 } | 321 } |
| 323 } | 322 } |
| 324 i++; | 323 i++; |
| 325 } | 324 } |
| 326 | 325 |
| 327 // We did not read a keyword. | 326 // We did not read a keyword. |
| 328 current_token_.kind = Token::kIDENT; | 327 current_token_.kind = Token::kIDENT; |
| 329 String& literal = | 328 String& literal = |
| 330 String::ZoneHandle(Symbols::New(source_, ident_pos, ident_length)); | 329 String::ZoneHandle(Symbols::New(source_, ident_pos, ident_length)); |
| 331 if ((ident_char0 == kPrivateIdentifierStart) && !FLAG_disable_privacy) { | 330 if (ident_char0 == kPrivateIdentifierStart) { |
| 332 // Private identifiers are mangled on a per script basis. | 331 // Private identifiers are mangled on a per script basis. |
| 333 literal = String::Concat(literal, private_key_); | 332 literal = String::Concat(literal, private_key_); |
| 334 literal = Symbols::New(literal); | 333 literal = Symbols::New(literal); |
| 335 } | 334 } |
| 336 current_token_.literal = &literal; | 335 current_token_.literal = &literal; |
| 337 } | 336 } |
| 338 | 337 |
| 339 | 338 |
| 340 // Parse integer or double number literal of format: | 339 // Parse integer or double number literal of format: |
| 341 // NUMBER = INTEGER | DOUBLE | 340 // NUMBER = INTEGER | DOUBLE |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 "%c%#"Px"", kPrivateKeySeparator, key_value); | 953 "%c%#"Px"", kPrivateKeySeparator, key_value); |
| 955 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 954 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
| 956 return result.raw(); | 955 return result.raw(); |
| 957 } | 956 } |
| 958 | 957 |
| 959 | 958 |
| 960 void Scanner::InitOnce() { | 959 void Scanner::InitOnce() { |
| 961 } | 960 } |
| 962 | 961 |
| 963 } // namespace dart | 962 } // namespace dart |
| OLD | NEW |