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

Unified Diff: runtime/vm/scanner.cc

Issue 72923002: Add Dart keyword symbols to the VM isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/scanner.cc
===================================================================
--- runtime/vm/scanner.cc (revision 30276)
+++ runtime/vm/scanner.cc (working copy)
@@ -5,6 +5,7 @@
#include "vm/scanner.h"
#include "platform/assert.h"
+#include "vm/dart.h"
#include "vm/flags.h"
#include "vm/object.h"
#include "vm/object_store.h"
@@ -17,30 +18,10 @@
DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens.");
-void Scanner::InitKeywordTable() {
- ObjectStore* object_store = Isolate::Current()->object_store();
- keyword_symbol_table_ = object_store->keyword_symbols();
- if (keyword_symbol_table_.IsNull()) {
- object_store->InitKeywordTable();
- keyword_symbol_table_ = object_store->keyword_symbols();
- ASSERT(!keyword_symbol_table_.IsNull());
- String& symbol = String::Handle();
- for (int i = 0; i < Token::numKeywords; i++) {
- Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i);
- symbol = Symbols::New(Token::Str(token));
- keyword_symbol_table_.SetAt(i, symbol);
- }
- }
- for (int i = 0; i < Token::numKeywords; i++) {
- Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i);
- keywords_[i].kind = token;
- keywords_[i].keyword_chars = Token::Str(token);
- keywords_[i].keyword_len = strlen(Token::Str(token));
- keywords_[i].keyword_symbol = NULL;
- }
-}
+Scanner::KeywordTable Scanner::keywords_[Token::numKeywords];
+
void Scanner::Reset() {
// Non-changing newline properties.
newline_token_.kind = Token::kNEWLINE;
@@ -76,10 +57,8 @@
: source_(src),
source_length_(src.Length()),
saved_context_(NULL),
- private_key_(String::ZoneHandle(private_key.raw())),
- keyword_symbol_table_(Array::ZoneHandle()) {
+ private_key_(String::ZoneHandle(private_key.raw())) {
Reset();
- InitKeywordTable();
}
Scanner::~Scanner() {
@@ -321,12 +300,6 @@
char_pos++;
}
if (char_pos == ident_length) {
- if (keywords_[i].keyword_symbol == NULL) {
- String& symbol = String::ZoneHandle();
- symbol ^= keyword_symbol_table_.At(i);
- ASSERT(!symbol.IsNull());
- keywords_[i].keyword_symbol = &symbol;
- }
current_token_.literal = keywords_[i].keyword_symbol;
current_token_.kind = keywords_[i].kind;
return;
@@ -974,6 +947,14 @@
void Scanner::InitOnce() {
+ ASSERT(Isolate::Current() == Dart::vm_isolate());
+ for (int i = 0; i < Token::numKeywords; i++) {
+ Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i);
+ keywords_[i].kind = token;
+ keywords_[i].keyword_chars = Token::Str(token);
+ keywords_[i].keyword_len = strlen(Token::Str(token));
+ keywords_[i].keyword_symbol = &Symbols::Keyword(token);
+ }
}
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698