src/Structures.cpp
changeset 192 23a804fa1d3e
parent 153 fc91c4a3dfe2
child 195 c1ba166f3fc4
     1.1 --- a/src/Structures.cpp	Sun Sep 16 22:49:54 2012 -0700
     1.2 +++ b/src/Structures.cpp	Sun Sep 16 23:15:13 2012 -0700
     1.3 @@ -20,6 +20,7 @@
     1.4  #include "Structures.h"
     1.5  #include "Zone.h"
     1.6  #include "Types.h"
     1.7 +#include "Array.h"
     1.8  #include "Spaces-inl.h"
     1.9  #include "Heap-inl.h"
    1.10  
    1.11 @@ -98,16 +99,23 @@
    1.12      // struct allocation, rather than inlined in bytecode, for simplicity.
    1.13      if (map->composed()) {
    1.14          Local<Descriptor> desc(zone);
    1.15 -        Local<Struct> child(zone);
    1.16 -        Local<StructMap> childMap(zone);
    1.17 +        Local<Object> child(zone);
    1.18 +        Local<StructMap> childStructMap(zone);
    1.19 +        Local<ArrayMap> childArrayMap(zone);
    1.20 +
    1.21          for (unsigned i = 0; i < map->composed()->length(); i++) {
    1.22              desc = Descriptor::cast(map->composed()->at(i));
    1.23  
    1.24 -            // We don't support composing arrays yet.
    1.25 -            assert(desc->type()->isStruct());
    1.26 -
    1.27 -            childMap = StructMap::cast(desc->type()->newMap());
    1.28 -            child = Struct::New(zone, childMap, tenure);
    1.29 +            if (desc->type()->isStruct()) {
    1.30 +                childStructMap = StructMap::cast(desc->type()->newMap());
    1.31 +                child = Struct::New(zone, childStructMap, tenure);
    1.32 +            } else if (desc->type()->isArray()) {
    1.33 +                childArrayMap = ArrayMap::cast(desc->type()->newMap());
    1.34 +                if (desc->type()->isFixedLength())
    1.35 +                    child = Array::NewFixed(zone, childArrayMap, tenure);
    1.36 +                else
    1.37 +                    child = Array::NewEmpty(zone, childArrayMap, tenure);
    1.38 +            }
    1.39              if (!child)
    1.40                  return NULL;
    1.41