-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGCedRef.cpp
More file actions
60 lines (47 loc) · 1.29 KB
/
GCedRef.cpp
File metadata and controls
60 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "GCedRef.h"
#include "Evaluator/Runtime.h"
#include "HeapObject.h"
using namespace Egg;
class Runtime;
GCedRef::GCedRef(Object* object, uintptr_t index)
: _object(object), _index(index)
{}
GCedRef::GCedRef(Object* object)
: _object(object), _index(debugRuntime->assignGCedRefIndex())
{
debugRuntime->registerGCedRef_(this);
}
//GCedRef::GCedRef(GCedRef &other)
// : _runtime(other._runtime), _object(other.get()), index(_runtime->assignRef(other.get()))
//{}
/*
GCedRef::GCedRef(GCedRef&& other) : _object(other._object), _index(other._index) {
debugRuntime->registerGCedRef_(this);
other._object = (Object*)KnownObjects::nil;
}
GCedRef& GCedRef::operator=(GCedRef&& other) {
if (this != &other) {
_object = other._object;
_index = other._index;
other._object = nullptr;
}
return *this;
}
*/
GCedRef::~GCedRef() {
//if (_object != KnownObjects::nil)
debugRuntime->releaseGCedRef_(_index);
}
uintptr_t GCedRef::Comparator::hash(const GCedRef *obj) const {
return debugRuntime->hashFor_((Object*)obj->get());
}
uintptr_t GCedRef::Comparator::hash(const Object *obj) const {
return debugRuntime->hashFor_((Object*)obj);
}
Object* GCedRef::get()
{
return _object;
}
uintptr_t GCedRef::index() {
return _index;
}