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; |
15 class ObjectPointerVisitor; | 17 class ObjectPointerVisitor; |
16 class RawClass; | 18 class RawClass; |
| 19 class String; |
17 | 20 |
18 class ClassTable { | 21 class ClassTable { |
19 public: | 22 public: |
20 ClassTable(); | 23 ClassTable(); |
21 ~ClassTable(); | 24 ~ClassTable(); |
22 | 25 |
23 RawClass* At(intptr_t index) const { | 26 RawClass* At(intptr_t index) const { |
24 ASSERT(IsValidIndex(index)); | 27 ASSERT(IsValidIndex(index)); |
25 return table_[index]; | 28 return table_[index]; |
26 } | 29 } |
27 | 30 |
28 intptr_t IsValidIndex(intptr_t index) const { | 31 intptr_t IsValidIndex(intptr_t index) const { |
29 return (index > 0) && (index < top_); | 32 return (index > 0) && (index < top_); |
30 } | 33 } |
31 | 34 |
32 void Register(const Class& cls); | 35 void Register(const Class& cls); |
33 | 36 |
34 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 37 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
35 | 38 |
36 void Print(); | 39 void Print(); |
37 | 40 |
| 41 // Returns an array containing the cids of the direct and indirect subclasses |
| 42 // of the class given by its cid. |
| 43 // Must not be called for kDartObjectCid. |
| 44 ZoneGrowableArray<intptr_t>* GetSubclassIdsOf(intptr_t cid) const; |
| 45 |
| 46 // Returns an array containing instance functions of the given name and |
| 47 // belonging to the classes given by their cids. |
| 48 // Cids must not contain kDartObjectCid. |
| 49 ZoneGrowableArray<Function*>* GetNamedInstanceFunctionsOf( |
| 50 const ZoneGrowableArray<intptr_t>& cids, |
| 51 const String& function_name) const; |
| 52 |
| 53 // Returns an array of functions overriding the given function. |
| 54 // Must not be called for a function of class Object. |
| 55 ZoneGrowableArray<Function*>* GetOverridesOf(const Function& function) const; |
| 56 |
38 static intptr_t table_offset() { | 57 static intptr_t table_offset() { |
39 return OFFSET_OF(ClassTable, table_); | 58 return OFFSET_OF(ClassTable, table_); |
40 } | 59 } |
41 | 60 |
42 private: | 61 private: |
43 static const int initial_capacity_ = 512; | 62 static const int initial_capacity_ = 512; |
44 static const int capacity_increment_ = 256; | 63 static const int capacity_increment_ = 256; |
45 | 64 |
46 intptr_t top_; | 65 intptr_t top_; |
47 intptr_t capacity_; | 66 intptr_t capacity_; |
48 | 67 |
49 RawClass** table_; | 68 RawClass** table_; |
50 | 69 |
51 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 70 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
52 }; | 71 }; |
53 | 72 |
54 } // namespace dart | 73 } // namespace dart |
55 | 74 |
56 #endif // VM_CLASS_TABLE_H_ | 75 #endif // VM_CLASS_TABLE_H_ |
OLD | NEW |