| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 3653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3664 Object& obj = Object::Handle(array_.At(next_ix_)); | 3664 Object& obj = Object::Handle(array_.At(next_ix_)); |
| 3665 while (!obj.IsClass() && HasNext()) { | 3665 while (!obj.IsClass() && HasNext()) { |
| 3666 next_ix_++; | 3666 next_ix_++; |
| 3667 obj = array_.At(next_ix_); | 3667 obj = array_.At(next_ix_); |
| 3668 } | 3668 } |
| 3669 } | 3669 } |
| 3670 | 3670 |
| 3671 | 3671 |
| 3672 void Library::SetName(const String& name) const { | 3672 void Library::SetName(const String& name) const { |
| 3673 // Only set name once. | 3673 // Only set name once. |
| 3674 ASSERT(raw_ptr()->name_ == raw_ptr()->url_); | 3674 ASSERT(!Loaded()); |
| 3675 ASSERT(name.IsSymbol()); | 3675 ASSERT(name.IsSymbol()); |
| 3676 StorePointer(&raw_ptr()->name_, name.raw()); | 3676 StorePointer(&raw_ptr()->name_, name.raw()); |
| 3677 } | 3677 } |
| 3678 | 3678 |
| 3679 | 3679 |
| 3680 void Library::SetLoadInProgress() const { |
| 3681 // Should not be already loaded. |
| 3682 ASSERT(raw_ptr()->load_state_ == RawLibrary::kAllocated); |
| 3683 raw_ptr()->load_state_ = RawLibrary::kLoadInProgress; |
| 3684 } |
| 3685 |
| 3686 |
| 3687 void Library::SetLoaded() const { |
| 3688 // Should not be already loaded or just allocated. |
| 3689 ASSERT(LoadInProgress()); |
| 3690 raw_ptr()->load_state_ = RawLibrary::kLoaded; |
| 3691 } |
| 3692 |
| 3693 |
| 3694 void Library::SetLoadError() const { |
| 3695 // Should not be already loaded or just allocated. |
| 3696 ASSERT(LoadInProgress()); |
| 3697 raw_ptr()->load_state_ = RawLibrary::kLoadError; |
| 3698 } |
| 3699 |
| 3700 |
| 3680 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { | 3701 void Library::GrowDictionary(const Array& dict, intptr_t dict_size) const { |
| 3681 // TODO(iposva): Avoid exponential growth. | 3702 // TODO(iposva): Avoid exponential growth. |
| 3682 intptr_t new_dict_size = dict_size * 2; | 3703 intptr_t new_dict_size = dict_size * 2; |
| 3683 const Array& new_dict = | 3704 const Array& new_dict = |
| 3684 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); | 3705 Array::Handle(Array::New(new_dict_size + 1, Heap::kOld)); |
| 3685 // Rehash all elements from the original dictionary | 3706 // Rehash all elements from the original dictionary |
| 3686 // to the newly allocated array. | 3707 // to the newly allocated array. |
| 3687 Object& entry = Class::Handle(); | 3708 Object& entry = Class::Handle(); |
| 3688 String& entry_name = String::Handle(); | 3709 String& entry_name = String::Handle(); |
| 3689 Object& new_entry = Object::Handle(); | 3710 Object& new_entry = Object::Handle(); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4055 result.raw_ptr()->name_ = url.raw(); | 4076 result.raw_ptr()->name_ = url.raw(); |
| 4056 result.raw_ptr()->url_ = url.raw(); | 4077 result.raw_ptr()->url_ = url.raw(); |
| 4057 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); | 4078 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); |
| 4058 result.raw_ptr()->dictionary_ = Array::Empty(); | 4079 result.raw_ptr()->dictionary_ = Array::Empty(); |
| 4059 result.raw_ptr()->anonymous_classes_ = Array::Empty(); | 4080 result.raw_ptr()->anonymous_classes_ = Array::Empty(); |
| 4060 result.raw_ptr()->num_anonymous_ = 0; | 4081 result.raw_ptr()->num_anonymous_ = 0; |
| 4061 result.raw_ptr()->imports_ = Array::Empty(); | 4082 result.raw_ptr()->imports_ = Array::Empty(); |
| 4062 result.raw_ptr()->next_registered_ = Library::null(); | 4083 result.raw_ptr()->next_registered_ = Library::null(); |
| 4063 result.set_native_entry_resolver(NULL); | 4084 result.set_native_entry_resolver(NULL); |
| 4064 result.raw_ptr()->corelib_imported_ = true; | 4085 result.raw_ptr()->corelib_imported_ = true; |
| 4065 result.raw_ptr()->loaded_ = false; | 4086 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
| 4066 result.InitClassDictionary(); | 4087 result.InitClassDictionary(); |
| 4067 result.InitImportList(); | 4088 result.InitImportList(); |
| 4068 result.InitImportedIntoList(); | 4089 result.InitImportedIntoList(); |
| 4069 if (import_core_lib) { | 4090 if (import_core_lib) { |
| 4070 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4091 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4071 ASSERT(!core_lib.IsNull()); | 4092 ASSERT(!core_lib.IsNull()); |
| 4072 result.AddImport(core_lib); | 4093 result.AddImport(core_lib); |
| 4073 if (FLAG_expose_core_impl) { | 4094 if (FLAG_expose_core_impl) { |
| 4074 // Make implementation corelib visible to Dart code. | 4095 // Make implementation corelib visible to Dart code. |
| 4075 result.AddImport(Library::Handle(Library::CoreImplLibrary())); | 4096 result.AddImport(Library::Handle(Library::CoreImplLibrary())); |
| (...skipping 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6995 const String& str = String::Handle(pattern()); | 7016 const String& str = String::Handle(pattern()); |
| 6996 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7017 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 6997 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7018 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 6998 char* chars = reinterpret_cast<char*>( | 7019 char* chars = reinterpret_cast<char*>( |
| 6999 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7020 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 7000 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7021 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 7001 return chars; | 7022 return chars; |
| 7002 } | 7023 } |
| 7003 | 7024 |
| 7004 } // namespace dart | 7025 } // namespace dart |
| OLD | NEW |