| OLD | NEW |
| 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #ifndef SRC_VM_WEAK_POINTER_H_ | 5 #ifndef SRC_VM_WEAK_POINTER_H_ |
| 6 #define SRC_VM_WEAK_POINTER_H_ | 6 #define SRC_VM_WEAK_POINTER_H_ |
| 7 | 7 |
| 8 namespace fletch { | 8 namespace dartino { |
| 9 | 9 |
| 10 class HeapObject; | 10 class HeapObject; |
| 11 class Space; | 11 class Space; |
| 12 class Heap; | 12 class Heap; |
| 13 class PointerVisitor; | 13 class PointerVisitor; |
| 14 | 14 |
| 15 typedef void (*WeakPointerCallback)(HeapObject* object, Heap* heap); | 15 typedef void (*WeakPointerCallback)(HeapObject* object, Heap* heap); |
| 16 | 16 |
| 17 class WeakPointer { | 17 class WeakPointer { |
| 18 public: | 18 public: |
| 19 WeakPointer(HeapObject* object, WeakPointerCallback callback, | 19 WeakPointer(HeapObject* object, WeakPointerCallback callback, |
| 20 WeakPointer* next); | 20 WeakPointer* next); |
| 21 | 21 |
| 22 static void Process(Space* garbage_space, WeakPointer** pointers, Heap* heap); | 22 static void Process(Space* garbage_space, WeakPointer** pointers, Heap* heap); |
| 23 static void ForceCallbacks(WeakPointer** pointers, Heap* heap); | 23 static void ForceCallbacks(WeakPointer** pointers, Heap* heap); |
| 24 static void Remove(WeakPointer** pointers, HeapObject* object); | 24 static void Remove(WeakPointer** pointers, HeapObject* object); |
| 25 static void PrependWeakPointers(WeakPointer** pointers, | 25 static void PrependWeakPointers(WeakPointer** pointers, |
| 26 WeakPointer* to_be_prepended); | 26 WeakPointer* to_be_prepended); |
| 27 static void Visit(WeakPointer* pointers, PointerVisitor* visitor); | 27 static void Visit(WeakPointer* pointers, PointerVisitor* visitor); |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 HeapObject* object_; | 30 HeapObject* object_; |
| 31 WeakPointerCallback callback_; | 31 WeakPointerCallback callback_; |
| 32 WeakPointer* prev_; | 32 WeakPointer* prev_; |
| 33 WeakPointer* next_; | 33 WeakPointer* next_; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace fletch | 36 } // namespace dartino |
| 37 | 37 |
| 38 #endif // SRC_VM_WEAK_POINTER_H_ | 38 #endif // SRC_VM_WEAK_POINTER_H_ |
| OLD | NEW |