Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: runtime/vm/object.cc

Issue 23012003: Add Null class to dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed IsNullType. All tests succeede for VM now. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_finalized(); 420 cls.set_is_prefinalized();
421 cls.set_is_type_finalized();
422 isolate->object_store()->set_null_class(cls); 421 isolate->object_store()->set_null_class(cls);
423 422
424 // Allocate and initialize the free list element class. 423 // Allocate and initialize the free list element class.
425 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement); 424 cls = Class::New<FreeListElement::FakeInstance>(kFreeListElement);
426 cls.set_is_finalized(); 425 cls.set_is_finalized();
427 cls.set_is_type_finalized(); 426 cls.set_is_type_finalized();
428 427
429 // Allocate and initialize the sentinel values of Null class. 428 // Allocate and initialize the sentinel values of Null class.
430 { 429 {
431 *sentinel_ ^= 430 *sentinel_ ^=
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 // remaining classes and register them by name in the dictionaries. 850 // remaining classes and register them by name in the dictionaries.
852 String& name = String::Handle(); 851 String& name = String::Handle();
853 cls = Class::New<Bool>(); 852 cls = Class::New<Bool>();
854 object_store->set_bool_class(cls); 853 object_store->set_bool_class(cls);
855 RegisterClass(cls, Symbols::Bool(), core_lib); 854 RegisterClass(cls, Symbols::Bool(), core_lib);
856 pending_classes.Add(cls, Heap::kOld); 855 pending_classes.Add(cls, Heap::kOld);
857 856
858 // TODO(12364): The class 'Null' is not registered in the class dictionary 857 // TODO(12364): The class 'Null' is not registered in the class dictionary
859 // because it is not exported by dart:core. 858 // because it is not exported by dart:core.
860 cls = Class::New<Instance>(kNullCid); 859 cls = Class::New<Instance>(kNullCid);
861 cls.set_name(Symbols::Null());
862 // We immediately mark Null as finalized because it has no corresponding
863 // source.
864 cls.set_is_finalized();
865 cls.set_is_type_finalized();
866 object_store->set_null_class(cls); 860 object_store->set_null_class(cls);
867 cls.set_library(core_lib); // A sort of fiction for the mirrors. 861 cls.set_is_prefinalized();
868 // When/if we promote Null to an ordinary class, it should be added to the 862 RegisterClass(cls, Symbols::Null(), core_lib);
869 // core library, given source and added to the list of classes pending 863 pending_classes.Add(cls, Heap::kOld);
870 // finalization.
871 // RegisterClass(cls, Symbols::Null(), core_lib);
872 // pending_classes.Add(cls, Heap::kOld);
873 864
874 cls = object_store->array_class(); // Was allocated above. 865 cls = object_store->array_class(); // Was allocated above.
875 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); 866 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib);
876 pending_classes.Add(cls, Heap::kOld); 867 pending_classes.Add(cls, Heap::kOld);
877 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 868 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
878 type ^= Type::New(Object::Handle(cls.raw()), 869 type ^= Type::New(Object::Handle(cls.raw()),
879 TypeArguments::Handle(), 870 TypeArguments::Handle(),
880 Scanner::kDummyTokenIndex); 871 Scanner::kDummyTokenIndex);
881 type.SetIsFinalized(); 872 type.SetIsFinalized();
882 type ^= type.Canonicalize(); 873 type ^= type.Canonicalize();
(...skipping 9592 matching lines...) Expand 10 before | Expand all | Expand 10 after
10475 RawString* AbstractType::ClassName() const { 10466 RawString* AbstractType::ClassName() const {
10476 if (HasResolvedTypeClass()) { 10467 if (HasResolvedTypeClass()) {
10477 return Class::Handle(type_class()).Name(); 10468 return Class::Handle(type_class()).Name();
10478 } else { 10469 } else {
10479 return UnresolvedClass::Handle(unresolved_class()).Name(); 10470 return UnresolvedClass::Handle(unresolved_class()).Name();
10480 } 10471 }
10481 } 10472 }
10482 10473
10483 10474
10484 bool AbstractType::IsNullType() const { 10475 bool AbstractType::IsNullType() const {
10485 ASSERT(Type::Handle(Type::NullType()).IsCanonical()); 10476 return HasResolvedTypeClass() &&
10486 return raw() == Type::NullType(); 10477 (type_class() == Type::Handle(Type::NullType()).type_class());
10487 } 10478 }
10488 10479
10489 10480
10490 bool AbstractType::IsBoolType() const { 10481 bool AbstractType::IsBoolType() const {
10491 return HasResolvedTypeClass() && 10482 return HasResolvedTypeClass() &&
10492 (type_class() == Type::Handle(Type::BoolType()).type_class()); 10483 (type_class() == Type::Handle(Type::BoolType()).type_class());
10493 } 10484 }
10494 10485
10495 10486
10496 bool AbstractType::IsIntType() const { 10487 bool AbstractType::IsIntType() const {
(...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after
14619 } 14610 }
14620 14611
14621 14612
14622 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14613 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14623 stream->OpenObject(); 14614 stream->OpenObject();
14624 stream->CloseObject(); 14615 stream->CloseObject();
14625 } 14616 }
14626 14617
14627 14618
14628 } // namespace dart 14619 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698