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

Unified Diff: src/utils.h

Issue 3137037: Ensure that scanner state is correctly reset when an error is encountered. (Closed)
Patch Set: Created 10 years, 4 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
« src/scanner.h ('K') | « src/scanner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index 8eddb1391d15ff1e6fd5db12d81f531eeeaac34a..90fa74f9fb0e43c4ced4e182e4b0263b03a12447 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -560,6 +560,15 @@ class Collector {
return Vector<T>(new_store, total_length);
}
+ // Resets the collector to be empty.
+ virtual void Reset() {
+ for (int i = chunks_.length() - 1; i >= 0; i--) {
+ chunks_.at(i).Dispose();
+ }
+ chunks_.Rewind(0);
+ index_ = 0;
+ }
+
protected:
static const int kMinCapacity = 16;
List<Vector<T> > chunks_;
@@ -632,6 +641,18 @@ class SequenceCollector : public Collector<T> {
this->index_ - sequence_start);
}
+ // Drops the currently added sequence, and all collected elements in it.
+ void DropSequence() {
+ ASSERT(sequence_start_ != kNoSequence);
+ this->index_ = sequence_start_;
+ sequence_start_ = kNoSequence;
+ }
+
+ virtual void Reset() {
+ sequence_start_ = kNoSequence;
+ this->Collector<T>::Reset();
+ }
+
private:
static const int kNoSequence = -1;
int sequence_start_;
« src/scanner.h ('K') | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698