| 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 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 Array::Handle(Array::Grow(canonical_list, new_length, Heap::kOld)); | 1742 Array::Handle(Array::Grow(canonical_list, new_length, Heap::kOld)); |
| 1743 set_constants(new_canonical_list); | 1743 set_constants(new_canonical_list); |
| 1744 new_canonical_list.SetAt(index, constant); | 1744 new_canonical_list.SetAt(index, constant); |
| 1745 } else { | 1745 } else { |
| 1746 canonical_list.SetAt(index, constant); | 1746 canonical_list.SetAt(index, constant); |
| 1747 } | 1747 } |
| 1748 } | 1748 } |
| 1749 | 1749 |
| 1750 | 1750 |
| 1751 RawUnresolvedClass* UnresolvedClass::New(intptr_t token_index, | 1751 RawUnresolvedClass* UnresolvedClass::New(intptr_t token_index, |
| 1752 const String& qualifier, | 1752 const LibraryPrefix& library_prefix, |
| 1753 const String& ident) { | 1753 const String& ident) { |
| 1754 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); | 1754 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); |
| 1755 type.set_token_index(token_index); | 1755 type.set_token_index(token_index); |
| 1756 type.set_qualifier(qualifier); | 1756 type.set_library_prefix(library_prefix); |
| 1757 type.set_ident(ident); | 1757 type.set_ident(ident); |
| 1758 return type.raw(); | 1758 return type.raw(); |
| 1759 } | 1759 } |
| 1760 | 1760 |
| 1761 | 1761 |
| 1762 RawUnresolvedClass* UnresolvedClass::New() { | 1762 RawUnresolvedClass* UnresolvedClass::New() { |
| 1763 const Class& unresolved_class_class = | 1763 const Class& unresolved_class_class = |
| 1764 Class::Handle(Object::unresolved_class_class()); | 1764 Class::Handle(Object::unresolved_class_class()); |
| 1765 RawObject* raw = Object::Allocate(unresolved_class_class, | 1765 RawObject* raw = Object::Allocate(unresolved_class_class, |
| 1766 UnresolvedClass::InstanceSize(), | 1766 UnresolvedClass::InstanceSize(), |
| 1767 Heap::kNew); | 1767 Heap::kNew); |
| 1768 return reinterpret_cast<RawUnresolvedClass*>(raw); | 1768 return reinterpret_cast<RawUnresolvedClass*>(raw); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 | 1771 |
| 1772 void UnresolvedClass::set_token_index(intptr_t token_index) const { | 1772 void UnresolvedClass::set_token_index(intptr_t token_index) const { |
| 1773 raw_ptr()->token_index_ = token_index; | 1773 raw_ptr()->token_index_ = token_index; |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 | 1776 |
| 1777 void UnresolvedClass::set_ident(const String& ident) const { | 1777 void UnresolvedClass::set_ident(const String& ident) const { |
| 1778 StorePointer(&raw_ptr()->ident_, ident.raw()); | 1778 StorePointer(&raw_ptr()->ident_, ident.raw()); |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 | 1781 |
| 1782 void UnresolvedClass::set_qualifier(const String& qualifier) const { | 1782 void UnresolvedClass::set_library_prefix( |
| 1783 StorePointer(&raw_ptr()->qualifier_, qualifier.raw()); | 1783 const LibraryPrefix& library_prefix) const { |
| 1784 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw()); |
| 1784 } | 1785 } |
| 1785 | 1786 |
| 1786 | 1787 |
| 1787 void UnresolvedClass::set_factory_signature_class(const Class& value) const { | 1788 void UnresolvedClass::set_factory_signature_class(const Class& value) const { |
| 1788 StorePointer(&raw_ptr()->factory_signature_class_, value.raw()); | 1789 StorePointer(&raw_ptr()->factory_signature_class_, value.raw()); |
| 1789 } | 1790 } |
| 1790 | 1791 |
| 1791 | 1792 |
| 1792 RawString* UnresolvedClass::Name() const { | 1793 RawString* UnresolvedClass::Name() const { |
| 1793 if (qualifier() != String::null()) { | 1794 if (library_prefix() != LibraryPrefix::null()) { |
| 1795 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); |
| 1794 String& name = String::Handle(); | 1796 String& name = String::Handle(); |
| 1795 name = qualifier(); | |
| 1796 String& str = String::Handle(); | 1797 String& str = String::Handle(); |
| 1798 name = lib_prefix.name(); // Qualifier. |
| 1797 str = String::New("."); | 1799 str = String::New("."); |
| 1798 name = String::Concat(name, str); | 1800 name = String::Concat(name, str); |
| 1799 str = ident(); | 1801 str = ident(); |
| 1800 name = String::Concat(name, str); | 1802 name = String::Concat(name, str); |
| 1801 return name.raw(); | 1803 return name.raw(); |
| 1802 } else { | 1804 } else { |
| 1803 return ident(); | 1805 return ident(); |
| 1804 } | 1806 } |
| 1805 } | 1807 } |
| 1806 | 1808 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2132 | 2134 |
| 2133 | 2135 |
| 2134 RawType* Type::ListInterface() { | 2136 RawType* Type::ListInterface() { |
| 2135 return Isolate::Current()->object_store()->list_interface(); | 2137 return Isolate::Current()->object_store()->list_interface(); |
| 2136 } | 2138 } |
| 2137 | 2139 |
| 2138 | 2140 |
| 2139 RawType* Type::NewRawType(const Class& type_class) { | 2141 RawType* Type::NewRawType(const Class& type_class) { |
| 2140 const AbstractTypeArguments& type_arguments = | 2142 const AbstractTypeArguments& type_arguments = |
| 2141 AbstractTypeArguments::Handle(type_class.type_parameter_extends()); | 2143 AbstractTypeArguments::Handle(type_class.type_parameter_extends()); |
| 2142 return NewParameterizedType(Object::Handle(type_class.raw()), type_arguments); | 2144 return New(Object::Handle(type_class.raw()), type_arguments); |
| 2143 } | 2145 } |
| 2144 | 2146 |
| 2145 | 2147 |
| 2146 RawType* Type::NewNonParameterizedType( | 2148 RawType* Type::NewNonParameterizedType( |
| 2147 const Class& type_class) { | 2149 const Class& type_class) { |
| 2148 ASSERT(!type_class.HasTypeArguments()); | 2150 ASSERT(!type_class.HasTypeArguments()); |
| 2149 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 2151 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
| 2150 Type& type = Type::Handle(); | 2152 Type& type = Type::Handle(); |
| 2151 type ^= Type::New( | 2153 type ^= Type::New( |
| 2152 Object::Handle(type_class.raw()), no_type_arguments); | 2154 Object::Handle(type_class.raw()), no_type_arguments); |
| 2153 type.set_is_finalized(); | 2155 type.set_is_finalized(); |
| 2154 type ^= type.Canonicalize(); | 2156 type ^= type.Canonicalize(); |
| 2155 return type.raw(); | 2157 return type.raw(); |
| 2156 } | 2158 } |
| 2157 | 2159 |
| 2158 | 2160 |
| 2159 RawType* Type::NewParameterizedType(const Object& clazz, | |
| 2160 const AbstractTypeArguments& arguments) { | |
| 2161 return Type::New(clazz, arguments); | |
| 2162 } | |
| 2163 | |
| 2164 | |
| 2165 void Type::set_is_finalized() const { | 2161 void Type::set_is_finalized() const { |
| 2166 ASSERT(!IsFinalized()); | 2162 ASSERT(!IsFinalized()); |
| 2167 set_type_state(RawType::kFinalized); | 2163 set_type_state(RawType::kFinalized); |
| 2168 } | 2164 } |
| 2169 | 2165 |
| 2170 | 2166 |
| 2171 void Type::set_is_being_finalized() const { | 2167 void Type::set_is_being_finalized() const { |
| 2172 ASSERT(!IsFinalized() && !IsBeingFinalized()); | 2168 ASSERT(!IsFinalized() && !IsBeingFinalized()); |
| 2173 set_type_state(RawType::kBeingFinalized); | 2169 set_type_state(RawType::kBeingFinalized); |
| 2174 } | 2170 } |
| (...skipping 3470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 // Can occur when running disassembler. | 5641 // Can occur when running disassembler. |
| 5646 return "Instance"; | 5642 return "Instance"; |
| 5647 } else { | 5643 } else { |
| 5648 const char* kFormat = "Instance of '%s'"; | 5644 const char* kFormat = "Instance of '%s'"; |
| 5649 Class& cls = Class::Handle(clazz()); | 5645 Class& cls = Class::Handle(clazz()); |
| 5650 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 5646 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 5651 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 5647 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
| 5652 if (num_type_arguments > 0) { | 5648 if (num_type_arguments > 0) { |
| 5653 type_arguments = GetTypeArguments(); | 5649 type_arguments = GetTypeArguments(); |
| 5654 } | 5650 } |
| 5655 const Type& type = Type::Handle( | 5651 const Type& type = Type::Handle(Type::New(cls, type_arguments)); |
| 5656 Type::NewParameterizedType(cls, type_arguments)); | |
| 5657 const String& type_name = String::Handle(type.Name()); | 5652 const String& type_name = String::Handle(type.Name()); |
| 5658 // Calculate the size of the string. | 5653 // Calculate the size of the string. |
| 5659 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 5654 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; |
| 5660 char* chars = reinterpret_cast<char*>( | 5655 char* chars = reinterpret_cast<char*>( |
| 5661 Isolate::Current()->current_zone()->Allocate(len)); | 5656 Isolate::Current()->current_zone()->Allocate(len)); |
| 5662 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | 5657 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); |
| 5663 return chars; | 5658 return chars; |
| 5664 } | 5659 } |
| 5665 } | 5660 } |
| 5666 | 5661 |
| (...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7882 const String& str = String::Handle(pattern()); | 7877 const String& str = String::Handle(pattern()); |
| 7883 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7878 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 7884 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7879 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 7885 char* chars = reinterpret_cast<char*>( | 7880 char* chars = reinterpret_cast<char*>( |
| 7886 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7881 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 7887 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7882 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 7888 return chars; | 7883 return chars; |
| 7889 } | 7884 } |
| 7890 | 7885 |
| 7891 } // namespace dart | 7886 } // namespace dart |
| OLD | NEW |