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

Unified Diff: src/scanner.h

Issue 640193002: Allow identifier code points from supplementary multilingual planes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/char-predicates.cc ('k') | test/intl/general/smp-identifier.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.h
diff --git a/src/scanner.h b/src/scanner.h
index aeadf9da23b411c966790f6e699ad04e32fcd9b9..d40c6266b729b7edc5a97b1e4057de42a93a0d04 100644
--- a/src/scanner.h
+++ b/src/scanner.h
@@ -212,9 +212,17 @@ class LiteralBuffer {
}
ConvertToTwoByte();
}
- DCHECK(code_unit < 0x10000u);
- *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
- position_ += kUC16Size;
+ if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
+ *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
+ position_ += kUC16Size;
+ } else {
+ *reinterpret_cast<uint16_t*>(&backing_store_[position_]) =
+ unibrow::Utf16::LeadSurrogate(code_unit);
+ position_ += kUC16Size;
+ *reinterpret_cast<uint16_t*>(&backing_store_[position_]) =
+ unibrow::Utf16::TrailSurrogate(code_unit);
+ position_ += kUC16Size;
+ }
}
bool is_one_byte() const { return is_one_byte_; }
@@ -519,9 +527,25 @@ class Scanner {
}
// Low-level scanning support.
- void Advance() { c0_ = source_->Advance(); }
+ void Advance() {
+ c0_ = source_->Advance();
+ if (unibrow::Utf16::IsLeadSurrogate(c0_)) {
marja 2015/01/29 15:39:38 Looks like code load doesn't like adding this bran
+ uc32 c1 = source_->Advance();
+ if (!unibrow::Utf16::IsTrailSurrogate(c1)) {
+ source_->PushBack(c1);
+ } else {
+ c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1);
+ }
+ }
+ }
+
void PushBack(uc32 ch) {
- source_->PushBack(c0_);
+ if (ch > static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
+ source_->PushBack(unibrow::Utf16::TrailSurrogate(c0_));
+ source_->PushBack(unibrow::Utf16::LeadSurrogate(c0_));
+ } else {
+ source_->PushBack(c0_);
+ }
c0_ = ch;
}
« no previous file with comments | « src/char-predicates.cc ('k') | test/intl/general/smp-identifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698