| 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 "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 5921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5932 RawObject* raw = Object::Allocate(library_class, | 5932 RawObject* raw = Object::Allocate(library_class, |
| 5933 Library::InstanceSize(), | 5933 Library::InstanceSize(), |
| 5934 Heap::kOld); | 5934 Heap::kOld); |
| 5935 return reinterpret_cast<RawLibrary*>(raw); | 5935 return reinterpret_cast<RawLibrary*>(raw); |
| 5936 } | 5936 } |
| 5937 | 5937 |
| 5938 | 5938 |
| 5939 RawLibrary* Library::NewLibraryHelper(const String& url, | 5939 RawLibrary* Library::NewLibraryHelper(const String& url, |
| 5940 bool import_core_lib) { | 5940 bool import_core_lib) { |
| 5941 const Library& result = Library::Handle(Library::New()); | 5941 const Library& result = Library::Handle(Library::New()); |
| 5942 result.raw_ptr()->name_ = url.raw(); | 5942 result.StorePointer(&result.raw_ptr()->name_, url.raw()); |
| 5943 result.raw_ptr()->url_ = url.raw(); | 5943 result.StorePointer(&result.raw_ptr()->url_, url.raw()); |
| 5944 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); | 5944 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); |
| 5945 result.raw_ptr()->dictionary_ = Array::Empty(); | 5945 result.raw_ptr()->dictionary_ = Array::Empty(); |
| 5946 result.raw_ptr()->anonymous_classes_ = Array::Empty(); | 5946 result.raw_ptr()->anonymous_classes_ = Array::Empty(); |
| 5947 result.raw_ptr()->num_anonymous_ = 0; | 5947 result.raw_ptr()->num_anonymous_ = 0; |
| 5948 result.raw_ptr()->imports_ = Array::Empty(); | 5948 result.raw_ptr()->imports_ = Array::Empty(); |
| 5949 result.raw_ptr()->loaded_scripts_ = Array::null(); | 5949 result.raw_ptr()->loaded_scripts_ = Array::null(); |
| 5950 result.set_native_entry_resolver(NULL); | 5950 result.set_native_entry_resolver(NULL); |
| 5951 result.raw_ptr()->corelib_imported_ = true; | 5951 result.raw_ptr()->corelib_imported_ = true; |
| 5952 result.set_debuggable(false); | 5952 result.set_debuggable(false); |
| 5953 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; | 5953 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; |
| (...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7700 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 7700 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 7701 type_arguments ^= *FieldAddrAtOffset(field_offset); | 7701 type_arguments ^= *FieldAddrAtOffset(field_offset); |
| 7702 return type_arguments.raw(); | 7702 return type_arguments.raw(); |
| 7703 } | 7703 } |
| 7704 | 7704 |
| 7705 | 7705 |
| 7706 void Instance::SetTypeArguments(const AbstractTypeArguments& value) const { | 7706 void Instance::SetTypeArguments(const AbstractTypeArguments& value) const { |
| 7707 const Class& cls = Class::Handle(clazz()); | 7707 const Class& cls = Class::Handle(clazz()); |
| 7708 intptr_t field_offset = cls.type_arguments_instance_field_offset(); | 7708 intptr_t field_offset = cls.type_arguments_instance_field_offset(); |
| 7709 ASSERT(field_offset != Class::kNoTypeArguments); | 7709 ASSERT(field_offset != Class::kNoTypeArguments); |
| 7710 *FieldAddrAtOffset(field_offset) = value.raw(); | 7710 SetFieldAtOffset(field_offset, value); |
| 7711 } | 7711 } |
| 7712 | 7712 |
| 7713 | 7713 |
| 7714 bool Instance::IsInstanceOf(const AbstractType& other, | 7714 bool Instance::IsInstanceOf(const AbstractType& other, |
| 7715 const AbstractTypeArguments& other_instantiator, | 7715 const AbstractTypeArguments& other_instantiator, |
| 7716 Error* malformed_error) const { | 7716 Error* malformed_error) const { |
| 7717 ASSERT(other.IsFinalized()); | 7717 ASSERT(other.IsFinalized()); |
| 7718 ASSERT(!other.IsDynamicType()); | 7718 ASSERT(!other.IsDynamicType()); |
| 7719 ASSERT(!other.IsMalformed()); | 7719 ASSERT(!other.IsMalformed()); |
| 7720 if (IsNull()) { | 7720 if (IsNull()) { |
| (...skipping 2853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10574 NoGCScope no_gc; | 10574 NoGCScope no_gc; |
| 10575 result ^= raw; | 10575 result ^= raw; |
| 10576 } | 10576 } |
| 10577 result.set_function(function); | 10577 result.set_function(function); |
| 10578 result.set_context(context); | 10578 result.set_context(context); |
| 10579 return result.raw(); | 10579 return result.raw(); |
| 10580 } | 10580 } |
| 10581 | 10581 |
| 10582 | 10582 |
| 10583 void Closure::set_context(const Context& value) const { | 10583 void Closure::set_context(const Context& value) const { |
| 10584 raw_ptr()->context_ = value.raw(); | 10584 StorePointer(&raw_ptr()->context_, value.raw()); |
| 10585 } | 10585 } |
| 10586 | 10586 |
| 10587 | 10587 |
| 10588 void Closure::set_function(const Function& value) const { | 10588 void Closure::set_function(const Function& value) const { |
| 10589 raw_ptr()->function_ = value.raw(); | 10589 StorePointer(&raw_ptr()->function_, value.raw()); |
| 10590 } | 10590 } |
| 10591 | 10591 |
| 10592 | 10592 |
| 10593 const char* Closure::ToCString() const { | 10593 const char* Closure::ToCString() const { |
| 10594 const Function& fun = Function::Handle(function()); | 10594 const Function& fun = Function::Handle(function()); |
| 10595 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 10595 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
| 10596 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); | 10596 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); |
| 10597 const char* from = is_implicit_closure ? " from " : ""; | 10597 const char* from = is_implicit_closure ? " from " : ""; |
| 10598 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 10598 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
| 10599 const char* format = "Closure: %s%s%s"; | 10599 const char* format = "Closure: %s%s%s"; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10872 const String& str = String::Handle(pattern()); | 10872 const String& str = String::Handle(pattern()); |
| 10873 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10873 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10874 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10874 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10875 char* chars = reinterpret_cast<char*>( | 10875 char* chars = reinterpret_cast<char*>( |
| 10876 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10876 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10877 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10877 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10878 return chars; | 10878 return chars; |
| 10879 } | 10879 } |
| 10880 | 10880 |
| 10881 } // namespace dart | 10881 } // namespace dart |
| OLD | NEW |