diff -r b029d63565a2 -r c1ba166f3fc4 src/Structures.cpp --- a/src/Structures.cpp Mon Sep 17 00:10:01 2012 -0700 +++ b/src/Structures.cpp Sat Nov 17 18:41:01 2012 -0800 @@ -51,7 +51,7 @@ } Descriptor * -Descriptor::New(Zone *zone, Handle name, Handle type, unsigned offset) +Descriptor::New(Zone *zone, Handle name, Handle type) { Local desc(zone, Descriptor::cast(zone->allocate(MapKind_Descriptor, sizeof(Descriptor), Heap::Tenure_Old))); @@ -60,13 +60,31 @@ desc->name_ = name; desc->type_ = type; - desc->offset_ = offset; + desc->offset_ = unsigned(-1); return desc; } StructMap * -StructMap::New(Zone *zone, const StructureBufferBuilder &builder, Handle composed) +StructMap::New(Zone *zone, const StructureBufferBuilder &builder, Handle type) { + Vector composedIndexes; + for (size_t i = 0; i < type->fields()->length(); i++) { + Descriptor *desc = Descriptor::cast(type->fields()->at(i)); + if (desc->type()->isArray() || desc->type()->isStruct()) { + if (!composedIndexes.append(i)) + return NULL; + } + } + + Local composed(zone, FixedArray::New(zone, composedIndexes.length(), Heap::Tenure_Old)); + if (!composed) + return NULL; + + for (size_t i = 0; i < composedIndexes.length(); i++) { + Descriptor *desc = Descriptor::cast(type->fields()->at(composedIndexes[i])); + composed->set(zone, i, desc); + } + size_t bytesNeeded = sizeof(StructMap) + (builder.traceableOffsetCount() * sizeof(unsigned)); @@ -77,7 +95,7 @@ map->structureSize_ = builder.structureSize(); map->traceOffsetCount_ = builder.traceableOffsetCount(); - map->type_ = NULL; + map->type_ = type; map->composed_ = composed; memcpy(const_cast(map->traceOffsets()), builder.offsets(), sizeof(unsigned) * builder.traceableOffsetCount()); @@ -107,14 +125,17 @@ desc = Descriptor::cast(map->composed()->at(i)); if (desc->type()->isStruct()) { - childStructMap = StructMap::cast(desc->type()->newMap()); + childStructMap = StructMap::cast(StructType::cast(desc->type())->newMap()); child = Struct::New(zone, childStructMap, tenure); } else if (desc->type()->isArray()) { + assert(false); +#if 0 childArrayMap = ArrayMap::cast(desc->type()->newMap()); if (desc->type()->isFixedLength()) child = Array::NewFixed(zone, childArrayMap, tenure); else child = Array::NewEmpty(zone, childArrayMap, tenure); +#endif } if (!child) return NULL;