src/Structures.h
changeset 256 3c184218462d
parent 234 26e3035cdffc
child 263 ba85a47ee414
     1.1 --- a/src/Structures.h	Tue Jan 01 20:08:34 2013 -0800
     1.2 +++ b/src/Structures.h	Sun Jan 06 13:52:21 2013 -0800
     1.3 @@ -60,6 +60,14 @@
     1.4  // Represents a property descriptor for a structure field.
     1.5  class Descriptor : public Object
     1.6  {
     1.7 +  public:
     1.8 +    enum Visibility {
     1.9 +        Private,
    1.10 +        Protected,
    1.11 +        Public
    1.12 +    };
    1.13 +
    1.14 +  private:
    1.15      // The name of the field.
    1.16      Barriered<String> name_;
    1.17  
    1.18 @@ -69,8 +77,10 @@
    1.19      // The offset into an object at which this field can be accessed.
    1.20      unsigned offset_;
    1.21  
    1.22 +    Visibility visibility_;
    1.23 +
    1.24    public:
    1.25 -    static Descriptor *New(Zone *zone, Handle<String> name, Handle<Type> type);
    1.26 +    static Descriptor *New(Zone *zone, Handle<String> name, Handle<Type> type, Visibility visibility);
    1.27  
    1.28      String *name() {
    1.29          return name_;
    1.30 @@ -160,9 +170,6 @@
    1.31  
    1.32      static bool Copy(Zone *zone, Handle<Struct> dest, Handle<Struct> src);
    1.33  
    1.34 -    size_t objSize() {
    1.35 -        return sizeof(Struct) + map()->structureSize();
    1.36 -    }
    1.37      StructMap *map() {
    1.38          return StructMap::cast(Object::map());
    1.39      }
    1.40 @@ -171,6 +178,10 @@
    1.41          return reinterpret_cast<Address>(this) + offsetOfSlotOffset(desc->offset());
    1.42      }
    1.43  
    1.44 +    static inline size_t SizeFor(StructMap *map) {
    1.45 +        return Max(sizeof(Struct) + map->structureSize(), kMinObjectSize);
    1.46 +    }
    1.47 +
    1.48      template <typename T> T get(Descriptor *desc) {
    1.49          return *reinterpret_cast<T *>(ref(desc));
    1.50      }