OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 void set_source(const String& value) const; | 1415 void set_source(const String& value) const; |
1416 void set_kind(RawScript::Kind value) const; | 1416 void set_kind(RawScript::Kind value) const; |
1417 void set_tokens(const TokenStream& value) const; | 1417 void set_tokens(const TokenStream& value) const; |
1418 static RawScript* New(); | 1418 static RawScript* New(); |
1419 | 1419 |
1420 HEAP_OBJECT_IMPLEMENTATION(Script, Object); | 1420 HEAP_OBJECT_IMPLEMENTATION(Script, Object); |
1421 friend class Class; | 1421 friend class Class; |
1422 }; | 1422 }; |
1423 | 1423 |
1424 | 1424 |
1425 class ClassDictionaryIterator : public ValueObject { | 1425 class DictionaryIterator : public ValueObject { |
1426 public: | 1426 public: |
1427 explicit ClassDictionaryIterator(const Library& library); | 1427 explicit DictionaryIterator(const Library& library); |
1428 bool HasNext() const { | 1428 |
1429 return next_ix_ < size_; | 1429 bool HasNext() const { return next_ix_ < size_; } |
1430 } | 1430 |
1431 // Returns a non-null raw object. | 1431 // Returns next non-null raw object. |
1432 RawClass* GetNext(); | 1432 RawObject* GetNext(); |
1433 | 1433 |
1434 private: | 1434 private: |
1435 void MoveToNextClass(); | 1435 void MoveToNextObject(); |
1436 | 1436 |
1437 const Array& array_; | 1437 const Array& array_; |
1438 const int size_; // Number of elements to iterate over. | 1438 const int size_; // Number of elements to iterate over. |
1439 int next_ix_; // Index of next element. | 1439 int next_ix_; // Index of next element. |
1440 | 1440 |
| 1441 friend class ClassDictionaryIterator; |
| 1442 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator); |
| 1443 }; |
| 1444 |
| 1445 |
| 1446 class ClassDictionaryIterator : public DictionaryIterator { |
| 1447 public: |
| 1448 explicit ClassDictionaryIterator(const Library& library); |
| 1449 |
| 1450 // Returns a non-null raw class. |
| 1451 RawClass* GetNextClass(); |
| 1452 |
| 1453 private: |
| 1454 void MoveToNextClass(); |
| 1455 |
1441 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); | 1456 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); |
1442 }; | 1457 }; |
1443 | 1458 |
1444 | 1459 |
1445 class Library : public Object { | 1460 class Library : public Object { |
1446 public: | 1461 public: |
1447 RawString* name() const { return raw_ptr()->name_; } | 1462 RawString* name() const { return raw_ptr()->name_; } |
1448 void SetName(const String& name) const; | 1463 void SetName(const String& name) const; |
1449 | 1464 |
1450 RawString* url() const { return raw_ptr()->url_; } | 1465 RawString* url() const { return raw_ptr()->url_; } |
(...skipping 22 matching lines...) Expand all Loading... |
1473 // Resolving native methods for script loaded in the library. | 1488 // Resolving native methods for script loaded in the library. |
1474 Dart_NativeEntryResolver native_entry_resolver() const { | 1489 Dart_NativeEntryResolver native_entry_resolver() const { |
1475 return raw_ptr()->native_entry_resolver_; | 1490 return raw_ptr()->native_entry_resolver_; |
1476 } | 1491 } |
1477 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { | 1492 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { |
1478 raw_ptr()->native_entry_resolver_ = value; | 1493 raw_ptr()->native_entry_resolver_ = value; |
1479 } | 1494 } |
1480 | 1495 |
1481 void Register() const; | 1496 void Register() const; |
1482 static RawLibrary* LookupLibrary(const String& url); | 1497 static RawLibrary* LookupLibrary(const String& url); |
| 1498 static RawString* CheckForDuplicateDefinition(); |
1483 static bool IsKeyUsed(intptr_t key); | 1499 static bool IsKeyUsed(intptr_t key); |
1484 | 1500 |
1485 static void InitCoreLibrary(Isolate* isolate); | 1501 static void InitCoreLibrary(Isolate* isolate); |
1486 static RawLibrary* CoreLibrary(); | 1502 static RawLibrary* CoreLibrary(); |
1487 static RawLibrary* CoreImplLibrary(); | 1503 static RawLibrary* CoreImplLibrary(); |
1488 | 1504 |
1489 // Eagerly compile all classes and functions in the library. | 1505 // Eagerly compile all classes and functions in the library. |
1490 static void CompileAll(); | 1506 static void CompileAll(); |
1491 | 1507 |
1492 private: | 1508 private: |
1493 static const int kInitialImportsCapacity = 4; | 1509 static const int kInitialImportsCapacity = 4; |
1494 static const int kImportsCapacityIncrement = 8; | 1510 static const int kImportsCapacityIncrement = 8; |
| 1511 static const int kInitialImportedIntoCapacity = 1; |
| 1512 static const int kImportedIntoCapacityIncrement = 2; |
1495 static RawLibrary* New(); | 1513 static RawLibrary* New(); |
1496 | 1514 |
1497 intptr_t num_imports() const { return raw_ptr()->num_imports_; } | 1515 intptr_t num_imports() const { return raw_ptr()->num_imports_; } |
1498 void set_num_imports(intptr_t value) const { | 1516 void set_num_imports(intptr_t value) const { |
1499 raw_ptr()->num_imports_ = value; | 1517 raw_ptr()->num_imports_ = value; |
1500 } | 1518 } |
| 1519 intptr_t num_imported_into() const { return raw_ptr()->num_imported_into_; } |
| 1520 void set_num_imported_into(intptr_t value) const { |
| 1521 raw_ptr()->num_imported_into_ = value; |
| 1522 } |
1501 RawArray* imports() const { return raw_ptr()->imports_; } | 1523 RawArray* imports() const { return raw_ptr()->imports_; } |
| 1524 RawArray* imported_into() const { return raw_ptr()->imported_into_; } |
1502 RawArray* dictionary() const { return raw_ptr()->dictionary_; } | 1525 RawArray* dictionary() const { return raw_ptr()->dictionary_; } |
1503 RawLibrary* next_registered() const { return raw_ptr()->next_registered_; } | 1526 RawLibrary* next_registered() const { return raw_ptr()->next_registered_; } |
1504 void InitClassDictionary() const; | 1527 void InitClassDictionary() const; |
1505 void InitImportList() const; | 1528 void InitImportList() const; |
| 1529 void InitImportedIntoList() const; |
1506 void GrowDictionary(const Array& dict, intptr_t dict_size) const; | 1530 void GrowDictionary(const Array& dict, intptr_t dict_size) const; |
1507 static RawLibrary* NewLibraryHelper(const String& url, | 1531 static RawLibrary* NewLibraryHelper(const String& url, |
1508 bool import_core_lib); | 1532 bool import_core_lib); |
| 1533 void AddImportedInto(const Library& library) const; |
| 1534 RawObject* LookupObjectInImporter(const String& name) const; |
| 1535 RawString* DuplicateDefineErrorString(const Object& obj) const; |
| 1536 RawObject* FindDuplicateDefinition() const; |
| 1537 |
1509 HEAP_OBJECT_IMPLEMENTATION(Library, Object); | 1538 HEAP_OBJECT_IMPLEMENTATION(Library, Object); |
1510 friend class Class; | 1539 friend class Class; |
1511 friend class ClassDictionaryIterator; | 1540 friend class DictionaryIterator; |
1512 friend class Isolate; | 1541 friend class Isolate; |
1513 }; | 1542 }; |
1514 | 1543 |
1515 | 1544 |
1516 class LibraryPrefix : public Object { | 1545 class LibraryPrefix : public Object { |
1517 public: | 1546 public: |
1518 RawString* name() const { return raw_ptr()->name_; } | 1547 RawString* name() const { return raw_ptr()->name_; } |
1519 RawLibrary* library() const { return raw_ptr()->library_; } | 1548 RawLibrary* library() const { return raw_ptr()->library_; } |
1520 | 1549 |
1521 static intptr_t InstanceSize() { | 1550 static intptr_t InstanceSize() { |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 } | 2906 } |
2878 | 2907 |
2879 | 2908 |
2880 void Context::SetAt(intptr_t index, const Instance& value) const { | 2909 void Context::SetAt(intptr_t index, const Instance& value) const { |
2881 StorePointer(InstanceAddr(index), value.raw()); | 2910 StorePointer(InstanceAddr(index), value.raw()); |
2882 } | 2911 } |
2883 | 2912 |
2884 } // namespace dart | 2913 } // namespace dart |
2885 | 2914 |
2886 #endif // VM_OBJECT_H_ | 2915 #endif // VM_OBJECT_H_ |
OLD | NEW |