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

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

Issue 22819005: Make Null a public class of dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: type cast, extends/implements prohibition 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
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | runtime/vm/resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_finalized();
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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 847
849 // Now that the symbol table is initialized and that the core dictionary as 848 // Now that the symbol table is initialized and that the core dictionary as
850 // well as the core implementation dictionary have been setup, preallocate 849 // well as the core implementation dictionary have been setup, preallocate
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
859 // because it is not exported by dart:core.
860 cls = Class::New<Instance>(kNullCid); 857 cls = Class::New<Instance>(kNullCid);
861 cls.set_name(Symbols::Null()); 858 cls.set_is_prefinalized();
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); 859 object_store->set_null_class(cls);
867 cls.set_library(core_lib); // A sort of fiction for the mirrors. 860 RegisterClass(cls, Symbols::Null(), core_lib);
868 // When/if we promote Null to an ordinary class, it should be added to the 861 pending_classes.Add(cls, Heap::kOld);
869 // core library, given source and added to the list of classes pending
870 // finalization.
871 // RegisterClass(cls, Symbols::Null(), core_lib);
872 // pending_classes.Add(cls, Heap::kOld);
873 862
874 cls = object_store->array_class(); // Was allocated above. 863 cls = object_store->array_class(); // Was allocated above.
875 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib); 864 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib);
876 pending_classes.Add(cls, Heap::kOld); 865 pending_classes.Add(cls, Heap::kOld);
877 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 866 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
878 type ^= Type::New(Object::Handle(cls.raw()), 867 type ^= Type::New(Object::Handle(cls.raw()),
879 TypeArguments::Handle(), 868 TypeArguments::Handle(),
880 Scanner::kDummyTokenIndex); 869 Scanner::kDummyTokenIndex);
881 type.SetIsFinalized(); 870 type.SetIsFinalized();
882 type ^= type.Canonicalize(); 871 type ^= type.Canonicalize();
(...skipping 9585 matching lines...) Expand 10 before | Expand all | Expand 10 after
10468 RawString* AbstractType::ClassName() const { 10457 RawString* AbstractType::ClassName() const {
10469 if (HasResolvedTypeClass()) { 10458 if (HasResolvedTypeClass()) {
10470 return Class::Handle(type_class()).Name(); 10459 return Class::Handle(type_class()).Name();
10471 } else { 10460 } else {
10472 return UnresolvedClass::Handle(unresolved_class()).Name(); 10461 return UnresolvedClass::Handle(unresolved_class()).Name();
10473 } 10462 }
10474 } 10463 }
10475 10464
10476 10465
10477 bool AbstractType::IsNullType() const { 10466 bool AbstractType::IsNullType() const {
10478 ASSERT(Type::Handle(Type::NullType()).IsCanonical()); 10467 return HasResolvedTypeClass() &&
10479 return raw() == Type::NullType(); 10468 (type_class() == Type::Handle(Type::NullType()).type_class());
siva 2013/08/14 18:53:31 why not return HasResolvedTypeClass() && (type_cla
rmacnak 2013/08/14 22:31:34 Done.
10480 } 10469 }
10481 10470
10482 10471
10483 bool AbstractType::IsBoolType() const { 10472 bool AbstractType::IsBoolType() const {
10484 return HasResolvedTypeClass() && 10473 return HasResolvedTypeClass() &&
10485 (type_class() == Type::Handle(Type::BoolType()).type_class()); 10474 (type_class() == Type::Handle(Type::BoolType()).type_class());
10486 } 10475 }
10487 10476
10488 10477
10489 bool AbstractType::IsIntType() const { 10478 bool AbstractType::IsIntType() const {
(...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after
14612 } 14601 }
14613 14602
14614 14603
14615 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14604 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14616 stream->OpenObject(); 14605 stream->OpenObject();
14617 stream->CloseObject(); 14606 stream->CloseObject();
14618 } 14607 }
14619 14608
14620 14609
14621 } // namespace dart 14610 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_type_propagator.cc ('k') | runtime/vm/resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698