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