src/Structures.cpp
changeset 256 3c184218462d
parent 241 18f3010a358c
child 263 ba85a47ee414
     1.1 --- a/src/Structures.cpp	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/Structures.cpp	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -56,7 +56,7 @@
     1.4  }
     1.5  
     1.6  Descriptor *
     1.7 -Descriptor::New(Zone *zone, Handle<String> name, Handle<Type> type)
     1.8 +Descriptor::New(Zone *zone, Handle<String> name, Handle<Type> type, Visibility visibility)
     1.9  {
    1.10      Local<Descriptor> desc(zone,
    1.11          Descriptor::cast(zone->allocate(MapKind_Descriptor, sizeof(Descriptor), Heap::Tenure_Old)));
    1.12 @@ -66,6 +66,7 @@
    1.13      desc->name_ = name;
    1.14      desc->type_ = type;
    1.15      desc->offset_ = unsigned(-1);
    1.16 +    desc->visibility_ = visibility;
    1.17      return desc;
    1.18  }
    1.19  
    1.20 @@ -111,12 +112,13 @@
    1.21  Struct *
    1.22  Struct::New(Zone *zone, Handle<StructMap> map, Heap::Tenure tenure)
    1.23  {
    1.24 -    size_t bytesNeeded = sizeof(Struct) + map->structureSize();
    1.25 +    size_t bytesNeeded = SizeFor(map);
    1.26 +
    1.27      Local<Struct> obj(zone, Struct::cast(zone->allocate(map, bytesNeeded, tenure)));
    1.28      if (!obj)
    1.29          return NULL;
    1.30  
    1.31 -    memset((Struct *)obj + 1, 0, map->structureSize());
    1.32 +    memset((Struct *)obj + 1, 0, (bytesNeeded - sizeof(Struct)));
    1.33  
    1.34      // Initialize any sub-structures. Right now, this is performed as part of
    1.35      // struct allocation, rather than inlined in bytecode, for simplicity.