| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 6469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6480 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(obj); | 6480 const LibraryPrefix& lib_prefix = LibraryPrefix::Cast(obj); |
| 6481 if (lib_prefix.ContainsLibrary(imported)) { | 6481 if (lib_prefix.ContainsLibrary(imported)) { |
| 6482 return lib_prefix.raw(); | 6482 return lib_prefix.raw(); |
| 6483 } | 6483 } |
| 6484 } | 6484 } |
| 6485 } | 6485 } |
| 6486 return LibraryPrefix::null(); | 6486 return LibraryPrefix::null(); |
| 6487 } | 6487 } |
| 6488 | 6488 |
| 6489 | 6489 |
| 6490 bool Library::ImportsCorelib() const { |
| 6491 Isolate* isolate = Isolate::Current(); |
| 6492 Library& imported = Library::Handle(isolate); |
| 6493 intptr_t count = num_imports(); |
| 6494 for (int i = 0; i < count; i++) { |
| 6495 imported = ImportAt(i); |
| 6496 if (imported.IsCoreLibrary()) { |
| 6497 return true; |
| 6498 } |
| 6499 } |
| 6500 LibraryPrefix& prefix = LibraryPrefix::Handle(isolate); |
| 6501 LibraryPrefixIterator it(*this); |
| 6502 while (it.HasNext()) { |
| 6503 prefix = it.GetNext(); |
| 6504 count = prefix.num_libs(); |
| 6505 for (int i = 0; i < count; i++) { |
| 6506 imported = prefix.GetLibrary(i); |
| 6507 if (imported.IsCoreLibrary()) { |
| 6508 return true; |
| 6509 } |
| 6510 } |
| 6511 } |
| 6512 return false; |
| 6513 } |
| 6514 |
| 6515 |
| 6490 void Library::AddImport(const Library& library) const { | 6516 void Library::AddImport(const Library& library) const { |
| 6491 Array& imports = Array::Handle(this->imports()); | 6517 Array& imports = Array::Handle(this->imports()); |
| 6492 intptr_t capacity = imports.Length(); | 6518 intptr_t capacity = imports.Length(); |
| 6493 if (num_imports() == capacity) { | 6519 if (num_imports() == capacity) { |
| 6494 capacity = capacity + kImportsCapacityIncrement; | 6520 capacity = capacity + kImportsCapacityIncrement; |
| 6495 imports = Array::Grow(imports, capacity); | 6521 imports = Array::Grow(imports, capacity); |
| 6496 StorePointer(&raw_ptr()->imports_, imports.raw()); | 6522 StorePointer(&raw_ptr()->imports_, imports.raw()); |
| 6497 } | 6523 } |
| 6498 intptr_t index = num_imports(); | 6524 intptr_t index = num_imports(); |
| 6499 imports.SetAt(index, library); | 6525 imports.SetAt(index, library); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6551 if (import_core_lib) { | 6577 if (import_core_lib) { |
| 6552 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 6578 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 6553 ASSERT(!core_lib.IsNull()); | 6579 ASSERT(!core_lib.IsNull()); |
| 6554 result.AddImport(core_lib); | 6580 result.AddImport(core_lib); |
| 6555 } | 6581 } |
| 6556 return result.raw(); | 6582 return result.raw(); |
| 6557 } | 6583 } |
| 6558 | 6584 |
| 6559 | 6585 |
| 6560 RawLibrary* Library::New(const String& url) { | 6586 RawLibrary* Library::New(const String& url) { |
| 6561 return NewLibraryHelper(url, true); | 6587 return NewLibraryHelper(url, false); |
| 6562 } | 6588 } |
| 6563 | 6589 |
| 6564 | 6590 |
| 6565 void Library::InitCoreLibrary(Isolate* isolate) { | 6591 void Library::InitCoreLibrary(Isolate* isolate) { |
| 6566 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); | 6592 const String& core_lib_url = String::Handle(Symbols::New("dart:core")); |
| 6567 const Library& core_lib = | 6593 const Library& core_lib = |
| 6568 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); | 6594 Library::Handle(Library::NewLibraryHelper(core_lib_url, false)); |
| 6569 core_lib.Register(); | 6595 core_lib.Register(); |
| 6570 isolate->object_store()->set_core_library(core_lib); | 6596 isolate->object_store()->set_core_library(core_lib); |
| 6571 const String& core_impl_lib_url = | 6597 const String& core_impl_lib_url = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6585 // Hook up predefined classes without setting their library pointers. These | 6611 // Hook up predefined classes without setting their library pointers. These |
| 6586 // classes are coming from the VM isolate, and are shared between multiple | 6612 // classes are coming from the VM isolate, and are shared between multiple |
| 6587 // isolates so setting their library pointers would be wrong. | 6613 // isolates so setting their library pointers would be wrong. |
| 6588 const Class& cls = Class::Handle(Object::dynamic_class()); | 6614 const Class& cls = Class::Handle(Object::dynamic_class()); |
| 6589 core_lib.AddObject(cls, String::Handle(cls.Name())); | 6615 core_lib.AddObject(cls, String::Handle(cls.Name())); |
| 6590 } | 6616 } |
| 6591 | 6617 |
| 6592 | 6618 |
| 6593 void Library::InitMathLibrary(Isolate* isolate) { | 6619 void Library::InitMathLibrary(Isolate* isolate) { |
| 6594 const String& url = String::Handle(Symbols::New("dart:math")); | 6620 const String& url = String::Handle(Symbols::New("dart:math")); |
| 6595 const Library& lib = Library::Handle(Library::New(url)); | 6621 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
| 6596 lib.Register(); | 6622 lib.Register(); |
| 6597 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 6623 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 6598 lib.AddImport(core_impl_lib); | 6624 lib.AddImport(core_impl_lib); |
| 6599 isolate->object_store()->set_math_library(lib); | 6625 isolate->object_store()->set_math_library(lib); |
| 6600 } | 6626 } |
| 6601 | 6627 |
| 6602 | 6628 |
| 6603 void Library::InitIsolateLibrary(Isolate* isolate) { | 6629 void Library::InitIsolateLibrary(Isolate* isolate) { |
| 6604 const String& url = String::Handle(Symbols::New("dart:isolate")); | 6630 const String& url = String::Handle(Symbols::New("dart:isolate")); |
| 6605 const Library& lib = Library::Handle(Library::New(url)); | 6631 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
| 6606 lib.Register(); | 6632 lib.Register(); |
| 6607 isolate->object_store()->set_isolate_library(lib); | 6633 isolate->object_store()->set_isolate_library(lib); |
| 6608 } | 6634 } |
| 6609 | 6635 |
| 6610 | 6636 |
| 6611 void Library::InitMirrorsLibrary(Isolate* isolate) { | 6637 void Library::InitMirrorsLibrary(Isolate* isolate) { |
| 6612 const String& url = String::Handle(Symbols::New("dart:mirrors")); | 6638 const String& url = String::Handle(Symbols::New("dart:mirrors")); |
| 6613 const Library& lib = Library::Handle(Library::New(url)); | 6639 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
| 6614 lib.Register(); | 6640 lib.Register(); |
| 6615 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 6641 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 6616 lib.AddImport(isolate_lib); | 6642 lib.AddImport(isolate_lib); |
| 6617 const Library& wrappers_lib = | 6643 const Library& wrappers_lib = |
| 6618 Library::Handle(Library::NativeWrappersLibrary()); | 6644 Library::Handle(Library::NativeWrappersLibrary()); |
| 6619 lib.AddImport(wrappers_lib); | 6645 lib.AddImport(wrappers_lib); |
| 6620 isolate->object_store()->set_mirrors_library(lib); | 6646 isolate->object_store()->set_mirrors_library(lib); |
| 6621 } | 6647 } |
| 6622 | 6648 |
| 6623 | 6649 |
| 6624 void Library::InitScalarlistLibrary(Isolate* isolate) { | 6650 void Library::InitScalarlistLibrary(Isolate* isolate) { |
| 6625 const String& url = String::Handle(Symbols::New("dart:scalarlist")); | 6651 const String& url = String::Handle(Symbols::New("dart:scalarlist")); |
| 6626 const Library& lib = Library::Handle(Library::New(url)); | 6652 const Library& lib = Library::Handle(Library::NewLibraryHelper(url, true)); |
| 6627 lib.Register(); | 6653 lib.Register(); |
| 6628 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 6654 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 6629 lib.AddImport(core_impl_lib); | 6655 lib.AddImport(core_impl_lib); |
| 6630 isolate->object_store()->set_scalarlist_library(lib); | 6656 isolate->object_store()->set_scalarlist_library(lib); |
| 6631 } | 6657 } |
| 6632 | 6658 |
| 6633 | 6659 |
| 6634 void Library::InitNativeWrappersLibrary(Isolate* isolate) { | 6660 void Library::InitNativeWrappersLibrary(Isolate* isolate) { |
| 6635 static const int kNumNativeWrappersClasses = 4; | 6661 static const int kNumNativeWrappersClasses = 4; |
| 6636 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); | 6662 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); |
| (...skipping 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11808 } | 11834 } |
| 11809 return result.raw(); | 11835 return result.raw(); |
| 11810 } | 11836 } |
| 11811 | 11837 |
| 11812 | 11838 |
| 11813 const char* WeakProperty::ToCString() const { | 11839 const char* WeakProperty::ToCString() const { |
| 11814 return "_WeakProperty"; | 11840 return "_WeakProperty"; |
| 11815 } | 11841 } |
| 11816 | 11842 |
| 11817 } // namespace dart | 11843 } // namespace dart |
| OLD | NEW |