| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_CLASS_TABLE_H_ | 5 #ifndef VM_CLASS_TABLE_H_ |
| 6 #define VM_CLASS_TABLE_H_ | 6 #define VM_CLASS_TABLE_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class Class; | 14 class Class; |
| 15 class Function; | |
| 16 template <typename T> class ZoneGrowableArray; | |
| 17 class ObjectPointerVisitor; | 15 class ObjectPointerVisitor; |
| 18 class RawClass; | 16 class RawClass; |
| 19 class String; | |
| 20 | 17 |
| 21 class ClassTable { | 18 class ClassTable { |
| 22 public: | 19 public: |
| 23 ClassTable(); | 20 ClassTable(); |
| 24 ~ClassTable(); | 21 ~ClassTable(); |
| 25 | 22 |
| 26 RawClass* At(intptr_t index) const { | 23 RawClass* At(intptr_t index) const { |
| 27 ASSERT(IsValidIndex(index)); | 24 ASSERT(IsValidIndex(index)); |
| 28 return table_[index]; | 25 return table_[index]; |
| 29 } | 26 } |
| 30 | 27 |
| 31 intptr_t IsValidIndex(intptr_t index) const { | 28 intptr_t IsValidIndex(intptr_t index) const { |
| 32 return (index > 0) && (index < top_); | 29 return (index > 0) && (index < top_); |
| 33 } | 30 } |
| 34 | 31 |
| 35 void Register(const Class& cls); | 32 void Register(const Class& cls); |
| 36 | 33 |
| 37 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 34 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 38 | 35 |
| 39 void Print(); | 36 void Print(); |
| 40 | 37 |
| 41 // Returns true if the class given by its cid has subclasses. | |
| 42 // Must not be called for kDartObjectCid. | |
| 43 bool HasSubclasses(intptr_t cid) const; | |
| 44 | |
| 45 // Returns an array containing the cids of the direct and indirect subclasses | |
| 46 // of the class given by its cid. | |
| 47 // Must not be called for kDartObjectCid. | |
| 48 ZoneGrowableArray<intptr_t>* GetSubclassIdsOf(intptr_t cid) const; | |
| 49 | |
| 50 // Returns an array containing instance functions of the given name and | |
| 51 // belonging to the classes given by their cids. | |
| 52 // Cids must not contain kDartObjectCid. | |
| 53 ZoneGrowableArray<Function*>* GetNamedInstanceFunctionsOf( | |
| 54 const ZoneGrowableArray<intptr_t>& cids, | |
| 55 const String& function_name) const; | |
| 56 | |
| 57 // Returns an array of functions overriding the given function. | |
| 58 // Must not be called for a function of class Object. | |
| 59 ZoneGrowableArray<Function*>* GetOverridesOf(const Function& function) const; | |
| 60 | |
| 61 static intptr_t table_offset() { | 38 static intptr_t table_offset() { |
| 62 return OFFSET_OF(ClassTable, table_); | 39 return OFFSET_OF(ClassTable, table_); |
| 63 } | 40 } |
| 64 | 41 |
| 65 private: | 42 private: |
| 66 static const int initial_capacity_ = 512; | 43 static const int initial_capacity_ = 512; |
| 67 static const int capacity_increment_ = 256; | 44 static const int capacity_increment_ = 256; |
| 68 | 45 |
| 69 intptr_t top_; | 46 intptr_t top_; |
| 70 intptr_t capacity_; | 47 intptr_t capacity_; |
| 71 | 48 |
| 72 RawClass** table_; | 49 RawClass** table_; |
| 73 | 50 |
| 74 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 51 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
| 75 }; | 52 }; |
| 76 | 53 |
| 77 } // namespace dart | 54 } // namespace dart |
| 78 | 55 |
| 79 #endif // VM_CLASS_TABLE_H_ | 56 #endif // VM_CLASS_TABLE_H_ |
| OLD | NEW |