Index: src/objects.cc |
=================================================================== |
--- src/objects.cc (revision 830) |
+++ src/objects.cc (working copy) |
@@ -3501,6 +3501,57 @@ |
} |
+FlatStringReader* FlatStringReader::top_ = NULL; |
+ |
+ |
+FlatStringReader::FlatStringReader(Handle<String> str) |
+ : str_(str.location()), |
Mads Ager (chromium)
2008/11/25 21:09:41
Four space indent. More occurrences below.
Christian Plesner Hansen
2008/11/26 06:49:56
Fixed.
|
+ length_(str->length()), |
+ prev_(top_) { |
+ top_ = this; |
+ RefreshState(); |
+} |
+ |
+ |
+FlatStringReader::FlatStringReader(Vector<const char> input) |
+ : str_(NULL), |
+ is_ascii_(true), |
+ length_(input.length()), |
+ start_(input.start()), |
+ prev_(top_) { |
+ top_ = this; |
+} |
+ |
+ |
+FlatStringReader::~FlatStringReader() { |
+ ASSERT_EQ(top_, this); |
+ top_ = prev_; |
+} |
+ |
+ |
+void FlatStringReader::RefreshState() { |
+ if (str_ == NULL) return; |
+ Handle<String> str(str_); |
+ StringShape shape(*str); |
+ ASSERT(str->IsFlat(shape)); |
+ is_ascii_ = shape.IsAsciiRepresentation(); |
+ if (is_ascii_) { |
+ start_ = str->ToAsciiVector().start(); |
+ } else { |
+ start_ = str->ToUC16Vector().start(); |
+ } |
+} |
+ |
+ |
+void FlatStringReader::PostGarbageCollectionProcessing() { |
+ FlatStringReader* current = top_; |
+ while (current != NULL) { |
+ current->RefreshState(); |
+ current = current->prev_; |
+ } |
+} |
+ |
+ |
void StringInputBuffer::Seek(unsigned pos) { |
Reset(pos, input_); |
} |