Chromium Code Reviews| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 | 474 |
| 475 Class fake; | 475 Class fake; |
| 476 // Initialization from Class::New<Class>. | 476 // Initialization from Class::New<Class>. |
| 477 // Directly set raw_ to break a circular dependency: SetRaw will attempt | 477 // Directly set raw_ to break a circular dependency: SetRaw will attempt |
| 478 // to lookup class class in the class table where it is not registered yet. | 478 // to lookup class class in the class table where it is not registered yet. |
| 479 cls.raw_ = class_class_; | 479 cls.raw_ = class_class_; |
| 480 cls.set_handle_vtable(fake.vtable()); | 480 cls.set_handle_vtable(fake.vtable()); |
| 481 cls.set_instance_size(Class::InstanceSize()); | 481 cls.set_instance_size(Class::InstanceSize()); |
| 482 cls.set_next_field_offset(Class::InstanceSize()); | 482 cls.set_next_field_offset(Class::InstanceSize()); |
| 483 cls.set_id(Class::kClassId); | 483 cls.set_id(Class::kClassId); |
| 484 cls.raw_ptr()->state_bits_ = 0; | 484 cls.set_state_bits(0); |
| 485 cls.set_is_finalized(); | 485 cls.set_is_finalized(); |
| 486 cls.set_is_type_finalized(); | 486 cls.set_is_type_finalized(); |
| 487 cls.raw_ptr()->type_arguments_field_offset_in_words_ = | 487 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments); |
| 488 Class::kNoTypeArguments; | 488 cls.set_num_type_arguments(0); |
| 489 cls.raw_ptr()->num_native_fields_ = 0; | 489 cls.set_num_own_type_arguments(0); |
| 490 cls.set_num_native_fields(0); | |
| 490 cls.InitEmptyFields(); | 491 cls.InitEmptyFields(); |
| 491 isolate->RegisterClass(cls); | 492 isolate->RegisterClass(cls); |
| 492 } | 493 } |
| 493 | 494 |
| 494 // Allocate and initialize the null class. | 495 // Allocate and initialize the null class. |
| 495 cls = Class::New<Instance>(kNullCid); | 496 cls = Class::New<Instance>(kNullCid); |
| 496 isolate->object_store()->set_null_class(cls); | 497 isolate->object_store()->set_null_class(cls); |
| 497 | 498 |
| 498 // Allocate and initialize the free list element class. | 499 // Allocate and initialize the free list element class. |
| 499 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); | 500 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 Array::initializeHandle( | 631 Array::initializeHandle( |
| 631 empty_array_, | 632 empty_array_, |
| 632 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); | 633 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); |
| 633 empty_array_->raw()->ptr()->length_ = Smi::New(0); | 634 empty_array_->raw()->ptr()->length_ = Smi::New(0); |
| 634 } | 635 } |
| 635 | 636 |
| 636 cls = Class::New<Instance>(kDynamicCid); | 637 cls = Class::New<Instance>(kDynamicCid); |
| 637 cls.set_is_finalized(); | 638 cls.set_is_finalized(); |
| 638 cls.set_is_type_finalized(); | 639 cls.set_is_type_finalized(); |
| 639 cls.set_is_abstract(); | 640 cls.set_is_abstract(); |
| 641 cls.set_num_type_arguments(0); | |
| 642 cls.set_num_own_type_arguments(0); | |
| 640 dynamic_class_ = cls.raw(); | 643 dynamic_class_ = cls.raw(); |
| 641 | 644 |
| 642 cls = Class::New<Instance>(kVoidCid); | 645 cls = Class::New<Instance>(kVoidCid); |
| 643 cls.set_is_finalized(); | 646 cls.set_is_finalized(); |
| 644 cls.set_is_type_finalized(); | 647 cls.set_is_type_finalized(); |
| 648 cls.set_num_type_arguments(0); | |
| 649 cls.set_num_own_type_arguments(0); | |
| 645 void_class_ = cls.raw(); | 650 void_class_ = cls.raw(); |
| 646 | 651 |
| 647 cls = Class::New<Type>(); | 652 cls = Class::New<Type>(); |
| 648 cls.set_is_finalized(); | 653 cls.set_is_finalized(); |
| 649 cls.set_is_type_finalized(); | 654 cls.set_is_type_finalized(); |
| 655 cls.set_num_type_arguments(0); | |
| 656 cls.set_num_own_type_arguments(0); | |
| 650 isolate->object_store()->set_type_class(cls); | 657 isolate->object_store()->set_type_class(cls); |
| 651 | 658 |
| 652 cls = dynamic_class_; | 659 cls = dynamic_class_; |
| 653 dynamic_type_ = Type::NewNonParameterizedType(cls); | 660 dynamic_type_ = Type::NewNonParameterizedType(cls); |
| 654 | 661 |
| 655 cls = void_class_; | 662 cls = void_class_; |
| 656 void_type_ = Type::NewNonParameterizedType(cls); | 663 void_type_ = Type::NewNonParameterizedType(cls); |
| 657 | 664 |
| 658 // Allocate and initialize singleton true and false boolean objects. | 665 // Allocate and initialize singleton true and false boolean objects. |
| 659 cls = Class::New<Bool>(); | 666 cls = Class::New<Bool>(); |
| 667 cls.set_num_type_arguments(0); | |
| 668 cls.set_num_own_type_arguments(0); | |
| 660 isolate->object_store()->set_bool_class(cls); | 669 isolate->object_store()->set_bool_class(cls); |
| 661 *bool_true_ = Bool::New(true); | 670 *bool_true_ = Bool::New(true); |
| 662 *bool_false_ = Bool::New(false); | 671 *bool_false_ = Bool::New(false); |
| 663 | 672 |
| 664 *smi_illegal_cid_ = Smi::New(kIllegalCid); | 673 *smi_illegal_cid_ = Smi::New(kIllegalCid); |
| 665 | 674 |
| 666 String& error_str = String::Handle(); | 675 String& error_str = String::Handle(); |
| 667 error_str = String::New("SnapshotWriter Error"); | 676 error_str = String::New("SnapshotWriter Error"); |
| 668 *snapshot_writer_error_ = LanguageError::New(error_str); | 677 *snapshot_writer_error_ = LanguageError::New(error_str); |
| 669 error_str = String::New("Branch offset overflow"); | 678 error_str = String::New("Branch offset overflow"); |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1608 Heap::kOld); | 1617 Heap::kOld); |
| 1609 NoGCScope no_gc; | 1618 NoGCScope no_gc; |
| 1610 result ^= raw; | 1619 result ^= raw; |
| 1611 } | 1620 } |
| 1612 FakeObject fake; | 1621 FakeObject fake; |
| 1613 result.set_handle_vtable(fake.vtable()); | 1622 result.set_handle_vtable(fake.vtable()); |
| 1614 result.set_instance_size(FakeObject::InstanceSize()); | 1623 result.set_instance_size(FakeObject::InstanceSize()); |
| 1615 result.set_next_field_offset(FakeObject::InstanceSize()); | 1624 result.set_next_field_offset(FakeObject::InstanceSize()); |
| 1616 ASSERT((FakeObject::kClassId != kInstanceCid)); | 1625 ASSERT((FakeObject::kClassId != kInstanceCid)); |
| 1617 result.set_id(FakeObject::kClassId); | 1626 result.set_id(FakeObject::kClassId); |
| 1618 result.raw_ptr()->state_bits_ = 0; | 1627 result.set_state_bits(0); |
| 1619 // VM backed classes are almost ready: run checks and resolve class | 1628 // VM backed classes are almost ready: run checks and resolve class |
| 1620 // references, but do not recompute size. | 1629 // references, but do not recompute size. |
| 1621 result.set_is_prefinalized(); | 1630 result.set_is_prefinalized(); |
| 1622 result.raw_ptr()->type_arguments_field_offset_in_words_ = kNoTypeArguments; | 1631 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
| 1623 result.raw_ptr()->num_native_fields_ = 0; | 1632 result.set_num_type_arguments(kUnknownNumTypeArguments); |
| 1624 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; | 1633 result.set_num_own_type_arguments(kUnknownNumTypeArguments); |
| 1634 result.set_num_native_fields(0); | |
| 1635 result.set_token_pos(Scanner::kDummyTokenIndex); | |
| 1625 result.InitEmptyFields(); | 1636 result.InitEmptyFields(); |
| 1626 Isolate::Current()->RegisterClass(result); | 1637 Isolate::Current()->RegisterClass(result); |
| 1627 return result.raw(); | 1638 return result.raw(); |
| 1628 } | 1639 } |
| 1629 | 1640 |
| 1630 | 1641 |
| 1642 static RawError* FormatError(const Error& prev_error, | |
| 1643 const Script& script, | |
| 1644 intptr_t token_pos, | |
| 1645 const char* format, ...) { | |
| 1646 va_list args; | |
| 1647 va_start(args, format); | |
| 1648 if (prev_error.IsNull()) { | |
| 1649 return Parser::FormatError(script, token_pos, "Error", format, args); | |
| 1650 } else { | |
| 1651 return Parser::FormatErrorWithAppend(prev_error, script, token_pos, | |
| 1652 "Error", format, args); | |
| 1653 } | |
| 1654 } | |
| 1655 | |
| 1656 | |
| 1657 static void ReportTooManyTypeArguments(const Class& cls) { | |
| 1658 const Error& error = Error::Handle( | |
| 1659 FormatError(Error::Handle(), // No previous error. | |
| 1660 Script::Handle(cls.script()), cls.token_pos(), | |
| 1661 "too many type parameters declared in class '%s' or in its " | |
| 1662 "super classes", | |
| 1663 String::Handle(cls.Name()).ToCString())); | |
| 1664 Isolate::Current()->long_jump_base()->Jump(1, error); | |
| 1665 UNREACHABLE(); | |
| 1666 } | |
| 1667 | |
| 1668 | |
| 1669 void Class::set_num_type_arguments(intptr_t value) const { | |
| 1670 if (!Utils::IsInt(16, value)) { | |
| 1671 ReportTooManyTypeArguments(*this); | |
| 1672 } | |
| 1673 raw_ptr()->num_type_arguments_ = value; | |
| 1674 } | |
| 1675 | |
| 1676 | |
| 1677 void Class::set_num_own_type_arguments(intptr_t value) const { | |
| 1678 if (!Utils::IsInt(16, value)) { | |
| 1679 ReportTooManyTypeArguments(*this); | |
| 1680 } | |
| 1681 raw_ptr()->num_own_type_arguments_ = value; | |
| 1682 } | |
| 1683 | |
| 1684 | |
| 1631 // Initialize class fields of type Array with empty array. | 1685 // Initialize class fields of type Array with empty array. |
| 1632 void Class::InitEmptyFields() { | 1686 void Class::InitEmptyFields() { |
| 1633 if (Object::empty_array().raw() == Array::null()) { | 1687 if (Object::empty_array().raw() == Array::null()) { |
| 1634 // The empty array has not been initialized yet. | 1688 // The empty array has not been initialized yet. |
| 1635 return; | 1689 return; |
| 1636 } | 1690 } |
| 1637 StorePointer(&raw_ptr()->interfaces_, Object::empty_array().raw()); | 1691 StorePointer(&raw_ptr()->interfaces_, Object::empty_array().raw()); |
| 1638 StorePointer(&raw_ptr()->constants_, Object::empty_array().raw()); | 1692 StorePointer(&raw_ptr()->constants_, Object::empty_array().raw()); |
| 1639 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); | 1693 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); |
| 1640 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); | 1694 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1748 } | 1802 } |
| 1749 if (type_parameters() == TypeArguments::null()) { | 1803 if (type_parameters() == TypeArguments::null()) { |
| 1750 return 0; | 1804 return 0; |
| 1751 } | 1805 } |
| 1752 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1806 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1753 return type_params.Length(); | 1807 return type_params.Length(); |
| 1754 } | 1808 } |
| 1755 | 1809 |
| 1756 | 1810 |
| 1757 intptr_t Class::NumOwnTypeArguments() const { | 1811 intptr_t Class::NumOwnTypeArguments() const { |
| 1812 // Return cached value if already calculated. | |
| 1813 if (num_own_type_arguments() != kUnknownNumTypeArguments) { | |
| 1814 return num_own_type_arguments(); | |
| 1815 } | |
| 1758 Isolate* isolate = Isolate::Current(); | 1816 Isolate* isolate = Isolate::Current(); |
| 1759 const intptr_t num_type_params = NumTypeParameters(); | 1817 const intptr_t num_type_params = NumTypeParameters(); |
| 1760 if (!FLAG_overlap_type_arguments || | 1818 if (!FLAG_overlap_type_arguments || |
| 1761 (num_type_params == 0) || | 1819 (num_type_params == 0) || |
| 1762 (super_type() == AbstractType::null()) || | 1820 (super_type() == AbstractType::null()) || |
| 1763 (super_type() == isolate->object_store()->object_type())) { | 1821 (super_type() == isolate->object_store()->object_type())) { |
| 1822 set_num_own_type_arguments(num_type_params); | |
| 1764 return num_type_params; | 1823 return num_type_params; |
| 1765 } | 1824 } |
| 1766 ASSERT(!IsMixinApplication() || is_mixin_type_applied()); | 1825 ASSERT(!IsMixinApplication() || is_mixin_type_applied()); |
| 1767 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type()); | 1826 const AbstractType& sup_type = AbstractType::Handle(isolate, super_type()); |
| 1768 ASSERT(sup_type.IsResolved()); | 1827 ASSERT(sup_type.IsResolved()); |
| 1769 const AbstractTypeArguments& sup_type_args = | 1828 const AbstractTypeArguments& sup_type_args = |
| 1770 AbstractTypeArguments::Handle(isolate, sup_type.arguments()); | 1829 AbstractTypeArguments::Handle(isolate, sup_type.arguments()); |
| 1771 if (sup_type_args.IsNull()) { | 1830 if (sup_type_args.IsNull()) { |
| 1772 // The super type is raw or the super class is non generic. | 1831 // The super type is raw or the super class is non generic. |
| 1773 // In either case, overlapping is not possible. | 1832 // In either case, overlapping is not possible. |
| 1833 set_num_own_type_arguments(num_type_params); | |
| 1774 return num_type_params; | 1834 return num_type_params; |
| 1775 } | 1835 } |
| 1776 const intptr_t num_sup_type_args = sup_type_args.Length(); | 1836 const intptr_t num_sup_type_args = sup_type_args.Length(); |
| 1777 // At this point, the super type may or may not be finalized. In either case, | 1837 // At this point, the super type may or may not be finalized. In either case, |
| 1778 // the result of this function must remain the same. | 1838 // the result of this function must remain the same. |
| 1779 // The value of num_sup_type_args may increase when the super type is | 1839 // The value of num_sup_type_args may increase when the super type is |
| 1780 // finalized, but the last num_sup_type_args type arguments will not be | 1840 // finalized, but the last num_sup_type_args type arguments will not be |
| 1781 // modified by finalization, only shifted to higher indices in the vector. | 1841 // modified by finalization, only shifted to higher indices in the vector. |
| 1782 // They may however get wrapped in a BoundedType, which we skip. | 1842 // They may however get wrapped in a BoundedType, which we skip. |
| 1783 const AbstractTypeArguments& type_params = | 1843 const AbstractTypeArguments& type_params = |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1803 num_sup_type_args - num_overlapping_type_args + i); | 1863 num_sup_type_args - num_overlapping_type_args + i); |
| 1804 // BoundedType can nest in case the finalized super type has bounded type | 1864 // BoundedType can nest in case the finalized super type has bounded type |
| 1805 // arguments that overlap multiple times in its own super class chain. | 1865 // arguments that overlap multiple times in its own super class chain. |
| 1806 while (sup_type_arg.IsBoundedType()) { | 1866 while (sup_type_arg.IsBoundedType()) { |
| 1807 sup_type_arg = BoundedType::Cast(sup_type_arg).type(); | 1867 sup_type_arg = BoundedType::Cast(sup_type_arg).type(); |
| 1808 } | 1868 } |
| 1809 if (!type_param.Equals(sup_type_arg)) break; | 1869 if (!type_param.Equals(sup_type_arg)) break; |
| 1810 } | 1870 } |
| 1811 if (i == num_overlapping_type_args) { | 1871 if (i == num_overlapping_type_args) { |
| 1812 // Overlap found. | 1872 // Overlap found. |
| 1873 set_num_own_type_arguments(num_type_params - num_overlapping_type_args); | |
| 1813 return num_type_params - num_overlapping_type_args; | 1874 return num_type_params - num_overlapping_type_args; |
| 1814 } | 1875 } |
| 1815 } | 1876 } |
| 1816 // No overlap found. | 1877 // No overlap found. |
| 1878 set_num_own_type_arguments(num_type_params); | |
| 1817 return num_type_params; | 1879 return num_type_params; |
| 1818 } | 1880 } |
| 1819 | 1881 |
| 1820 | 1882 |
| 1821 intptr_t Class::NumTypeArguments() const { | 1883 intptr_t Class::NumTypeArguments() const { |
| 1884 // Return cached value if already calculated. | |
| 1885 if (num_type_arguments() != kUnknownNumTypeArguments) { | |
| 1886 return num_type_arguments(); | |
| 1887 } | |
| 1822 // To work properly, this call requires the super class of this class to be | 1888 // To work properly, this call requires the super class of this class to be |
| 1823 // resolved, which is checked by the type_class() call on the super type. | 1889 // resolved, which is checked by the type_class() call on the super type. |
| 1824 // Note that calling type_class() on a MixinAppType fails. | 1890 // Note that calling type_class() on a MixinAppType fails. |
| 1825 Isolate* isolate = Isolate::Current(); | 1891 Isolate* isolate = Isolate::Current(); |
| 1826 Class& cls = Class::Handle(isolate); | 1892 Class& cls = Class::Handle(isolate); |
| 1827 AbstractType& sup_type = AbstractType::Handle(isolate); | 1893 AbstractType& sup_type = AbstractType::Handle(isolate); |
| 1828 cls = raw(); | 1894 cls = raw(); |
| 1829 intptr_t num_type_args = 0; | 1895 intptr_t num_type_args = 0; |
| 1830 do { | 1896 do { |
| 1831 if (cls.IsSignatureClass()) { | 1897 if (cls.IsSignatureClass()) { |
| 1832 Function& signature_fun = Function::Handle(isolate); | 1898 Function& signature_fun = Function::Handle(isolate); |
| 1833 signature_fun ^= cls.signature_function(); | 1899 signature_fun ^= cls.signature_function(); |
| 1834 if (!signature_fun.is_static() && | 1900 if (!signature_fun.is_static() && |
| 1835 !signature_fun.HasInstantiatedSignature()) { | 1901 !signature_fun.HasInstantiatedSignature()) { |
| 1836 cls = signature_fun.Owner(); | 1902 cls = signature_fun.Owner(); |
| 1837 } | 1903 } |
| 1838 } | 1904 } |
| 1839 // Calling NumOwnTypeArguments() on a mixin application class will setup the | 1905 // Calling NumOwnTypeArguments() on a mixin application class will setup the |
| 1840 // type parameters if not already done. | 1906 // type parameters if not already done. |
| 1841 num_type_args += cls.NumOwnTypeArguments(); | 1907 num_type_args += cls.NumOwnTypeArguments(); |
| 1842 // Super type of Object class is null. | 1908 // Super type of Object class is null. |
| 1843 if ((cls.super_type() == AbstractType::null()) || | 1909 if ((cls.super_type() == AbstractType::null()) || |
| 1844 (cls.super_type() == isolate->object_store()->object_type())) { | 1910 (cls.super_type() == isolate->object_store()->object_type())) { |
| 1845 break; | 1911 break; |
| 1846 } | 1912 } |
| 1847 sup_type = cls.super_type(); | 1913 sup_type = cls.super_type(); |
| 1848 cls = sup_type.type_class(); | 1914 cls = sup_type.type_class(); |
| 1849 } while (true); | 1915 } while (true); |
| 1916 set_num_type_arguments(num_type_args); | |
| 1850 return num_type_args; | 1917 return num_type_args; |
| 1851 } | 1918 } |
| 1852 | 1919 |
| 1853 | 1920 |
| 1854 // More efficient than calling NumTypeArguments(). | 1921 // More efficient than calling NumTypeArguments(). |
| 1855 bool Class::HasTypeArguments() const { | 1922 bool Class::HasTypeArguments() const { |
|
siva
2013/10/15 00:06:57
Is this HasTypeArguments optimization necessary an
regis
2013/10/15 17:49:15
You are right. This is now overkill. I have remove
| |
| 1923 // Check cached number of type arguments if already calculated. | |
| 1924 if (num_type_arguments() != kUnknownNumTypeArguments) { | |
| 1925 return num_type_arguments() > 0; | |
| 1926 } | |
| 1856 // Fast check for a non-signature finalized class. | 1927 // Fast check for a non-signature finalized class. |
| 1857 if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) { | 1928 if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) { |
| 1858 return type_arguments_field_offset() != kNoTypeArguments; | 1929 return type_arguments_field_offset() != kNoTypeArguments; |
| 1859 } | 1930 } |
| 1860 Isolate* isolate = Isolate::Current(); | 1931 Isolate* isolate = Isolate::Current(); |
| 1861 Class& cls = Class::Handle(isolate); | 1932 Class& cls = Class::Handle(isolate); |
| 1862 cls = raw(); | 1933 cls = raw(); |
| 1863 do { | 1934 do { |
| 1864 if (cls.IsSignatureClass()) { | 1935 if (cls.IsSignatureClass()) { |
| 1865 Function& signature_fun = Function::Handle(isolate); | 1936 Function& signature_fun = Function::Handle(isolate); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2086 // Prefinalized classes have a VM internal representation and no Dart fields. | 2157 // Prefinalized classes have a VM internal representation and no Dart fields. |
| 2087 // Their instance size is precomputed and field offsets are known. | 2158 // Their instance size is precomputed and field offsets are known. |
| 2088 if (!is_prefinalized()) { | 2159 if (!is_prefinalized()) { |
| 2089 // Compute offsets of instance fields and instance size. | 2160 // Compute offsets of instance fields and instance size. |
| 2090 CalculateFieldOffsets(); | 2161 CalculateFieldOffsets(); |
| 2091 } | 2162 } |
| 2092 set_is_finalized(); | 2163 set_is_finalized(); |
| 2093 } | 2164 } |
| 2094 | 2165 |
| 2095 | 2166 |
| 2096 static RawError* FormatError(const Error& prev_error, | |
| 2097 const Script& script, | |
| 2098 intptr_t token_pos, | |
| 2099 const char* format, ...) { | |
| 2100 va_list args; | |
| 2101 va_start(args, format); | |
| 2102 if (prev_error.IsNull()) { | |
| 2103 return Parser::FormatError(script, token_pos, "Error", format, args); | |
| 2104 } else { | |
| 2105 return Parser::FormatErrorWithAppend(prev_error, script, token_pos, | |
| 2106 "Error", format, args); | |
| 2107 } | |
| 2108 } | |
| 2109 | |
| 2110 | |
| 2111 // Apply the members from the patch class to the original class. | 2167 // Apply the members from the patch class to the original class. |
| 2112 bool Class::ApplyPatch(const Class& patch, Error* error) const { | 2168 bool Class::ApplyPatch(const Class& patch, Error* error) const { |
| 2113 ASSERT(error != NULL); | 2169 ASSERT(error != NULL); |
| 2114 ASSERT(!is_finalized()); | 2170 ASSERT(!is_finalized()); |
| 2115 // Shared handles used during the iteration. | 2171 // Shared handles used during the iteration. |
| 2116 String& member_name = String::Handle(); | 2172 String& member_name = String::Handle(); |
| 2117 | 2173 |
| 2118 const PatchClass& patch_class = | 2174 const PatchClass& patch_class = |
| 2119 PatchClass::Handle(PatchClass::New(*this, patch)); | 2175 PatchClass::Handle(PatchClass::New(*this, patch)); |
| 2120 | 2176 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2306 Heap::kOld); | 2362 Heap::kOld); |
| 2307 NoGCScope no_gc; | 2363 NoGCScope no_gc; |
| 2308 result ^= raw; | 2364 result ^= raw; |
| 2309 } | 2365 } |
| 2310 FakeInstance fake; | 2366 FakeInstance fake; |
| 2311 ASSERT(fake.IsInstance()); | 2367 ASSERT(fake.IsInstance()); |
| 2312 result.set_handle_vtable(fake.vtable()); | 2368 result.set_handle_vtable(fake.vtable()); |
| 2313 result.set_instance_size(FakeInstance::InstanceSize()); | 2369 result.set_instance_size(FakeInstance::InstanceSize()); |
| 2314 result.set_next_field_offset(FakeInstance::InstanceSize()); | 2370 result.set_next_field_offset(FakeInstance::InstanceSize()); |
| 2315 result.set_id(index); | 2371 result.set_id(index); |
| 2316 result.raw_ptr()->state_bits_ = 0; | 2372 result.set_state_bits(0); |
| 2317 result.raw_ptr()->type_arguments_field_offset_in_words_ = kNoTypeArguments; | 2373 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
| 2318 result.raw_ptr()->num_native_fields_ = 0; | 2374 result.set_num_type_arguments(kUnknownNumTypeArguments); |
| 2319 result.raw_ptr()->token_pos_ = Scanner::kDummyTokenIndex; | 2375 result.set_num_own_type_arguments(kUnknownNumTypeArguments); |
| 2376 result.set_num_native_fields(0); | |
| 2377 result.set_token_pos(Scanner::kDummyTokenIndex); | |
| 2320 result.InitEmptyFields(); | 2378 result.InitEmptyFields(); |
| 2321 Isolate::Current()->RegisterClass(result); | 2379 Isolate::Current()->RegisterClass(result); |
| 2322 return result.raw(); | 2380 return result.raw(); |
| 2323 } | 2381 } |
| 2324 | 2382 |
| 2325 | 2383 |
| 2326 RawClass* Class::New(const String& name, | 2384 RawClass* Class::New(const String& name, |
| 2327 const Script& script, | 2385 const Script& script, |
| 2328 intptr_t token_pos) { | 2386 intptr_t token_pos) { |
| 2329 Class& result = Class::Handle(New<Instance>(kIllegalCid)); | 2387 Class& result = Class::Handle(New<Instance>(kIllegalCid)); |
| (...skipping 13153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15483 return "_MirrorReference"; | 15541 return "_MirrorReference"; |
| 15484 } | 15542 } |
| 15485 | 15543 |
| 15486 | 15544 |
| 15487 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15545 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 15488 JSONObject jsobj(stream); | 15546 JSONObject jsobj(stream); |
| 15489 } | 15547 } |
| 15490 | 15548 |
| 15491 | 15549 |
| 15492 } // namespace dart | 15550 } // namespace dart |
| OLD | NEW |