1.1 --- a/src/Reference.cpp Sun Aug 05 02:17:40 2012 -0700
1.2 +++ b/src/Reference.cpp Sun Aug 05 12:55:51 2012 -0700
1.3 @@ -18,6 +18,7 @@
1.4 #include "Reference.h"
1.5 #include "Zone.h"
1.6 #include "Array.h"
1.7 +#include "Structures.h"
1.8 #include "Heap-inl.h"
1.9
1.10 using namespace ke;
1.11 @@ -30,6 +31,7 @@
1.12 return NULL;
1.13
1.14 ref->location_ = location;
1.15 + ref->base_ = NULL;
1.16 return ref;
1.17 }
1.18
1.19 @@ -42,6 +44,7 @@
1.20
1.21 ref->location_ = &ref->slot_;
1.22 ref->slot_ = slot;
1.23 + ref->base_ = NULL;
1.24 return ref;
1.25 }
1.26
1.27 @@ -56,3 +59,17 @@
1.28 ref->base_ = base;
1.29 return ref;
1.30 }
1.31 +
1.32 +Reference *
1.33 +Reference::NewField(Zone *zone, Handle<Struct> obj, size_t index, Heap::Tenure tenure)
1.34 +{
1.35 + Local<Reference> ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure)));
1.36 + if (!ref)
1.37 + return NULL;
1.38 +
1.39 + Descriptor *desc = Descriptor::cast(obj->map()->type()->fields()->at(index));
1.40 + ref->location_ = obj->ref(desc);
1.41 + ref->base_ = obj;
1.42 + return ref;
1.43 +}
1.44 +