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 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/become.h" | 10 #include "vm/become.h" |
(...skipping 10460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10471 } | 10471 } |
10472 | 10472 |
10473 | 10473 |
10474 RawLibrary* Library::NewLibraryHelper(const String& url, | 10474 RawLibrary* Library::NewLibraryHelper(const String& url, |
10475 bool import_core_lib) { | 10475 bool import_core_lib) { |
10476 Thread* thread = Thread::Current(); | 10476 Thread* thread = Thread::Current(); |
10477 Zone* zone = thread->zone(); | 10477 Zone* zone = thread->zone(); |
10478 ASSERT(thread->IsMutatorThread()); | 10478 ASSERT(thread->IsMutatorThread()); |
10479 // Force the url to have a hash code. | 10479 // Force the url to have a hash code. |
10480 url.Hash(); | 10480 url.Hash(); |
| 10481 const bool dart_scheme = url.StartsWith(Symbols::DartScheme()); |
| 10482 const bool dart_private_scheme = |
| 10483 dart_scheme && url.StartsWith(Symbols::DartSchemePrivate()); |
10481 const Library& result = Library::Handle(zone, Library::New()); | 10484 const Library& result = Library::Handle(zone, Library::New()); |
10482 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); | 10485 result.StorePointer(&result.raw_ptr()->name_, Symbols::Empty().raw()); |
10483 result.StorePointer(&result.raw_ptr()->url_, url.raw()); | 10486 result.StorePointer(&result.raw_ptr()->url_, url.raw()); |
10484 result.StorePointer(&result.raw_ptr()->resolved_names_, | 10487 result.StorePointer(&result.raw_ptr()->resolved_names_, |
10485 Object::empty_array().raw()); | 10488 Object::empty_array().raw()); |
10486 result.StorePointer(&result.raw_ptr()->exported_names_, | 10489 result.StorePointer(&result.raw_ptr()->exported_names_, |
10487 Array::null()); | 10490 Array::null()); |
10488 result.StorePointer(&result.raw_ptr()->dictionary_, | 10491 result.StorePointer(&result.raw_ptr()->dictionary_, |
10489 Object::empty_array().raw()); | 10492 Object::empty_array().raw()); |
10490 result.StorePointer(&result.raw_ptr()->metadata_, | 10493 result.StorePointer(&result.raw_ptr()->metadata_, |
10491 GrowableObjectArray::New(4, Heap::kOld)); | 10494 GrowableObjectArray::New(4, Heap::kOld)); |
10492 result.StorePointer(&result.raw_ptr()->toplevel_class_, Class::null()); | 10495 result.StorePointer(&result.raw_ptr()->toplevel_class_, Class::null()); |
10493 result.StorePointer(&result.raw_ptr()->patch_classes_, | 10496 result.StorePointer(&result.raw_ptr()->patch_classes_, |
10494 GrowableObjectArray::New(Object::empty_array(), | 10497 GrowableObjectArray::New(Object::empty_array(), |
10495 Heap::kOld)); | 10498 Heap::kOld)); |
10496 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw()); | 10499 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw()); |
10497 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw()); | 10500 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw()); |
10498 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null()); | 10501 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null()); |
10499 result.StorePointer(&result.raw_ptr()->load_error_, Instance::null()); | 10502 result.StorePointer(&result.raw_ptr()->load_error_, Instance::null()); |
10500 result.set_native_entry_resolver(NULL); | 10503 result.set_native_entry_resolver(NULL); |
10501 result.set_native_entry_symbol_resolver(NULL); | 10504 result.set_native_entry_symbol_resolver(NULL); |
10502 result.set_is_in_fullsnapshot(false); | 10505 result.set_is_in_fullsnapshot(false); |
10503 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true); | 10506 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true); |
10504 result.set_debuggable(false); | 10507 result.set_debuggable(!dart_private_scheme); |
10505 result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme())); | 10508 result.set_is_dart_scheme(dart_scheme); |
10506 result.StoreNonPointer(&result.raw_ptr()->load_state_, | 10509 result.StoreNonPointer(&result.raw_ptr()->load_state_, |
10507 RawLibrary::kAllocated); | 10510 RawLibrary::kAllocated); |
10508 result.StoreNonPointer(&result.raw_ptr()->index_, -1); | 10511 result.StoreNonPointer(&result.raw_ptr()->index_, -1); |
10509 const intptr_t kInitialNameCacheSize = 64; | 10512 const intptr_t kInitialNameCacheSize = 64; |
10510 result.InitResolvedNamesCache(kInitialNameCacheSize); | 10513 result.InitResolvedNamesCache(kInitialNameCacheSize); |
10511 result.InitClassDictionary(); | 10514 result.InitClassDictionary(); |
10512 result.InitImportList(); | 10515 result.InitImportList(); |
10513 result.AllocatePrivateKey(); | 10516 result.AllocatePrivateKey(); |
10514 if (import_core_lib) { | 10517 if (import_core_lib) { |
10515 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); | 10518 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); |
(...skipping 12445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22961 return UserTag::null(); | 22964 return UserTag::null(); |
22962 } | 22965 } |
22963 | 22966 |
22964 | 22967 |
22965 const char* UserTag::ToCString() const { | 22968 const char* UserTag::ToCString() const { |
22966 const String& tag_label = String::Handle(label()); | 22969 const String& tag_label = String::Handle(label()); |
22967 return tag_label.ToCString(); | 22970 return tag_label.ToCString(); |
22968 } | 22971 } |
22969 | 22972 |
22970 } // namespace dart | 22973 } // namespace dart |
OLD | NEW |