| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_VISITOR_H_ | 5 #ifndef VM_VISITOR_H_ |
| 6 #define VM_VISITOR_H_ | 6 #define VM_VISITOR_H_ |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 // Forward declarations. | 12 // Forward declarations. |
| 13 class Isolate; |
| 13 class RawObject; | 14 class RawObject; |
| 14 | 15 |
| 15 // An object pointer visitor interface. | 16 // An object pointer visitor interface. |
| 16 class ObjectPointerVisitor { | 17 class ObjectPointerVisitor { |
| 17 public: | 18 public: |
| 19 explicit ObjectPointerVisitor(Isolate* isolate) : isolate_(isolate) {} |
| 18 virtual ~ObjectPointerVisitor() {} | 20 virtual ~ObjectPointerVisitor() {} |
| 19 | 21 |
| 22 Isolate* isolate() const { return isolate_; } |
| 23 |
| 20 // Range of pointers to visit 'first' <= pointer <= 'last'. | 24 // Range of pointers to visit 'first' <= pointer <= 'last'. |
| 21 virtual void VisitPointers(RawObject** first, RawObject** last) = 0; | 25 virtual void VisitPointers(RawObject** first, RawObject** last) = 0; |
| 22 | 26 |
| 23 // len argument is the number of pointers to visit starting from 'p'. | 27 // len argument is the number of pointers to visit starting from 'p'. |
| 24 void VisitPointers(RawObject** p, intptr_t len) { | 28 void VisitPointers(RawObject** p, intptr_t len) { |
| 25 VisitPointers(p, (p + len - 1)); | 29 VisitPointers(p, (p + len - 1)); |
| 26 } | 30 } |
| 27 | 31 |
| 28 void VisitPointer(RawObject** p) { VisitPointers(p , p); } | 32 void VisitPointer(RawObject** p) { VisitPointers(p , p); } |
| 33 |
| 34 private: |
| 35 Isolate* isolate_; |
| 36 |
| 37 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectPointerVisitor); |
| 29 }; | 38 }; |
| 30 | 39 |
| 31 | 40 |
| 32 // An object finder visitor interface. | 41 // An object finder visitor interface. |
| 33 class FindObjectVisitor { | 42 class FindObjectVisitor { |
| 34 public: | 43 public: |
| 44 explicit FindObjectVisitor(Isolate* isolate) : isolate_(isolate) {} |
| 35 virtual ~FindObjectVisitor() {} | 45 virtual ~FindObjectVisitor() {} |
| 36 | 46 |
| 37 // Check if object matches find condition. | 47 // Check if object matches find condition. |
| 38 virtual bool FindObject(RawObject* obj) = 0; | 48 virtual bool FindObject(RawObject* obj) = 0; |
| 49 |
| 50 private: |
| 51 Isolate* isolate_; |
| 52 |
| 53 DISALLOW_IMPLICIT_CONSTRUCTORS(FindObjectVisitor); |
| 39 }; | 54 }; |
| 40 | 55 |
| 41 } // namespace dart | 56 } // namespace dart |
| 42 | 57 |
| 43 #endif // VM_VISITOR_H_ | 58 #endif // VM_VISITOR_H_ |
| OLD | NEW |