| 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 cls.set_is_type_finalized(); | 410 cls.set_is_type_finalized(); |
| 411 cls.raw_ptr()->type_arguments_field_offset_in_words_ = | 411 cls.raw_ptr()->type_arguments_field_offset_in_words_ = |
| 412 Class::kNoTypeArguments; | 412 Class::kNoTypeArguments; |
| 413 cls.raw_ptr()->num_native_fields_ = 0; | 413 cls.raw_ptr()->num_native_fields_ = 0; |
| 414 cls.InitEmptyFields(); | 414 cls.InitEmptyFields(); |
| 415 isolate->RegisterClass(cls); | 415 isolate->RegisterClass(cls); |
| 416 } | 416 } |
| 417 | 417 |
| 418 // Allocate and initialize the null class. | 418 // Allocate and initialize the null class. |
| 419 cls = Class::New<Instance>(kNullCid); | 419 cls = Class::New<Instance>(kNullCid); |
| 420 cls.set_is_prefinalized(); | |
| 421 isolate->object_store()->set_null_class(cls); | 420 isolate->object_store()->set_null_class(cls); |
| 422 | 421 |
| 423 // Allocate and initialize the free list element class. | 422 // Allocate and initialize the free list element class. |
| 424 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); | 423 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); |
| 425 cls.set_is_finalized(); | 424 cls.set_is_finalized(); |
| 426 cls.set_is_type_finalized(); | 425 cls.set_is_type_finalized(); |
| 427 | 426 |
| 428 // Allocate and initialize the sentinel values of Null class. | 427 // Allocate and initialize the sentinel values of Null class. |
| 429 { | 428 { |
| 430 *sentinel_ ^= | 429 *sentinel_ ^= |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); | 841 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
| 843 object_store->set_pending_classes(pending_classes); | 842 object_store->set_pending_classes(pending_classes); |
| 844 | 843 |
| 845 Context& context = Context::Handle(Context::New(0, Heap::kOld)); | 844 Context& context = Context::Handle(Context::New(0, Heap::kOld)); |
| 846 object_store->set_empty_context(context); | 845 object_store->set_empty_context(context); |
| 847 | 846 |
| 848 // Now that the symbol table is initialized and that the core dictionary as | 847 // Now that the symbol table is initialized and that the core dictionary as |
| 849 // well as the core implementation dictionary have been setup, preallocate | 848 // well as the core implementation dictionary have been setup, preallocate |
| 850 // remaining classes and register them by name in the dictionaries. | 849 // remaining classes and register them by name in the dictionaries. |
| 851 String& name = String::Handle(); | 850 String& name = String::Handle(); |
| 852 cls = Class::New<Bool>(); | |
| 853 object_store->set_bool_class(cls); | |
| 854 RegisterClass(cls, Symbols::Bool(), core_lib); | |
| 855 pending_classes.Add(cls, Heap::kOld); | |
| 856 | |
| 857 // TODO(12364): The class 'Null' is not registered in the class dictionary | |
| 858 // because it is not exported by dart:core. | |
| 859 cls = Class::New<Instance>(kNullCid); | |
| 860 object_store->set_null_class(cls); | |
| 861 cls.set_is_prefinalized(); | |
| 862 RegisterClass(cls, Symbols::Null(), core_lib); | |
| 863 pending_classes.Add(cls, Heap::kOld); | |
| 864 | |
| 865 cls = object_store->array_class(); // Was allocated above. | 851 cls = object_store->array_class(); // Was allocated above. |
| 866 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); | 852 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); |
| 867 pending_classes.Add(cls, Heap::kOld); | 853 pending_classes.Add(cls, Heap::kOld); |
| 868 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. | 854 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. |
| 869 type ^= Type::New(Object::Handle(cls.raw()), | 855 type ^= Type::New(Object::Handle(cls.raw()), |
| 870 TypeArguments::Handle(), | 856 TypeArguments::Handle(), |
| 871 Scanner::kDummyTokenIndex); | 857 Scanner::kDummyTokenIndex); |
| 872 type.SetIsFinalized(); | 858 type.SetIsFinalized(); |
| 873 type ^= type.Canonicalize(); | 859 type ^= type.Canonicalize(); |
| 874 object_store->set_array_type(type); | 860 object_store->set_array_type(type); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 // Parser::ParseClassDefinition). | 908 // Parser::ParseClassDefinition). |
| 923 cls = Class::New<Instance>(kInstanceCid); | 909 cls = Class::New<Instance>(kInstanceCid); |
| 924 object_store->set_object_class(cls); | 910 object_store->set_object_class(cls); |
| 925 cls.set_name(Symbols::Object()); | 911 cls.set_name(Symbols::Object()); |
| 926 cls.set_is_prefinalized(); | 912 cls.set_is_prefinalized(); |
| 927 core_lib.AddClass(cls); | 913 core_lib.AddClass(cls); |
| 928 pending_classes.Add(cls, Heap::kOld); | 914 pending_classes.Add(cls, Heap::kOld); |
| 929 type = Type::NewNonParameterizedType(cls); | 915 type = Type::NewNonParameterizedType(cls); |
| 930 object_store->set_object_type(type); | 916 object_store->set_object_type(type); |
| 931 | 917 |
| 918 cls = Class::New<Bool>(); |
| 919 object_store->set_bool_class(cls); |
| 920 RegisterClass(cls, Symbols::Bool(), core_lib); |
| 921 pending_classes.Add(cls, Heap::kOld); |
| 922 |
| 923 cls = Class::New<Instance>(kNullCid); |
| 924 cls.set_is_prefinalized(); |
| 925 object_store->set_null_class(cls); |
| 926 RegisterClass(cls, Symbols::Null(), core_lib); |
| 927 pending_classes.Add(cls, Heap::kOld); |
| 928 |
| 932 cls = object_store->type_class(); | 929 cls = object_store->type_class(); |
| 933 RegisterPrivateClass(cls, Symbols::Type(), core_lib); | 930 RegisterPrivateClass(cls, Symbols::Type(), core_lib); |
| 934 pending_classes.Add(cls, Heap::kOld); | 931 pending_classes.Add(cls, Heap::kOld); |
| 935 | 932 |
| 936 cls = object_store->type_parameter_class(); | 933 cls = object_store->type_parameter_class(); |
| 937 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib); | 934 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib); |
| 938 pending_classes.Add(cls, Heap::kOld); | 935 pending_classes.Add(cls, Heap::kOld); |
| 939 | 936 |
| 940 cls = object_store->bounded_type_class(); | 937 cls = object_store->bounded_type_class(); |
| 941 RegisterPrivateClass(cls, Symbols::BoundedType(), core_lib); | 938 RegisterPrivateClass(cls, Symbols::BoundedType(), core_lib); |
| (...skipping 9519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10461 if (HasResolvedTypeClass()) { | 10458 if (HasResolvedTypeClass()) { |
| 10462 return Class::Handle(type_class()).Name(); | 10459 return Class::Handle(type_class()).Name(); |
| 10463 } else { | 10460 } else { |
| 10464 return UnresolvedClass::Handle(unresolved_class()).Name(); | 10461 return UnresolvedClass::Handle(unresolved_class()).Name(); |
| 10465 } | 10462 } |
| 10466 } | 10463 } |
| 10467 | 10464 |
| 10468 | 10465 |
| 10469 bool AbstractType::IsNullType() const { | 10466 bool AbstractType::IsNullType() const { |
| 10470 return HasResolvedTypeClass() && | 10467 return HasResolvedTypeClass() && |
| 10471 (type_class() == Type::Handle(Type::NullType()).type_class()); | 10468 (type_class() == Isolate::Current()->object_store()->null_class()); |
| 10472 } | 10469 } |
| 10473 | 10470 |
| 10474 | 10471 |
| 10475 bool AbstractType::IsBoolType() const { | 10472 bool AbstractType::IsBoolType() const { |
| 10476 return HasResolvedTypeClass() && | 10473 return HasResolvedTypeClass() && |
| 10477 (type_class() == Type::Handle(Type::BoolType()).type_class()); | 10474 (type_class() == Isolate::Current()->object_store()->bool_class()); |
| 10478 } | 10475 } |
| 10479 | 10476 |
| 10480 | 10477 |
| 10481 bool AbstractType::IsIntType() const { | 10478 bool AbstractType::IsIntType() const { |
| 10482 return HasResolvedTypeClass() && | 10479 return HasResolvedTypeClass() && |
| 10483 (type_class() == Type::Handle(Type::IntType()).type_class()); | 10480 (type_class() == Type::Handle(Type::IntType()).type_class()); |
| 10484 } | 10481 } |
| 10485 | 10482 |
| 10486 | 10483 |
| 10487 bool AbstractType::IsDoubleType() const { | 10484 bool AbstractType::IsDoubleType() const { |
| (...skipping 4120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14608 } | 14605 } |
| 14609 | 14606 |
| 14610 | 14607 |
| 14611 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14608 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14612 stream->OpenObject(); | 14609 stream->OpenObject(); |
| 14613 stream->CloseObject(); | 14610 stream->CloseObject(); |
| 14614 } | 14611 } |
| 14615 | 14612 |
| 14616 | 14613 |
| 14617 } // namespace dart | 14614 } // namespace dart |
| OLD | NEW |