| 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/thread.h" | 11 #include "vm/thread.h" |
| 12 #include "vm/token.h" | 12 #include "vm/token.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DEFINE_FLAG(bool, disable_privacy, false, "Disable library privacy."); |
| 16 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); | 17 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); |
| 17 | 18 |
| 18 void Scanner::InitKeywordTable() { | 19 void Scanner::InitKeywordTable() { |
| 19 ObjectStore* object_store = Isolate::Current()->object_store(); | 20 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 20 keyword_symbol_table_ = object_store->keyword_symbols(); | 21 keyword_symbol_table_ = object_store->keyword_symbols(); |
| 21 if (keyword_symbol_table_.IsNull()) { | 22 if (keyword_symbol_table_.IsNull()) { |
| 22 object_store->InitKeywordTable(); | 23 object_store->InitKeywordTable(); |
| 23 keyword_symbol_table_ = object_store->keyword_symbols(); | 24 keyword_symbol_table_ = object_store->keyword_symbols(); |
| 24 ASSERT(!keyword_symbol_table_.IsNull()); | 25 ASSERT(!keyword_symbol_table_.IsNull()); |
| 25 } | 26 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return; | 284 return; |
| 284 } | 285 } |
| 285 } | 286 } |
| 286 i++; | 287 i++; |
| 287 } | 288 } |
| 288 | 289 |
| 289 // We did not read a keyword. | 290 // We did not read a keyword. |
| 290 current_token_.kind = Token::kIDENT; | 291 current_token_.kind = Token::kIDENT; |
| 291 String& literal = | 292 String& literal = |
| 292 String::ZoneHandle(String::NewSymbol(source_, ident_pos, ident_length)); | 293 String::ZoneHandle(String::NewSymbol(source_, ident_pos, ident_length)); |
| 293 if (ident_char0 == kPrivateIdentifierStart) { | 294 if ((ident_char0 == kPrivateIdentifierStart) && !FLAG_disable_privacy) { |
| 294 // Private identifiers are mangled on a per script basis. | 295 // Private identifiers are mangled on a per script basis. |
| 295 literal = String::Concat(literal, private_key_); | 296 literal = String::Concat(literal, private_key_); |
| 296 literal = String::NewSymbol(literal); | 297 literal = String::NewSymbol(literal); |
| 297 } | 298 } |
| 298 current_token_.literal = &literal; | 299 current_token_.literal = &literal; |
| 299 } | 300 } |
| 300 | 301 |
| 301 | 302 |
| 302 // Parse integer or double number literal of format: | 303 // Parse integer or double number literal of format: |
| 303 // NUMBER = INTEGER | DOUBLE | 304 // NUMBER = INTEGER | DOUBLE |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 912 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
| 912 const String& result = String::Handle(String::New(private_key)); | 913 const String& result = String::Handle(String::New(private_key)); |
| 913 return result.raw(); | 914 return result.raw(); |
| 914 } | 915 } |
| 915 | 916 |
| 916 | 917 |
| 917 void Scanner::InitOnce() { | 918 void Scanner::InitOnce() { |
| 918 } | 919 } |
| 919 | 920 |
| 920 } // namespace dart | 921 } // namespace dart |
| OLD | NEW |