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

Unified Diff: runtime/vm/object.h

Issue 383523005: Specify descriptor kind to iterate on. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 38124)
+++ runtime/vm/object.h (working copy)
@@ -3034,24 +3034,46 @@
class Iterator : ValueObject {
public:
- explicit Iterator(const PcDescriptors& descriptors)
- : descriptors_(descriptors), current_ix_(0) {}
+ Iterator(const PcDescriptors& descriptors, intptr_t kind_mask)
+ : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) {
+ MoveToMatching();
+ }
+ bool HasNext() const { return current_ix_ < descriptors_.Length(); }
+
+ const RawPcDescriptors::PcDescriptorRec& Next() {
+ ASSERT(HasNext());
+ const RawPcDescriptors::PcDescriptorRec* res =
+ descriptors_.recAt(current_ix_++);
+ MoveToMatching();
+ return *res;
+ }
+
+ private:
+ friend class PcDescriptors;
+
// For nested iterations, starting at element after.
explicit Iterator(const Iterator& iter)
: ValueObject(),
descriptors_(iter.descriptors_),
+ kind_mask_(iter.kind_mask_),
current_ix_(iter.current_ix_) {}
- bool HasNext() { return current_ix_ < descriptors_.Length(); }
-
- const RawPcDescriptors::PcDescriptorRec& Next() {
- ASSERT(HasNext());
- return *descriptors_.recAt(current_ix_++);
+ // Moves to record that matches kind_mask_.
+ void MoveToMatching() {
+ while (current_ix_ < descriptors_.Length()) {
+ const RawPcDescriptors::PcDescriptorRec& rec =
+ *descriptors_.recAt(current_ix_);
+ if ((rec.kind_ & kind_mask_) != 0) {
+ return; // Current is valid.
+ } else {
+ ++current_ix_;
+ }
+ }
}
- private:
const PcDescriptors& descriptors_;
+ const intptr_t kind_mask_;
intptr_t current_ix_;
};
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698