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

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

Issue 10832401: Gentle start with removing explicit interfaces (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 cls = Class::New<ExternalFloat64Array>(); 745 cls = Class::New<ExternalFloat64Array>();
746 object_store->set_external_float64_array_class(cls); 746 object_store->set_external_float64_array_class(cls);
747 name = Symbols::_ExternalFloat64Array(); 747 name = Symbols::_ExternalFloat64Array();
748 RegisterPrivateClass(cls, name, core_lib); 748 RegisterPrivateClass(cls, name, core_lib);
749 749
750 // Set the super type of class Stacktrace to Object type so that the 750 // Set the super type of class Stacktrace to Object type so that the
751 // 'toString' method is implemented. 751 // 'toString' method is implemented.
752 cls = object_store->stacktrace_class(); 752 cls = object_store->stacktrace_class();
753 cls.set_super_type(type); 753 cls.set_super_type(type);
754 754
755 cls = CreateAndRegisterInterface("Function", script, core_lib); 755 name = Symbols::Function();
756 cls = Class::New(name, script, Scanner::kDummyTokenIndex);
757 core_lib.AddClass(cls);
756 pending_classes.Add(cls, Heap::kOld); 758 pending_classes.Add(cls, Heap::kOld);
757 type = Type::NewNonParameterizedType(cls); 759 type = Type::NewNonParameterizedType(cls);
758 object_store->set_function_interface(type); 760 object_store->set_function_type(type);
759 761
760 cls = CreateAndRegisterInterface("num", script, core_lib); 762 name = Symbols::New("num");
siva 2012/08/21 21:22:06 why not make "num" also a predefined symbol in the
hausner 2012/08/23 00:25:06 Done.
763 cls = Class::New(name, script, Scanner::kDummyTokenIndex);
764 core_lib.AddClass(cls);
761 pending_classes.Add(cls, Heap::kOld); 765 pending_classes.Add(cls, Heap::kOld);
762 type = Type::NewNonParameterizedType(cls); 766 type = Type::NewNonParameterizedType(cls);
763 object_store->set_number_interface(type); 767 object_store->set_number_type(type);
764 768
765 cls = CreateAndRegisterInterface("int", script, core_lib); 769 cls = CreateAndRegisterInterface("int", script, core_lib);
766 pending_classes.Add(cls, Heap::kOld); 770 pending_classes.Add(cls, Heap::kOld);
767 type = Type::NewNonParameterizedType(cls); 771 type = Type::NewNonParameterizedType(cls);
768 object_store->set_int_interface(type); 772 object_store->set_int_interface(type);
769 773
770 cls = CreateAndRegisterInterface("double", script, core_lib); 774 cls = CreateAndRegisterInterface("double", script, core_lib);
771 pending_classes.Add(cls, Heap::kOld); 775 pending_classes.Add(cls, Heap::kOld);
772 type = Type::NewNonParameterizedType(cls); 776 type = Type::NewNonParameterizedType(cls);
773 object_store->set_double_interface(type); 777 object_store->set_double_interface(type);
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 const Array& empty_array = Array::Handle(Object::empty_array()); 1734 const Array& empty_array = Array::Handle(Object::empty_array());
1731 ASSERT(!super_type.IsNull()); 1735 ASSERT(!super_type.IsNull());
1732 result.set_super_type(super_type); 1736 result.set_super_type(super_type);
1733 result.set_signature_function(signature_function); 1737 result.set_signature_function(signature_function);
1734 result.set_type_parameters(type_parameters); 1738 result.set_type_parameters(type_parameters);
1735 result.SetFields(empty_array); 1739 result.SetFields(empty_array);
1736 result.SetFunctions(empty_array); 1740 result.SetFunctions(empty_array);
1737 result.set_type_arguments_instance_field_offset( 1741 result.set_type_arguments_instance_field_offset(
1738 Closure::type_arguments_offset()); 1742 Closure::type_arguments_offset());
1739 // Implements interface "Function". 1743 // Implements interface "Function".
1740 const Type& function_interface = Type::Handle(Type::FunctionInterface()); 1744 const Type& function_type = Type::Handle(Type::Function());
1741 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld)); 1745 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld));
1742 interfaces.SetAt(0, function_interface); 1746 interfaces.SetAt(0, function_type);
1743 result.set_interfaces(interfaces); 1747 result.set_interfaces(interfaces);
1744 // Unless the signature function already has a signature class, create a 1748 // Unless the signature function already has a signature class, create a
1745 // canonical signature class by having the signature function point back to 1749 // canonical signature class by having the signature function point back to
1746 // the signature class. 1750 // the signature class.
1747 if (signature_function.signature_class() == Object::null()) { 1751 if (signature_function.signature_class() == Object::null()) {
1748 signature_function.set_signature_class(result); 1752 signature_function.set_signature_class(result);
1749 result.set_is_finalized(); 1753 result.set_is_finalized();
1750 } else { 1754 } else {
1751 // This new signature class is an alias. 1755 // This new signature class is an alias.
1752 ASSERT(!result.IsCanonicalSignatureClass()); 1756 ASSERT(!result.IsCanonicalSignatureClass());
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 (type_class() == Type::Handle(Type::IntInterface()).type_class()); 2566 (type_class() == Type::Handle(Type::IntInterface()).type_class());
2563 } 2567 }
2564 2568
2565 2569
2566 bool AbstractType::IsDoubleInterface() const { 2570 bool AbstractType::IsDoubleInterface() const {
2567 return HasResolvedTypeClass() && 2571 return HasResolvedTypeClass() &&
2568 (type_class() == Type::Handle(Type::DoubleInterface()).type_class()); 2572 (type_class() == Type::Handle(Type::DoubleInterface()).type_class());
2569 } 2573 }
2570 2574
2571 2575
2572 bool AbstractType::IsNumberInterface() const { 2576 bool AbstractType::IsNumber() const {
2573 return HasResolvedTypeClass() && 2577 return HasResolvedTypeClass() &&
2574 (type_class() == Type::Handle(Type::NumberInterface()).type_class()); 2578 (type_class() == Type::Handle(Type::Number()).type_class());
2575 } 2579 }
2576 2580
2577 2581
2578 bool AbstractType::IsStringInterface() const { 2582 bool AbstractType::IsStringInterface() const {
2579 return HasResolvedTypeClass() && 2583 return HasResolvedTypeClass() &&
2580 (type_class() == Type::Handle(Type::StringInterface()).type_class()); 2584 (type_class() == Type::Handle(Type::StringInterface()).type_class());
2581 } 2585 }
2582 2586
2583 2587
2584 bool AbstractType::IsFunctionInterface() const { 2588 bool AbstractType::IsFunction() const {
2585 return HasResolvedTypeClass() && 2589 return HasResolvedTypeClass() &&
2586 (type_class() == Type::Handle(Type::FunctionInterface()).type_class()); 2590 (type_class() == Type::Handle(Type::Function()).type_class());
2587 } 2591 }
2588 2592
2589 2593
2590 bool AbstractType::IsListInterface() const { 2594 bool AbstractType::IsListInterface() const {
2591 return HasResolvedTypeClass() && 2595 return HasResolvedTypeClass() &&
2592 (type_class() == Type::Handle(Type::ListInterface()).type_class()); 2596 (type_class() == Type::Handle(Type::ListInterface()).type_class());
2593 } 2597 }
2594 2598
2595 2599
2596 bool AbstractType::TypeTest(TypeTestKind test_kind, 2600 bool AbstractType::TypeTest(TypeTestKind test_kind,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 RawType* Type::IntInterface() { 2696 RawType* Type::IntInterface() {
2693 return Isolate::Current()->object_store()->int_interface(); 2697 return Isolate::Current()->object_store()->int_interface();
2694 } 2698 }
2695 2699
2696 2700
2697 RawType* Type::DoubleInterface() { 2701 RawType* Type::DoubleInterface() {
2698 return Isolate::Current()->object_store()->double_interface(); 2702 return Isolate::Current()->object_store()->double_interface();
2699 } 2703 }
2700 2704
2701 2705
2702 RawType* Type::NumberInterface() { 2706 RawType* Type::Number() {
2703 return Isolate::Current()->object_store()->number_interface(); 2707 return Isolate::Current()->object_store()->number_type();
2704 } 2708 }
2705 2709
2706 2710
2707 RawType* Type::StringInterface() { 2711 RawType* Type::StringInterface() {
2708 return Isolate::Current()->object_store()->string_interface(); 2712 return Isolate::Current()->object_store()->string_interface();
2709 } 2713 }
2710 2714
2711 2715
2712 RawType* Type::FunctionInterface() { 2716 RawType* Type::Function() {
2713 return Isolate::Current()->object_store()->function_interface(); 2717 return Isolate::Current()->object_store()->function_type();
2714 } 2718 }
2715 2719
2716 2720
2717 RawType* Type::ListInterface() { 2721 RawType* Type::ListInterface() {
2718 return Isolate::Current()->object_store()->list_interface(); 2722 return Isolate::Current()->object_store()->list_interface();
2719 } 2723 }
2720 2724
2721 2725
2722 RawType* Type::NewNonParameterizedType( 2726 RawType* Type::NewNonParameterizedType(
2723 const Class& type_class) { 2727 const Class& type_class) {
(...skipping 8417 matching lines...) Expand 10 before | Expand all | Expand 10 after
11141 } 11145 }
11142 return result.raw(); 11146 return result.raw();
11143 } 11147 }
11144 11148
11145 11149
11146 const char* WeakProperty::ToCString() const { 11150 const char* WeakProperty::ToCString() const {
11147 return "WeakProperty"; 11151 return "WeakProperty";
11148 } 11152 }
11149 11153
11150 } // namespace dart 11154 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698