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

Unified Diff: runtime/vm/scanner.cc

Issue 11368138: Add some support for the code-point code-unit distinction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New version integrates feedback, adds less to standard String class. Created 8 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
diff --git a/runtime/vm/scanner.cc b/runtime/vm/scanner.cc
index 229dfdf36f0a9b06d37104a6ec56f31b1283bff0..849524559c114b8c3165c96bca78c43eae2eae44 100644
--- a/runtime/vm/scanner.cc
+++ b/runtime/vm/scanner.cc
@@ -162,11 +162,11 @@ bool Scanner::IsIdent(const String& str) {
if (!str.IsOneByteString()) {
return false;
}
- if (str.Length() == 0 || !IsIdentStartChar(str.CharAt(0))) {
+ if (str.Length() == 0 || !IsIdentStartChar(str.CodeUnitAt(0))) {
return false;
}
for (int i = 1; i < str.Length(); i++) {
- if (!IsIdentChar(str.CharAt(i))) {
+ if (!IsIdentChar(str.CodeUnitAt(i))) {
return false;
}
}
@@ -180,7 +180,7 @@ void Scanner::ReadChar() {
newline_seen_ = true;
c0_pos_.line++;
c0_pos_.column = 0;
- if (source_.CharAt(lookahead_pos_) == '\r') {
+ if (source_.CodeUnitAt(lookahead_pos_) == '\r') {
// Replace a sequence of '\r' '\n' with a single '\n'.
if (LookaheadChar(1) == '\n') {
lookahead_pos_++;
@@ -205,7 +205,7 @@ int32_t Scanner::LookaheadChar(int how_many) {
ASSERT(how_many >= 0);
int32_t lookahead_char = '\0';
if (lookahead_pos_ + how_many < source_length_) {
- lookahead_char = source_.CharAt(lookahead_pos_ + how_many);
+ lookahead_char = source_.CodeUnitAt(lookahead_pos_ + how_many);
}
return lookahead_char;
}
@@ -260,7 +260,7 @@ void Scanner::ScanIdentChars(bool allow_dollar) {
ASSERT(allow_dollar || (c0_ != '$'));
int ident_length = 0;
int ident_pos = lookahead_pos_;
- int32_t ident_char0 = source_.CharAt(ident_pos);
+ int32_t ident_char0 = source_.CodeUnitAt(ident_pos);
while (IsIdentChar(c0_) && (allow_dollar || (c0_ != '$'))) {
ReadChar();
ident_length++;
@@ -275,7 +275,8 @@ void Scanner::ScanIdentChars(bool allow_dollar) {
const char* keyword = keywords_[i].keyword_chars;
int char_pos = 0;
while ((char_pos < ident_length) &&
- (keyword[char_pos] == source_.CharAt(ident_pos + char_pos))) {
+ (static_cast<uint32_t>(keyword[char_pos]) ==
+ source_.CodeUnitAt(ident_pos + char_pos))) {
char_pos++;
}
if (char_pos == ident_length) {

Powered by Google App Engine
This is Rietveld 408576698