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 #ifndef VM_SYMBOLS_H_ | 5 #ifndef VM_SYMBOLS_H_ |
6 #define VM_SYMBOLS_H_ | 6 #define VM_SYMBOLS_H_ |
7 | 7 |
8 #include "vm/object.h" | 8 #include "vm/object.h" |
9 #include "vm/snapshot_ids.h" | 9 #include "vm/snapshot_ids.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 // Forward declarations. | 13 // Forward declarations. |
14 class Isolate; | 14 class Isolate; |
15 class ObjectPointerVisitor; | 15 class ObjectPointerVisitor; |
16 | 16 |
17 // One-character symbols are added implicitly. | 17 // One-character symbols are added implicitly. |
18 #define PREDEFINED_SYMBOLS_LIST(V) \ | 18 #define PREDEFINED_SYMBOLS_LIST(V) \ |
19 V(Empty, "") \ | |
20 V(EqualOperator, "==") \ | 19 V(EqualOperator, "==") \ |
21 V(GreaterEqualOperator, ">=") \ | 20 V(GreaterEqualOperator, ">=") \ |
22 V(LessEqualOperator, "<=") \ | 21 V(LessEqualOperator, "<=") \ |
23 V(LeftShiftOperator, "<<") \ | 22 V(LeftShiftOperator, "<<") \ |
24 V(RightShiftOperator, ">>") \ | 23 V(RightShiftOperator, ">>") \ |
25 V(TruncDivOperator, "~/") \ | 24 V(TruncDivOperator, "~/") \ |
26 V(UnaryMinus, "unary-") \ | 25 V(UnaryMinus, "unary-") \ |
27 V(Identical, "identical") \ | 26 V(Identical, "identical") \ |
28 V(Length, "length") \ | 27 V(Length, "length") \ |
29 V(_setLength, "_setLength") \ | 28 V(_setLength, "_setLength") \ |
30 V(IndexToken, "[]") \ | 29 V(IndexToken, "[]") \ |
31 V(AssignIndexToken, "[]=") \ | 30 V(AssignIndexToken, "[]=") \ |
32 V(TopLevel, "::") \ | 31 V(TopLevel, "::") \ |
33 V(DefaultLabel, ":L") \ | 32 V(DefaultLabel, ":L") \ |
34 V(This, "this") \ | |
35 V(Other, "other") \ | 33 V(Other, "other") \ |
36 V(Super, "super") \ | |
37 V(Call, "call") \ | 34 V(Call, "call") \ |
38 V(Current, "current") \ | 35 V(Current, "current") \ |
39 V(MoveNext, "moveNext") \ | 36 V(MoveNext, "moveNext") \ |
40 V(IsYieldEach, "isYieldEach") \ | 37 V(IsYieldEach, "isYieldEach") \ |
41 V(Value, "value") \ | 38 V(Value, "value") \ |
42 V(_EnumHelper, "_EnumHelper") \ | 39 V(_EnumHelper, "_EnumHelper") \ |
43 V(_SyncIterable, "_SyncIterable") \ | 40 V(_SyncIterable, "_SyncIterable") \ |
44 V(_SyncIterableConstructor, "_SyncIterable.") \ | 41 V(_SyncIterableConstructor, "_SyncIterable.") \ |
45 V(_SyncIterator, "_SyncIterator") \ | 42 V(_SyncIterator, "_SyncIterator") \ |
46 V(IteratorParameter, ":iterator") \ | 43 V(IteratorParameter, ":iterator") \ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 V(CurrentContextVar, ":current_context_var") \ | 82 V(CurrentContextVar, ":current_context_var") \ |
86 V(SavedTryContextVar, ":saved_try_context_var") \ | 83 V(SavedTryContextVar, ":saved_try_context_var") \ |
87 V(ExceptionParameter, ":exception") \ | 84 V(ExceptionParameter, ":exception") \ |
88 V(StackTraceParameter, ":stack_trace") \ | 85 V(StackTraceParameter, ":stack_trace") \ |
89 V(ExceptionVar, ":exception_var") \ | 86 V(ExceptionVar, ":exception_var") \ |
90 V(StackTraceVar, ":stack_trace_var") \ | 87 V(StackTraceVar, ":stack_trace_var") \ |
91 V(SavedExceptionVar, ":saved_exception_var") \ | 88 V(SavedExceptionVar, ":saved_exception_var") \ |
92 V(SavedStackTraceVar, ":saved_stack_trace_var") \ | 89 V(SavedStackTraceVar, ":saved_stack_trace_var") \ |
93 V(ListLiteralElement, "list literal element") \ | 90 V(ListLiteralElement, "list literal element") \ |
94 V(ForInIter, ":for-in-iter") \ | 91 V(ForInIter, ":for-in-iter") \ |
95 V(Library, "library") \ | |
96 V(LoadLibrary, "loadLibrary") \ | 92 V(LoadLibrary, "loadLibrary") \ |
97 V(_LibraryPrefix, "_LibraryPrefix") \ | 93 V(_LibraryPrefix, "_LibraryPrefix") \ |
98 V(On, "on") \ | 94 V(On, "on") \ |
99 V(Of, "of") \ | 95 V(Of, "of") \ |
100 V(Deferred, "deferred") \ | 96 V(Deferred, "deferred") \ |
101 V(Show, "show") \ | 97 V(Show, "show") \ |
102 V(Hide, "hide") \ | 98 V(Hide, "hide") \ |
103 V(Async, "async") \ | 99 V(Async, "async") \ |
104 V(Sync, "sync") \ | 100 V(Sync, "sync") \ |
105 V(YieldKw, "yield") \ | 101 V(YieldKw, "yield") \ |
(...skipping 16 matching lines...) Expand all Loading... |
122 V(CompleterComplete, "complete") \ | 118 V(CompleterComplete, "complete") \ |
123 V(CompleterCompleteError, "completeError") \ | 119 V(CompleterCompleteError, "completeError") \ |
124 V(CompleterConstructor, "Completer.") \ | 120 V(CompleterConstructor, "Completer.") \ |
125 V(CompleterFuture, "future") \ | 121 V(CompleterFuture, "future") \ |
126 V(StreamIterator, "StreamIterator") \ | 122 V(StreamIterator, "StreamIterator") \ |
127 V(StreamIteratorConstructor, "StreamIterator.") \ | 123 V(StreamIteratorConstructor, "StreamIterator.") \ |
128 V(Native, "native") \ | 124 V(Native, "native") \ |
129 V(Class, "Class") \ | 125 V(Class, "Class") \ |
130 V(Null, "Null") \ | 126 V(Null, "Null") \ |
131 V(Dynamic, "dynamic") \ | 127 V(Dynamic, "dynamic") \ |
132 V(Void, "void") \ | |
133 V(UnresolvedClass, "UnresolvedClass") \ | 128 V(UnresolvedClass, "UnresolvedClass") \ |
134 V(Type, "_Type") \ | 129 V(Type, "_Type") \ |
135 V(TypeRef, "_TypeRef") \ | 130 V(TypeRef, "_TypeRef") \ |
136 V(TypeParameter, "_TypeParameter") \ | 131 V(TypeParameter, "_TypeParameter") \ |
137 V(BoundedType, "_BoundedType") \ | 132 V(BoundedType, "_BoundedType") \ |
138 V(MixinAppType, "_MixinAppType") \ | 133 V(MixinAppType, "_MixinAppType") \ |
139 V(TypeArguments, "TypeArguments") \ | 134 V(TypeArguments, "TypeArguments") \ |
140 V(Patch, "patch") \ | 135 V(Patch, "patch") \ |
141 V(PatchClass, "PatchClass") \ | 136 V(PatchClass, "PatchClass") \ |
142 V(Function, "Function") \ | 137 V(Function, "Function") \ |
(...skipping 26 matching lines...) Expand all Loading... |
169 V(LanguageError, "LanguageError") \ | 164 V(LanguageError, "LanguageError") \ |
170 V(UnhandledException, "UnhandledException") \ | 165 V(UnhandledException, "UnhandledException") \ |
171 V(UnwindError, "UnwindError") \ | 166 V(UnwindError, "UnwindError") \ |
172 V(IntegerImplementation, "_IntegerImplementation") \ | 167 V(IntegerImplementation, "_IntegerImplementation") \ |
173 V(Number, "num") \ | 168 V(Number, "num") \ |
174 V(_Smi, "_Smi") \ | 169 V(_Smi, "_Smi") \ |
175 V(_Mint, "_Mint") \ | 170 V(_Mint, "_Mint") \ |
176 V(_Bigint, "_Bigint") \ | 171 V(_Bigint, "_Bigint") \ |
177 V(_Double, "_Double") \ | 172 V(_Double, "_Double") \ |
178 V(Bool, "bool") \ | 173 V(Bool, "bool") \ |
179 V(True, "true") \ | |
180 V(False, "false") \ | |
181 V(_List, "_List") \ | 174 V(_List, "_List") \ |
182 V(_ListFactory, "_List.") \ | 175 V(_ListFactory, "_List.") \ |
183 V(_GrowableList, "_GrowableList") \ | 176 V(_GrowableList, "_GrowableList") \ |
184 V(_GrowableListFactory, "_GrowableList.") \ | 177 V(_GrowableListFactory, "_GrowableList.") \ |
185 V(_GrowableListWithData, "_GrowableList.withData") \ | 178 V(_GrowableListWithData, "_GrowableList.withData") \ |
186 V(_ImmutableList, "_ImmutableList") \ | 179 V(_ImmutableList, "_ImmutableList") \ |
187 V(_LinkedHashMap, "_InternalLinkedHashMap") \ | 180 V(_LinkedHashMap, "_InternalLinkedHashMap") \ |
188 V(_String, "String") \ | 181 V(_String, "String") \ |
189 V(OneByteString, "_OneByteString") \ | 182 V(OneByteString, "_OneByteString") \ |
190 V(TwoByteString, "_TwoByteString") \ | 183 V(TwoByteString, "_TwoByteString") \ |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 static const String& Percent() { | 498 static const String& Percent() { |
506 return *(symbol_handles_[kNullCharId + '%']); | 499 return *(symbol_handles_[kNullCharId + '%']); |
507 } | 500 } |
508 static const String& Caret() { | 501 static const String& Caret() { |
509 return *(symbol_handles_[kNullCharId + '^']); | 502 return *(symbol_handles_[kNullCharId + '^']); |
510 } | 503 } |
511 static const String& Tilde() { | 504 static const String& Tilde() { |
512 return *(symbol_handles_[kNullCharId + '~']); | 505 return *(symbol_handles_[kNullCharId + '~']); |
513 } | 506 } |
514 | 507 |
| 508 static const String& Empty() { return *(symbol_handles_[kKwTableStart]); } |
| 509 static const String& False() { return *(symbol_handles_[kFALSEId]); } |
| 510 static const String& Library() { return *(symbol_handles_[kLIBRARYId]); } |
| 511 static const String& Super() { return *(symbol_handles_[kSUPERId]); } |
| 512 static const String& This() { return *(symbol_handles_[kTHISId]); } |
| 513 static const String& True() { return *(symbol_handles_[kTRUEId]); } |
| 514 static const String& Void() { return *(symbol_handles_[kVOIDId]); } |
| 515 |
515 // Access methods for symbol handles stored in the vm isolate. | 516 // Access methods for symbol handles stored in the vm isolate. |
516 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol, literal) \ | 517 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol, literal) \ |
517 static const String& symbol() { return *(symbol_handles_[k##symbol##Id]); } | 518 static const String& symbol() { return *(symbol_handles_[k##symbol##Id]); } |
518 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) | 519 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) |
519 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR | 520 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR |
520 | 521 |
521 // Get symbol for scanner keyword. | 522 // Get symbol for scanner keyword. |
522 static const String& Keyword(Token::Kind keyword); | 523 static const String& Keyword(Token::Kind keyword); |
523 | 524 |
524 // Initialize frequently used symbols in the vm isolate. | 525 // Initialize frequently used symbols in the vm isolate. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 friend class SnapshotReader; | 601 friend class SnapshotReader; |
601 friend class SnapshotWriter; | 602 friend class SnapshotWriter; |
602 friend class ApiMessageReader; | 603 friend class ApiMessageReader; |
603 | 604 |
604 DISALLOW_COPY_AND_ASSIGN(Symbols); | 605 DISALLOW_COPY_AND_ASSIGN(Symbols); |
605 }; | 606 }; |
606 | 607 |
607 } // namespace dart | 608 } // namespace dart |
608 | 609 |
609 #endif // VM_SYMBOLS_H_ | 610 #endif // VM_SYMBOLS_H_ |
OLD | NEW |