diff -r efc3f91dbe42 -r 3bf7c007883d src/Reference.cpp --- a/src/Reference.cpp Sun Aug 05 02:17:40 2012 -0700 +++ b/src/Reference.cpp Sun Aug 05 12:55:51 2012 -0700 @@ -18,6 +18,7 @@ #include "Reference.h" #include "Zone.h" #include "Array.h" +#include "Structures.h" #include "Heap-inl.h" using namespace ke; @@ -30,6 +31,7 @@ return NULL; ref->location_ = location; + ref->base_ = NULL; return ref; } @@ -42,6 +44,7 @@ ref->location_ = &ref->slot_; ref->slot_ = slot; + ref->base_ = NULL; return ref; } @@ -56,3 +59,17 @@ ref->base_ = base; return ref; } + +Reference * +Reference::NewField(Zone *zone, Handle obj, size_t index, Heap::Tenure tenure) +{ + Local ref(zone, Reference::cast(zone->allocate(MapKind_Reference, sizeof(Reference), tenure))); + if (!ref) + return NULL; + + Descriptor *desc = Descriptor::cast(obj->map()->type()->fields()->at(index)); + ref->location_ = obj->ref(desc); + ref->base_ = obj; + return ref; +} +