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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 // Setup type class early in the process. | 698 // Setup type class early in the process. |
699 cls = Class::New<Type>(); | 699 cls = Class::New<Type>(); |
700 object_store->set_type_class(cls); | 700 object_store->set_type_class(cls); |
701 | 701 |
702 cls = Class::New<TypeParameter>(); | 702 cls = Class::New<TypeParameter>(); |
703 object_store->set_type_parameter_class(cls); | 703 object_store->set_type_parameter_class(cls); |
704 | 704 |
705 cls = Class::New<BoundedType>(); | 705 cls = Class::New<BoundedType>(); |
706 object_store->set_bounded_type_class(cls); | 706 object_store->set_bounded_type_class(cls); |
707 | 707 |
708 cls = Class::New<MixinAppType>(); | |
709 object_store->set_mixin_app_type_class(cls); | |
710 | |
708 // Pre-allocate the OneByteString class needed by the symbol table. | 711 // Pre-allocate the OneByteString class needed by the symbol table. |
709 cls = Class::NewStringClass(kOneByteStringCid); | 712 cls = Class::NewStringClass(kOneByteStringCid); |
710 object_store->set_one_byte_string_class(cls); | 713 object_store->set_one_byte_string_class(cls); |
711 | 714 |
712 // Pre-allocate the TwoByteString class needed by the symbol table. | 715 // Pre-allocate the TwoByteString class needed by the symbol table. |
713 cls = Class::NewStringClass(kTwoByteStringCid); | 716 cls = Class::NewStringClass(kTwoByteStringCid); |
714 object_store->set_two_byte_string_class(cls); | 717 object_store->set_two_byte_string_class(cls); |
715 | 718 |
716 // Setup the symbol table for the symbols created in the isolate. | 719 // Setup the symbol table for the symbols created in the isolate. |
717 Symbols::SetupSymbolTable(isolate); | 720 Symbols::SetupSymbolTable(isolate); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1043 | 1046 |
1044 cls = Class::New<Type>(); | 1047 cls = Class::New<Type>(); |
1045 object_store->set_type_class(cls); | 1048 object_store->set_type_class(cls); |
1046 | 1049 |
1047 cls = Class::New<TypeParameter>(); | 1050 cls = Class::New<TypeParameter>(); |
1048 object_store->set_type_parameter_class(cls); | 1051 object_store->set_type_parameter_class(cls); |
1049 | 1052 |
1050 cls = Class::New<BoundedType>(); | 1053 cls = Class::New<BoundedType>(); |
1051 object_store->set_bounded_type_class(cls); | 1054 object_store->set_bounded_type_class(cls); |
1052 | 1055 |
1056 cls = Class::New<MixinAppType>(); | |
1057 object_store->set_mixin_app_type_class(cls); | |
1058 | |
1053 cls = Class::New<Array>(); | 1059 cls = Class::New<Array>(); |
1054 object_store->set_array_class(cls); | 1060 object_store->set_array_class(cls); |
1055 | 1061 |
1056 cls = Class::New<ImmutableArray>(); | 1062 cls = Class::New<ImmutableArray>(); |
1057 object_store->set_immutable_array_class(cls); | 1063 object_store->set_immutable_array_class(cls); |
1058 | 1064 |
1059 cls = Class::New<GrowableObjectArray>(); | 1065 cls = Class::New<GrowableObjectArray>(); |
1060 object_store->set_growable_object_array_class(cls); | 1066 object_store->set_growable_object_array_class(cls); |
1061 | 1067 |
1062 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ | 1068 #define REGISTER_SCALARLIST_CLASS(name, object_store_name) \ |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 RawClass* Class::SuperClass() const { | 1592 RawClass* Class::SuperClass() const { |
1587 const AbstractType& sup_type = AbstractType::Handle(super_type()); | 1593 const AbstractType& sup_type = AbstractType::Handle(super_type()); |
1588 if (sup_type.IsNull()) { | 1594 if (sup_type.IsNull()) { |
1589 return Class::null(); | 1595 return Class::null(); |
1590 } | 1596 } |
1591 return sup_type.type_class(); | 1597 return sup_type.type_class(); |
1592 } | 1598 } |
1593 | 1599 |
1594 | 1600 |
1595 void Class::set_super_type(const AbstractType& value) const { | 1601 void Class::set_super_type(const AbstractType& value) const { |
1596 ASSERT(value.IsNull() || value.IsType() || value.IsBoundedType()); | 1602 ASSERT(value.IsNull() || |
1603 value.IsType() || | |
1604 value.IsBoundedType() || | |
1605 value.IsMixinAppType()); | |
1597 StorePointer(&raw_ptr()->super_type_, value.raw()); | 1606 StorePointer(&raw_ptr()->super_type_, value.raw()); |
1598 } | 1607 } |
1599 | 1608 |
1600 | 1609 |
1601 // Return a TypeParameter if the type_name is a type parameter of this class. | 1610 // Return a TypeParameter if the type_name is a type parameter of this class. |
1602 // Return null otherwise. | 1611 // Return null otherwise. |
1603 RawTypeParameter* Class::LookupTypeParameter(const String& type_name, | 1612 RawTypeParameter* Class::LookupTypeParameter(const String& type_name, |
1604 intptr_t token_pos) const { | 1613 intptr_t token_pos) const { |
1605 ASSERT(!type_name.IsNull()); | 1614 ASSERT(!type_name.IsNull()); |
1606 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1615 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
(...skipping 8264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9871 const char* cls_cstr = | 9880 const char* cls_cstr = |
9872 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString(); | 9881 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString(); |
9873 intptr_t len = OS::SNPrint( | 9882 intptr_t len = OS::SNPrint( |
9874 NULL, 0, format, type_cstr, bound_cstr, cls_cstr) + 1; | 9883 NULL, 0, format, type_cstr, bound_cstr, cls_cstr) + 1; |
9875 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 9884 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
9876 OS::SNPrint(chars, len, format, type_cstr, bound_cstr, cls_cstr); | 9885 OS::SNPrint(chars, len, format, type_cstr, bound_cstr, cls_cstr); |
9877 return chars; | 9886 return chars; |
9878 } | 9887 } |
9879 | 9888 |
9880 | 9889 |
9890 | |
9891 RawString* MixinAppType::Name() const { | |
9892 return String::New("MixinApplication"); | |
9893 } | |
9894 | |
9895 | |
9896 // The mixin type is resolved if the super type and all mixin | |
9897 // types are resolved. | |
9898 bool MixinAppType::IsResolved() const { | |
regis
2013/03/14 23:40:34
I do not think this call is necessary. By definiti
hausner
2013/03/15 00:36:32
Done.
| |
9899 AbstractType& type = AbstractType::Handle(super_type()); | |
9900 if (!type.IsResolved()) { | |
9901 return false; | |
9902 } | |
9903 const Array& mixins = Array::Handle(mixin_types()); | |
9904 for (int i = 0; i < mixins.Length(); i++) { | |
9905 type ^= mixins.At(i); | |
9906 if (!type.IsResolved()) { | |
9907 return false; | |
9908 } | |
9909 } | |
9910 return true; | |
9911 } | |
9912 | |
9913 | |
9914 const char* MixinAppType::ToCString() const { | |
9915 return "MixinAppType"; | |
9916 } | |
9917 | |
9918 | |
9919 void MixinAppType::set_super_type(const AbstractType& value) const { | |
9920 StorePointer(&raw_ptr()->super_type_, value.raw()); | |
9921 } | |
9922 | |
9923 | |
9924 void MixinAppType::set_mixin_types(const Array& value) const { | |
9925 StorePointer(&raw_ptr()->mixin_types_, value.raw()); | |
9926 } | |
9927 | |
9928 | |
9929 RawMixinAppType* MixinAppType::New() { | |
9930 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() != | |
9931 Class::null()); | |
9932 // MixinAppType objects do not survive finalization, so allocate | |
9933 // on new heap. | |
9934 RawObject* raw = Object::Allocate(MixinAppType::kClassId, | |
9935 MixinAppType::InstanceSize(), | |
9936 Heap::kNew); | |
9937 return reinterpret_cast<RawMixinAppType*>(raw); | |
9938 } | |
9939 | |
9940 | |
9941 RawMixinAppType* MixinAppType::New(const AbstractType& super_type, | |
9942 const Array& mixin_types) { | |
9943 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New()); | |
9944 result.set_super_type(super_type); | |
9945 result.set_mixin_types(mixin_types); | |
9946 return result.raw(); | |
9947 } | |
9948 | |
9949 | |
9881 const char* Number::ToCString() const { | 9950 const char* Number::ToCString() const { |
9882 // Number is an interface. No instances of Number should exist. | 9951 // Number is an interface. No instances of Number should exist. |
9883 UNREACHABLE(); | 9952 UNREACHABLE(); |
9884 return "Number"; | 9953 return "Number"; |
9885 } | 9954 } |
9886 | 9955 |
9887 | 9956 |
9888 const char* Integer::ToCString() const { | 9957 const char* Integer::ToCString() const { |
9889 // Integer is an interface. No instances of Integer should exist. | 9958 // Integer is an interface. No instances of Integer should exist. |
9890 UNREACHABLE(); | 9959 UNREACHABLE(); |
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13409 } | 13478 } |
13410 return result.raw(); | 13479 return result.raw(); |
13411 } | 13480 } |
13412 | 13481 |
13413 | 13482 |
13414 const char* WeakProperty::ToCString() const { | 13483 const char* WeakProperty::ToCString() const { |
13415 return "_WeakProperty"; | 13484 return "_WeakProperty"; |
13416 } | 13485 } |
13417 | 13486 |
13418 } // namespace dart | 13487 } // namespace dart |
OLD | NEW |