Reviewers: ,

Message:
I have implemented copy constructor/= operator in StackFrameIterator for easy
stack manipulations but didn't use it.

Just offering it here should anyone need it.

I'm sorry for spam.

Description:
Add a copy constructor to StackFrameIterator

Please review this at http://codereview.chromium.org/1172002

Affected files:
  M src/frames.h
  M src/frames.cc


Index: src/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index 24550a2ed07f0afeadd3d062a245d0ea2a36987e..13762b59988c2b32d72d1167a2f04591b79e1b8f 100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -91,6 +91,25 @@ StackFrameIterator::StackFrameIterator(bool use_top, Address fp, Address sp)
   JavaScriptFrame_.DisableHeapAccess();
 }

+StackFrameIterator::StackFrameIterator(const StackFrameIterator& original)
+    : STACK_FRAME_TYPE_LIST(INITIALIZE_SINGLETON)
+      frame_(NULL) {
+  this->operator=(original);
+}
+
+void StackFrameIterator::operator =(const StackFrameIterator& original) {
+  this->frame_ = this->SingletonFor(original.frame_->type());
+  this->frame_->state_ = original.frame_->state_;
+
+  this->handler_ = original.handler_;
+  this->thread_ = original.thread_;
+  this->fp_ = original.fp_;
+  this->sp_ = original.sp_;
+  this->advance_ = original.advance_;
+  this->JavaScriptFrame_.disable_heap_access_ =
+      original.JavaScriptFrame_.disable_heap_access_;
+}
+
 #undef INITIALIZE_SINGLETON


@@ -171,6 +190,12 @@ StackFrame* StackFrameIterator::SingletonFor(StackFrame::Type type) {
 }


+bool operator==(const StackFrameIterator& one,
+    const StackFrameIterator& another) {
+  return one.frame()->id() == another.frame()->id();
+}
+
+
// -------------------------------------------------------------------------


Index: src/frames.h
diff --git a/src/frames.h b/src/frames.h
index 8cbbc6267978b5929277e97787a684ee3167dcb0..b7821e69c69af79a7cff325203fd3266061a9c8a 100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -510,6 +510,9 @@ class StackFrameIterator BASE_EMBEDDED {
   // Go back to the first frame.
   void Reset();

+  StackFrameIterator(const StackFrameIterator& original);
+  void operator=(const StackFrameIterator& original);
+
  private:
 #define DECLARE_SINGLETON(ignore, type) type type##_;
   STACK_FRAME_TYPE_LIST(DECLARE_SINGLETON)
@@ -536,10 +539,13 @@ class StackFrameIterator BASE_EMBEDDED {

   friend class StackFrame;
   friend class SafeStackFrameIterator;
-  DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
 };


+bool operator==(const StackFrameIterator& one,
+    const StackFrameIterator& another);
+
+
 // Iterator that supports iterating through all JavaScript frames.
 template<typename Iterator>
 class JavaScriptFrameIteratorTemp BASE_EMBEDDED {


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply 
to this email with the words "REMOVE ME" as the subject.

Reply via email to