Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: runtime/vm/symbols.h

Issue 1130843002: Unify processing of Keywords and predefined symbols in the same loop and add accessors for keyword … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/symbols.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 class Symbols : public AllStatic { 389 class Symbols : public AllStatic {
390 public: 390 public:
391 enum { kMaxOneCharCodeSymbol = 0xFF }; 391 enum { kMaxOneCharCodeSymbol = 0xFF };
392 392
393 // List of strings that are pre created in the vm isolate. 393 // List of strings that are pre created in the vm isolate.
394 enum SymbolId { 394 enum SymbolId {
395 kIllegal = 0, 395 kIllegal = 0,
396 396
397 #define DEFINE_SYMBOL_INDEX(symbol, literal) \ 397 #define DEFINE_SYMBOL_INDEX(symbol, literal) \
398 k##symbol##Id, 398 k##symbol##Id,
399 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) 399 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX)
400 #undef DEFINE_SYMBOL_INDEX 400 #undef DEFINE_SYMBOL_INDEX
401 401
402 kKwTableStart, // First keyword at kKwTableStart + 1. 402 kKwTableStart, // First keyword at kKwTableStart + 1.
403 403
404 #define DEFINE_KEYWORD_SYMBOL_INDEX(token, chars, ignore1, ignore2) \ 404 #define DEFINE_KEYWORD_SYMBOL_INDEX(t, s, p, a) \
405 token##Id, 405 t##Id,
406 DART_KEYWORD_LIST(DEFINE_KEYWORD_SYMBOL_INDEX) 406 DART_KEYWORD_LIST(DEFINE_KEYWORD_SYMBOL_INDEX)
407 #undef DEFINE_KEYWORD_SYMBOL_INDEX 407 #undef DEFINE_KEYWORD_SYMBOL_INDEX
408 408
409 kNullCharId, // One char code symbol starts here and takes up 256 entries. 409 kNullCharId, // One char code symbol starts here and takes up 256 entries.
410 kMaxPredefinedId = kNullCharId + kMaxOneCharCodeSymbol + 1, 410 kMaxPredefinedId = kNullCharId + kMaxOneCharCodeSymbol + 1,
411 }; 411 };
412 412
413 // Number of one character symbols being predefined in the predefined_ array. 413 // Number of one character symbols being predefined in the predefined_ array.
414 static const int kNumberOfOneCharCodeSymbols = 414 static const int kNumberOfOneCharCodeSymbols =
415 (kMaxPredefinedId - kNullCharId); 415 (kMaxPredefinedId - kNullCharId);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 507 }
508 508
509 static const String& Empty() { return *(symbol_handles_[kKwTableStart]); } 509 static const String& Empty() { return *(symbol_handles_[kKwTableStart]); }
510 static const String& False() { return *(symbol_handles_[kFALSEId]); } 510 static const String& False() { return *(symbol_handles_[kFALSEId]); }
511 static const String& Library() { return *(symbol_handles_[kLIBRARYId]); } 511 static const String& Library() { return *(symbol_handles_[kLIBRARYId]); }
512 static const String& Super() { return *(symbol_handles_[kSUPERId]); } 512 static const String& Super() { return *(symbol_handles_[kSUPERId]); }
513 static const String& This() { return *(symbol_handles_[kTHISId]); } 513 static const String& This() { return *(symbol_handles_[kTHISId]); }
514 static const String& True() { return *(symbol_handles_[kTRUEId]); } 514 static const String& True() { return *(symbol_handles_[kTRUEId]); }
515 static const String& Void() { return *(symbol_handles_[kVOIDId]); } 515 static const String& Void() { return *(symbol_handles_[kVOIDId]); }
516 516
517 // Access methods for symbol handles stored in the vm isolate. 517 // Access methods for symbol handles stored in the vm isolate for predefined
518 // symbols.
518 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol, literal) \ 519 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol, literal) \
519 static const String& symbol() { return *(symbol_handles_[k##symbol##Id]); } 520 static const String& symbol() { return *(symbol_handles_[k##symbol##Id]); }
520 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) 521 PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR)
522 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR
523
524 // Access methods for symbol handles stored in the vm isolate for keywords.
525 #define DEFINE_SYMBOL_HANDLE_ACCESSOR(t, s, p, a) \
526 static const String& t() { return *(symbol_handles_[t##Id]); }
527 DART_KEYWORD_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR)
521 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR 528 #undef DEFINE_SYMBOL_HANDLE_ACCESSOR
522 529
523 // Get symbol for scanner keyword. 530 // Get symbol for scanner keyword.
524 static const String& Keyword(Token::Kind keyword); 531 static const String& Keyword(Token::Kind keyword);
525 532
526 // Initialize frequently used symbols in the vm isolate. 533 // Initialize frequently used symbols in the vm isolate.
527 static void InitOnce(Isolate* isolate); 534 static void InitOnce(Isolate* isolate);
528 535
529 // Initialize and setup a symbol table for the isolate. 536 // Initialize and setup a symbol table for the isolate.
530 static void SetupSymbolTable(Isolate* isolate); 537 static void SetupSymbolTable(Isolate* isolate);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 friend class SnapshotReader; 609 friend class SnapshotReader;
603 friend class SnapshotWriter; 610 friend class SnapshotWriter;
604 friend class ApiMessageReader; 611 friend class ApiMessageReader;
605 612
606 DISALLOW_COPY_AND_ASSIGN(Symbols); 613 DISALLOW_COPY_AND_ASSIGN(Symbols);
607 }; 614 };
608 615
609 } // namespace dart 616 } // namespace dart
610 617
611 #endif // VM_SYMBOLS_H_ 618 #endif // VM_SYMBOLS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698