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/symbols.h" | 5 #include "vm/symbols.h" |
6 | 6 |
7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
8 #include "vm/handles_impl.h" | 8 #include "vm/handles_impl.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 const char* Symbols::Name(SymbolId symbol) { | 44 const char* Symbols::Name(SymbolId symbol) { |
45 ASSERT((symbol > kIllegal) && (symbol < kNullCharId)); | 45 ASSERT((symbol > kIllegal) && (symbol < kNullCharId)); |
46 return names[symbol]; | 46 return names[symbol]; |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 const String& Symbols::Keyword(Token::Kind keyword) { | 50 const String& Symbols::Keyword(Token::Kind keyword) { |
51 const int kw_index = keyword - Token::kFirstKeyword; | 51 const int kw_index = keyword - Token::kFirstKeyword; |
52 ASSERT((0 <= kw_index) && (kw_index < Token::numKeywords)); | 52 ASSERT((0 <= kw_index) && (kw_index < Token::numKeywords)); |
53 ASSERT(Token::kABSTRACT == Token::kFirstKeyword); | 53 // First keyword symbol is in symbol_handles_[kKwTableStart + 1]. |
54 const intptr_t keyword_id = Symbols::kABSTRACTId + kw_index; | 54 const intptr_t keyword_id = Symbols::kKwTableStart + 1 + kw_index; |
55 ASSERT(symbol_handles_[keyword_id] != NULL); | 55 ASSERT(symbol_handles_[keyword_id] != NULL); |
56 return *symbol_handles_[keyword_id]; | 56 return *symbol_handles_[keyword_id]; |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 void Symbols::InitOnce(Isolate* isolate) { | 60 void Symbols::InitOnce(Isolate* isolate) { |
61 // Should only be run by the vm isolate. | 61 // Should only be run by the vm isolate. |
62 ASSERT(isolate == Dart::vm_isolate()); | 62 ASSERT(isolate == Dart::vm_isolate()); |
63 | 63 |
64 if (FLAG_dump_symbol_stats) { | 64 if (FLAG_dump_symbol_stats) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 473 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
474 ASSERT(IsVMSymbolId(object_id)); | 474 ASSERT(IsVMSymbolId(object_id)); |
475 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 475 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
476 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 476 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
477 return symbol_handles_[i]->raw(); | 477 return symbol_handles_[i]->raw(); |
478 } | 478 } |
479 return Object::null(); | 479 return Object::null(); |
480 } | 480 } |
481 | 481 |
482 } // namespace dart | 482 } // namespace dart |
OLD | NEW |