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

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

Issue 10942025: Convert String and List to abstract classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to tip-of-tree. Created 8 years, 2 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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 type = Type::NewNonParameterizedType(cls); 841 type = Type::NewNonParameterizedType(cls);
842 object_store->set_int_type(type); 842 object_store->set_int_type(type);
843 843
844 name = Symbols::New("double"); 844 name = Symbols::New("double");
845 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 845 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
846 RegisterClass(cls, name, core_lib); 846 RegisterClass(cls, name, core_lib);
847 pending_classes.Add(cls, Heap::kOld); 847 pending_classes.Add(cls, Heap::kOld);
848 type = Type::NewNonParameterizedType(cls); 848 type = Type::NewNonParameterizedType(cls);
849 object_store->set_double_type(type); 849 object_store->set_double_type(type);
850 850
851 cls = CreateAndRegisterInterface("String", script, core_lib); 851 name = Symbols::New("String");
852 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
853 RegisterClass(cls, name, core_lib);
852 pending_classes.Add(cls, Heap::kOld); 854 pending_classes.Add(cls, Heap::kOld);
853 type = Type::NewNonParameterizedType(cls); 855 type = Type::NewNonParameterizedType(cls);
854 object_store->set_string_interface(type); 856 object_store->set_string_type(type);
855 857
856 cls = CreateAndRegisterInterface("List", script, core_lib); 858 name = Symbols::New("List");
859 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
860 RegisterClass(cls, name, core_lib);
857 pending_classes.Add(cls, Heap::kOld); 861 pending_classes.Add(cls, Heap::kOld);
858 type = Type::NewNonParameterizedType(cls); 862 type = Type::NewNonParameterizedType(cls);
859 object_store->set_list_interface(type); 863 object_store->set_list_type(type);
860 864
861 cls = CreateAndRegisterInterface("ByteArray", script, core_lib); 865 cls = CreateAndRegisterInterface("ByteArray", script, core_lib);
862 pending_classes.Add(cls, Heap::kOld); 866 pending_classes.Add(cls, Heap::kOld);
863 type = Type::NewNonParameterizedType(cls); 867 type = Type::NewNonParameterizedType(cls);
864 object_store->set_byte_array_interface(type); 868 object_store->set_byte_array_interface(type);
865 869
866 cls = object_store->bool_class(); 870 cls = object_store->bool_class();
867 type = Type::NewNonParameterizedType(cls); 871 type = Type::NewNonParameterizedType(cls);
868 object_store->set_bool_type(type); 872 object_store->set_bool_type(type);
869 873
(...skipping 7472 matching lines...) Expand 10 before | Expand all | Expand 10 after
8342 (type_class() == Type::Handle(Type::Double()).type_class()); 8346 (type_class() == Type::Handle(Type::Double()).type_class());
8343 } 8347 }
8344 8348
8345 8349
8346 bool AbstractType::IsNumberType() const { 8350 bool AbstractType::IsNumberType() const {
8347 return HasResolvedTypeClass() && 8351 return HasResolvedTypeClass() &&
8348 (type_class() == Type::Handle(Type::Number()).type_class()); 8352 (type_class() == Type::Handle(Type::Number()).type_class());
8349 } 8353 }
8350 8354
8351 8355
8352 bool AbstractType::IsStringInterface() const { 8356 bool AbstractType::IsStringType() const {
8353 return HasResolvedTypeClass() && 8357 return HasResolvedTypeClass() &&
8354 (type_class() == Type::Handle(Type::StringInterface()).type_class()); 8358 (type_class() == Type::Handle(Type::StringType()).type_class());
8355 } 8359 }
8356 8360
8357 8361
8358 bool AbstractType::IsFunctionType() const { 8362 bool AbstractType::IsFunctionType() const {
8359 return HasResolvedTypeClass() && 8363 return HasResolvedTypeClass() &&
8360 (type_class() == Type::Handle(Type::Function()).type_class()); 8364 (type_class() == Type::Handle(Type::Function()).type_class());
8361 } 8365 }
8362 8366
8363 8367
8364 bool AbstractType::IsListInterface() const { 8368 bool AbstractType::IsListType() const {
8365 return HasResolvedTypeClass() && 8369 return HasResolvedTypeClass() &&
8366 (type_class() == Type::Handle(Type::ListInterface()).type_class()); 8370 (type_class() == Type::Handle(Type::ListType()).type_class());
8367 } 8371 }
8368 8372
8369 8373
8370 bool AbstractType::TypeTest(TypeTestKind test_kind, 8374 bool AbstractType::TypeTest(TypeTestKind test_kind,
8371 const AbstractType& other, 8375 const AbstractType& other,
8372 Error* malformed_error) const { 8376 Error* malformed_error) const {
8373 ASSERT(IsFinalized()); 8377 ASSERT(IsFinalized());
8374 ASSERT(other.IsFinalized()); 8378 ASSERT(other.IsFinalized());
8375 // In case the type checked in a type test is malformed, the code generator 8379 // In case the type checked in a type test is malformed, the code generator
8376 // may compile a throw instead of a run time call performing the type check. 8380 // may compile a throw instead of a run time call performing the type check.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
8481 RawType* Type::Double() { 8485 RawType* Type::Double() {
8482 return Isolate::Current()->object_store()->double_type(); 8486 return Isolate::Current()->object_store()->double_type();
8483 } 8487 }
8484 8488
8485 8489
8486 RawType* Type::Number() { 8490 RawType* Type::Number() {
8487 return Isolate::Current()->object_store()->number_type(); 8491 return Isolate::Current()->object_store()->number_type();
8488 } 8492 }
8489 8493
8490 8494
8491 RawType* Type::StringInterface() { 8495 RawType* Type::StringType() {
8492 return Isolate::Current()->object_store()->string_interface(); 8496 return Isolate::Current()->object_store()->string_type();
8493 } 8497 }
8494 8498
8495 8499
8496 RawType* Type::Function() { 8500 RawType* Type::Function() {
8497 return Isolate::Current()->object_store()->function_type(); 8501 return Isolate::Current()->object_store()->function_type();
8498 } 8502 }
8499 8503
8500 8504
8501 RawType* Type::ListInterface() { 8505 RawType* Type::ListType() {
8502 return Isolate::Current()->object_store()->list_interface(); 8506 return Isolate::Current()->object_store()->list_type();
8503 } 8507 }
8504 8508
8505 8509
8506 RawType* Type::NewNonParameterizedType(const Class& type_class) { 8510 RawType* Type::NewNonParameterizedType(const Class& type_class) {
8507 ASSERT(!type_class.HasTypeArguments()); 8511 ASSERT(!type_class.HasTypeArguments());
8508 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 8512 const TypeArguments& no_type_arguments = TypeArguments::Handle();
8509 Type& type = Type::Handle(); 8513 Type& type = Type::Handle();
8510 type ^= Type::New(Object::Handle(type_class.raw()), 8514 type ^= Type::New(Object::Handle(type_class.raw()),
8511 no_type_arguments, 8515 no_type_arguments,
8512 Scanner::kDummyTokenIndex); 8516 Scanner::kDummyTokenIndex);
(...skipping 3642 matching lines...) Expand 10 before | Expand all | Expand 10 after
12155 } 12159 }
12156 return result.raw(); 12160 return result.raw();
12157 } 12161 }
12158 12162
12159 12163
12160 const char* WeakProperty::ToCString() const { 12164 const char* WeakProperty::ToCString() const {
12161 return "_WeakProperty"; 12165 return "_WeakProperty";
12162 } 12166 }
12163 12167
12164 } // namespace dart 12168 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698