| 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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 3511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3522 | 3522 |
| 3523 // Library scope name dictionary. | 3523 // Library scope name dictionary. |
| 3524 // | 3524 // |
| 3525 // TODO(turnidge): The Lookup functions are not consistent in how | 3525 // TODO(turnidge): The Lookup functions are not consistent in how |
| 3526 // they deal with private names. Go through and make them a bit | 3526 // they deal with private names. Go through and make them a bit |
| 3527 // more regular. | 3527 // more regular. |
| 3528 void AddClass(const Class& cls) const; | 3528 void AddClass(const Class& cls) const; |
| 3529 void AddObject(const Object& obj, const String& name) const; | 3529 void AddObject(const Object& obj, const String& name) const; |
| 3530 void ReplaceObject(const Object& obj, const String& name) const; | 3530 void ReplaceObject(const Object& obj, const String& name) const; |
| 3531 bool RemoveObject(const Object& obj, const String& name) const; | 3531 bool RemoveObject(const Object& obj, const String& name) const; |
| 3532 RawObject* LookupReExport(const String& name) const; | 3532 RawObject* LookupReExport(const String& name, |
| 3533 ZoneGrowableArray<intptr_t>* visited = NULL) const; |
| 3533 RawObject* LookupObjectAllowPrivate(const String& name) const; | 3534 RawObject* LookupObjectAllowPrivate(const String& name) const; |
| 3534 RawObject* LookupLocalObjectAllowPrivate(const String& name) const; | 3535 RawObject* LookupLocalObjectAllowPrivate(const String& name) const; |
| 3535 RawObject* LookupLocalObject(const String& name) const; | 3536 RawObject* LookupLocalObject(const String& name) const; |
| 3536 RawObject* LookupImportedObject(const String& name) const; | 3537 RawObject* LookupImportedObject(const String& name) const; |
| 3537 RawClass* LookupClass(const String& name) const; | 3538 RawClass* LookupClass(const String& name) const; |
| 3538 RawClass* LookupClassAllowPrivate(const String& name) const; | 3539 RawClass* LookupClassAllowPrivate(const String& name) const; |
| 3539 RawClass* LookupLocalClass(const String& name) const; | 3540 RawClass* LookupLocalClass(const String& name) const; |
| 3540 RawField* LookupFieldAllowPrivate(const String& name) const; | 3541 RawField* LookupFieldAllowPrivate(const String& name) const; |
| 3541 RawField* LookupLocalField(const String& name) const; | 3542 RawField* LookupLocalField(const String& name) const; |
| 3542 RawFunction* LookupFunctionAllowPrivate(const String& name) const; | 3543 RawFunction* LookupFunctionAllowPrivate(const String& name) const; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3575 } | 3576 } |
| 3576 void set_toplevel_class(const Class& value) const; | 3577 void set_toplevel_class(const Class& value) const; |
| 3577 | 3578 |
| 3578 RawGrowableObjectArray* patch_classes() const { | 3579 RawGrowableObjectArray* patch_classes() const { |
| 3579 return raw_ptr()->patch_classes_; | 3580 return raw_ptr()->patch_classes_; |
| 3580 } | 3581 } |
| 3581 | 3582 |
| 3582 // Library imports. | 3583 // Library imports. |
| 3583 RawArray* imports() const { return raw_ptr()->imports_; } | 3584 RawArray* imports() const { return raw_ptr()->imports_; } |
| 3584 RawArray* exports() const { return raw_ptr()->exports_; } | 3585 RawArray* exports() const { return raw_ptr()->exports_; } |
| 3585 RawArray* exports2() const { return raw_ptr()->exports2_; } | |
| 3586 void AddImport(const Namespace& ns) const; | 3586 void AddImport(const Namespace& ns) const; |
| 3587 intptr_t num_imports() const { return raw_ptr()->num_imports_; } | 3587 intptr_t num_imports() const { return raw_ptr()->num_imports_; } |
| 3588 RawNamespace* ImportAt(intptr_t index) const; | 3588 RawNamespace* ImportAt(intptr_t index) const; |
| 3589 RawLibrary* ImportLibraryAt(intptr_t index) const; | 3589 RawLibrary* ImportLibraryAt(intptr_t index) const; |
| 3590 bool ImportsCorelib() const; | 3590 bool ImportsCorelib() const; |
| 3591 | 3591 |
| 3592 void DropDependencies() const; | 3592 void DropDependencies() const; |
| 3593 | 3593 |
| 3594 // Resolving native methods for script loaded in the library. | 3594 // Resolving native methods for script loaded in the library. |
| 3595 Dart_NativeEntryResolver native_entry_resolver() const { | 3595 Dart_NativeEntryResolver native_entry_resolver() const { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3701 void set_num_imports(intptr_t value) const; | 3701 void set_num_imports(intptr_t value) const; |
| 3702 bool HasExports() const; | 3702 bool HasExports() const; |
| 3703 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } | 3703 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } |
| 3704 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } | 3704 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } |
| 3705 RawArray* dictionary() const { return raw_ptr()->dictionary_; } | 3705 RawArray* dictionary() const { return raw_ptr()->dictionary_; } |
| 3706 void InitClassDictionary() const; | 3706 void InitClassDictionary() const; |
| 3707 | 3707 |
| 3708 RawArray* resolved_names() const { return raw_ptr()->resolved_names_; } | 3708 RawArray* resolved_names() const { return raw_ptr()->resolved_names_; } |
| 3709 void InitResolvedNamesCache(intptr_t size, | 3709 void InitResolvedNamesCache(intptr_t size, |
| 3710 SnapshotReader* reader = NULL) const; | 3710 SnapshotReader* reader = NULL) const; |
| 3711 void GrowResolvedNamesCache() const; | 3711 void AllocateExportedNamesCache() const; |
| 3712 void InitExportedNamesCache() const; |
| 3713 static void InvalidateExportedNamesCaches(); |
| 3712 bool LookupResolvedNamesCache(const String& name, Object* obj) const; | 3714 bool LookupResolvedNamesCache(const String& name, Object* obj) const; |
| 3713 void AddToResolvedNamesCache(const String& name, const Object& obj) const; | 3715 void AddToResolvedNamesCache(const String& name, const Object& obj) const; |
| 3714 void InvalidateResolvedName(const String& name) const; | 3716 void InvalidateResolvedName(const String& name) const; |
| 3715 void InvalidateResolvedNamesCache() const; | 3717 void InvalidateResolvedNamesCache() const; |
| 3716 | 3718 |
| 3719 RawArray* exported_names() const { return raw_ptr()->exported_names_; } |
| 3720 bool LookupExportedNamesCache(const String& name, Object* obj) const; |
| 3721 void AddToExportedNamesCache(const String& name, const Object& obj) const; |
| 3722 |
| 3723 |
| 3717 void InitImportList() const; | 3724 void InitImportList() const; |
| 3718 void GrowDictionary(const Array& dict, intptr_t dict_size) const; | 3725 void GrowDictionary(const Array& dict, intptr_t dict_size) const; |
| 3719 static RawLibrary* NewLibraryHelper(const String& url, | 3726 static RawLibrary* NewLibraryHelper(const String& url, |
| 3720 bool import_core_lib); | 3727 bool import_core_lib); |
| 3721 RawObject* LookupEntry(const String& name, intptr_t *index) const; | 3728 RawObject* LookupEntry(const String& name, intptr_t *index) const; |
| 3722 | 3729 |
| 3723 static bool IsKeyUsed(intptr_t key); | 3730 static bool IsKeyUsed(intptr_t key); |
| 3724 void AllocatePrivateKey() const; | 3731 void AllocatePrivateKey() const; |
| 3725 | 3732 |
| 3726 RawString* MakeMetadataName(const Object& obj) const; | 3733 RawString* MakeMetadataName(const Object& obj) const; |
| 3727 RawField* GetMetadataField(const String& metaname) const; | 3734 RawField* GetMetadataField(const String& metaname) const; |
| 3728 void AddMetadata(const Object& owner, | 3735 void AddMetadata(const Object& owner, |
| 3729 const String& name, | 3736 const String& name, |
| 3730 TokenPosition token_pos) const; | 3737 TokenPosition token_pos) const; |
| 3731 | 3738 |
| 3732 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); | 3739 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); |
| 3733 | 3740 |
| 3734 friend class Bootstrap; | 3741 friend class Bootstrap; |
| 3735 friend class Class; | 3742 friend class Class; |
| 3736 friend class Debugger; | 3743 friend class Debugger; |
| 3744 friend class Isolate; |
| 3737 friend class DictionaryIterator; | 3745 friend class DictionaryIterator; |
| 3738 friend class Namespace; | 3746 friend class Namespace; |
| 3739 friend class Object; | 3747 friend class Object; |
| 3740 }; | 3748 }; |
| 3741 | 3749 |
| 3742 | 3750 |
| 3743 // A Namespace contains the names in a library dictionary, filtered by | 3751 // A Namespace contains the names in a library dictionary, filtered by |
| 3744 // the show/hide combinators. | 3752 // the show/hide combinators. |
| 3745 class Namespace : public Object { | 3753 class Namespace : public Object { |
| 3746 public: | 3754 public: |
| 3747 RawLibrary* library() const { return raw_ptr()->library_; } | 3755 RawLibrary* library() const { return raw_ptr()->library_; } |
| 3748 RawArray* show_names() const { return raw_ptr()->show_names_; } | 3756 RawArray* show_names() const { return raw_ptr()->show_names_; } |
| 3749 RawArray* hide_names() const { return raw_ptr()->hide_names_; } | 3757 RawArray* hide_names() const { return raw_ptr()->hide_names_; } |
| 3750 | 3758 |
| 3751 void AddMetadata(const Object& owner, TokenPosition token_pos); | 3759 void AddMetadata(const Object& owner, TokenPosition token_pos); |
| 3752 RawObject* GetMetadata() const; | 3760 RawObject* GetMetadata() const; |
| 3753 | 3761 |
| 3754 static intptr_t InstanceSize() { | 3762 static intptr_t InstanceSize() { |
| 3755 return RoundedAllocationSize(sizeof(RawNamespace)); | 3763 return RoundedAllocationSize(sizeof(RawNamespace)); |
| 3756 } | 3764 } |
| 3757 | 3765 |
| 3758 bool HidesName(const String& name) const; | 3766 bool HidesName(const String& name) const; |
| 3759 RawObject* Lookup(const String& name) const; | 3767 RawObject* Lookup(const String& name, |
| 3768 ZoneGrowableArray<intptr_t>* trail = NULL) const; |
| 3760 | 3769 |
| 3761 static RawNamespace* New(const Library& library, | 3770 static RawNamespace* New(const Library& library, |
| 3762 const Array& show_names, | 3771 const Array& show_names, |
| 3763 const Array& hide_names); | 3772 const Array& hide_names); |
| 3764 | 3773 |
| 3765 private: | 3774 private: |
| 3766 static RawNamespace* New(); | 3775 static RawNamespace* New(); |
| 3767 | 3776 |
| 3768 RawField* metadata_field() const { return raw_ptr()->metadata_field_; } | 3777 RawField* metadata_field() const { return raw_ptr()->metadata_field_; } |
| 3769 void set_metadata_field(const Field& value) const; | 3778 void set_metadata_field(const Field& value) const; |
| (...skipping 4685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8455 | 8464 |
| 8456 | 8465 |
| 8457 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8466 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8458 intptr_t index) { | 8467 intptr_t index) { |
| 8459 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8468 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8460 } | 8469 } |
| 8461 | 8470 |
| 8462 } // namespace dart | 8471 } // namespace dart |
| 8463 | 8472 |
| 8464 #endif // VM_OBJECT_H_ | 8473 #endif // VM_OBJECT_H_ |
| OLD | NEW |