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 const char* MixinAppType::ToCString() const { |
| 9897 return "MixinAppType"; |
| 9898 } |
| 9899 |
| 9900 |
| 9901 void MixinAppType::set_super_type(const AbstractType& value) const { |
| 9902 StorePointer(&raw_ptr()->super_type_, value.raw()); |
| 9903 } |
| 9904 |
| 9905 |
| 9906 void MixinAppType::set_mixin_types(const Array& value) const { |
| 9907 StorePointer(&raw_ptr()->mixin_types_, value.raw()); |
| 9908 } |
| 9909 |
| 9910 |
| 9911 RawMixinAppType* MixinAppType::New() { |
| 9912 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() != |
| 9913 Class::null()); |
| 9914 // MixinAppType objects do not survive finalization, so allocate |
| 9915 // on new heap. |
| 9916 RawObject* raw = Object::Allocate(MixinAppType::kClassId, |
| 9917 MixinAppType::InstanceSize(), |
| 9918 Heap::kNew); |
| 9919 return reinterpret_cast<RawMixinAppType*>(raw); |
| 9920 } |
| 9921 |
| 9922 |
| 9923 RawMixinAppType* MixinAppType::New(const AbstractType& super_type, |
| 9924 const Array& mixin_types) { |
| 9925 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New()); |
| 9926 result.set_super_type(super_type); |
| 9927 result.set_mixin_types(mixin_types); |
| 9928 return result.raw(); |
| 9929 } |
| 9930 |
| 9931 |
9881 const char* Number::ToCString() const { | 9932 const char* Number::ToCString() const { |
9882 // Number is an interface. No instances of Number should exist. | 9933 // Number is an interface. No instances of Number should exist. |
9883 UNREACHABLE(); | 9934 UNREACHABLE(); |
9884 return "Number"; | 9935 return "Number"; |
9885 } | 9936 } |
9886 | 9937 |
9887 | 9938 |
9888 const char* Integer::ToCString() const { | 9939 const char* Integer::ToCString() const { |
9889 // Integer is an interface. No instances of Integer should exist. | 9940 // Integer is an interface. No instances of Integer should exist. |
9890 UNREACHABLE(); | 9941 UNREACHABLE(); |
(...skipping 3562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13453 } | 13504 } |
13454 return result.raw(); | 13505 return result.raw(); |
13455 } | 13506 } |
13456 | 13507 |
13457 | 13508 |
13458 const char* WeakProperty::ToCString() const { | 13509 const char* WeakProperty::ToCString() const { |
13459 return "_WeakProperty"; | 13510 return "_WeakProperty"; |
13460 } | 13511 } |
13461 | 13512 |
13462 } // namespace dart | 13513 } // namespace dart |
OLD | NEW |