| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 cls = Class::New<WeakProperty>(); | 749 cls = Class::New<WeakProperty>(); |
| 750 object_store->set_weak_property_class(cls); | 750 object_store->set_weak_property_class(cls); |
| 751 name = Symbols::_WeakProperty(); | 751 name = Symbols::_WeakProperty(); |
| 752 RegisterPrivateClass(cls, name, core_lib); | 752 RegisterPrivateClass(cls, name, core_lib); |
| 753 | 753 |
| 754 // Set the super type of class Stacktrace to Object type so that the | 754 // Set the super type of class Stacktrace to Object type so that the |
| 755 // 'toString' method is implemented. | 755 // 'toString' method is implemented. |
| 756 cls = object_store->stacktrace_class(); | 756 cls = object_store->stacktrace_class(); |
| 757 cls.set_super_type(type); | 757 cls.set_super_type(type); |
| 758 | 758 |
| 759 cls = CreateAndRegisterInterface("Function", script, core_lib); | 759 // Note: The abstract class Function is represented by VM class |
| 760 // DartFunction, not VM class Function. |
| 761 name = Symbols::Function(); |
| 762 cls = Class::New<DartFunction>(); |
| 763 RegisterClass(cls, name, core_lib); |
| 760 pending_classes.Add(cls, Heap::kOld); | 764 pending_classes.Add(cls, Heap::kOld); |
| 761 type = Type::NewNonParameterizedType(cls); | 765 type = Type::NewNonParameterizedType(cls); |
| 762 object_store->set_function_interface(type); | 766 object_store->set_function_type(type); |
| 763 | 767 |
| 764 cls = CreateAndRegisterInterface("num", script, core_lib); | 768 cls = Class::New<Number>(); |
| 765 pending_classes.Add(cls, Heap::kOld); | 769 name = Symbols::Number(); |
| 770 RegisterClass(cls, name, core_lib); |
| 766 type = Type::NewNonParameterizedType(cls); | 771 type = Type::NewNonParameterizedType(cls); |
| 767 object_store->set_number_interface(type); | 772 object_store->set_number_type(type); |
| 768 | 773 |
| 769 cls = CreateAndRegisterInterface("int", script, core_lib); | 774 cls = CreateAndRegisterInterface("int", script, core_lib); |
| 770 pending_classes.Add(cls, Heap::kOld); | 775 pending_classes.Add(cls, Heap::kOld); |
| 771 type = Type::NewNonParameterizedType(cls); | 776 type = Type::NewNonParameterizedType(cls); |
| 772 object_store->set_int_interface(type); | 777 object_store->set_int_interface(type); |
| 773 | 778 |
| 774 cls = CreateAndRegisterInterface("double", script, core_lib); | 779 cls = CreateAndRegisterInterface("double", script, core_lib); |
| 775 pending_classes.Add(cls, Heap::kOld); | 780 pending_classes.Add(cls, Heap::kOld); |
| 776 type = Type::NewNonParameterizedType(cls); | 781 type = Type::NewNonParameterizedType(cls); |
| 777 object_store->set_double_interface(type); | 782 object_store->set_double_interface(type); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 | 1034 |
| 1030 cls = Class::New<Bool>(); | 1035 cls = Class::New<Bool>(); |
| 1031 object_store->set_bool_class(cls); | 1036 object_store->set_bool_class(cls); |
| 1032 | 1037 |
| 1033 cls = Class::New<Stacktrace>(); | 1038 cls = Class::New<Stacktrace>(); |
| 1034 object_store->set_stacktrace_class(cls); | 1039 object_store->set_stacktrace_class(cls); |
| 1035 | 1040 |
| 1036 cls = Class::New<JSRegExp>(); | 1041 cls = Class::New<JSRegExp>(); |
| 1037 object_store->set_jsregexp_class(cls); | 1042 object_store->set_jsregexp_class(cls); |
| 1038 | 1043 |
| 1044 // Some classes are not stored in the object store. Yet we still need to |
| 1045 // create their Class object so that they get put into the class_table |
| 1046 // (as a side effect of Class::New()). |
| 1047 cls = Class::New<DartFunction>(); |
| 1048 cls = Class::New<Number>(); |
| 1049 |
| 1039 cls = Class::New<WeakProperty>(); | 1050 cls = Class::New<WeakProperty>(); |
| 1040 object_store->set_weak_property_class(cls); | 1051 object_store->set_weak_property_class(cls); |
| 1041 | 1052 |
| 1042 // Allocate pre-initialized values. | 1053 // Allocate pre-initialized values. |
| 1043 Bool& bool_value = Bool::Handle(); | 1054 Bool& bool_value = Bool::Handle(); |
| 1044 bool_value = Bool::New(true); | 1055 bool_value = Bool::New(true); |
| 1045 object_store->set_true_value(bool_value); | 1056 object_store->set_true_value(bool_value); |
| 1046 bool_value = Bool::New(false); | 1057 bool_value = Bool::New(false); |
| 1047 object_store->set_false_value(bool_value); | 1058 object_store->set_false_value(bool_value); |
| 1048 } | 1059 } |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 const Array& empty_array = Array::Handle(Object::empty_array()); | 1755 const Array& empty_array = Array::Handle(Object::empty_array()); |
| 1745 ASSERT(!super_type.IsNull()); | 1756 ASSERT(!super_type.IsNull()); |
| 1746 result.set_super_type(super_type); | 1757 result.set_super_type(super_type); |
| 1747 result.set_signature_function(signature_function); | 1758 result.set_signature_function(signature_function); |
| 1748 result.set_type_parameters(type_parameters); | 1759 result.set_type_parameters(type_parameters); |
| 1749 result.SetFields(empty_array); | 1760 result.SetFields(empty_array); |
| 1750 result.SetFunctions(empty_array); | 1761 result.SetFunctions(empty_array); |
| 1751 result.set_type_arguments_instance_field_offset( | 1762 result.set_type_arguments_instance_field_offset( |
| 1752 Closure::type_arguments_offset()); | 1763 Closure::type_arguments_offset()); |
| 1753 // Implements interface "Function". | 1764 // Implements interface "Function". |
| 1754 const Type& function_interface = Type::Handle(Type::FunctionInterface()); | 1765 const Type& function_type = Type::Handle(Type::Function()); |
| 1755 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld)); | 1766 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld)); |
| 1756 interfaces.SetAt(0, function_interface); | 1767 interfaces.SetAt(0, function_type); |
| 1757 result.set_interfaces(interfaces); | 1768 result.set_interfaces(interfaces); |
| 1758 // Unless the signature function already has a signature class, create a | 1769 // Unless the signature function already has a signature class, create a |
| 1759 // canonical signature class by having the signature function point back to | 1770 // canonical signature class by having the signature function point back to |
| 1760 // the signature class. | 1771 // the signature class. |
| 1761 if (signature_function.signature_class() == Object::null()) { | 1772 if (signature_function.signature_class() == Object::null()) { |
| 1762 signature_function.set_signature_class(result); | 1773 signature_function.set_signature_class(result); |
| 1763 result.set_is_finalized(); | 1774 result.set_is_finalized(); |
| 1764 } else { | 1775 } else { |
| 1765 // This new signature class is an alias. | 1776 // This new signature class is an alias. |
| 1766 ASSERT(!result.IsCanonicalSignatureClass()); | 1777 ASSERT(!result.IsCanonicalSignatureClass()); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2559 (type_class() == Type::Handle(Type::IntInterface()).type_class()); | 2570 (type_class() == Type::Handle(Type::IntInterface()).type_class()); |
| 2560 } | 2571 } |
| 2561 | 2572 |
| 2562 | 2573 |
| 2563 bool AbstractType::IsDoubleInterface() const { | 2574 bool AbstractType::IsDoubleInterface() const { |
| 2564 return HasResolvedTypeClass() && | 2575 return HasResolvedTypeClass() && |
| 2565 (type_class() == Type::Handle(Type::DoubleInterface()).type_class()); | 2576 (type_class() == Type::Handle(Type::DoubleInterface()).type_class()); |
| 2566 } | 2577 } |
| 2567 | 2578 |
| 2568 | 2579 |
| 2569 bool AbstractType::IsNumberInterface() const { | 2580 bool AbstractType::IsNumberType() const { |
| 2570 return HasResolvedTypeClass() && | 2581 return HasResolvedTypeClass() && |
| 2571 (type_class() == Type::Handle(Type::NumberInterface()).type_class()); | 2582 (type_class() == Type::Handle(Type::Number()).type_class()); |
| 2572 } | 2583 } |
| 2573 | 2584 |
| 2574 | 2585 |
| 2575 bool AbstractType::IsStringInterface() const { | 2586 bool AbstractType::IsStringInterface() const { |
| 2576 return HasResolvedTypeClass() && | 2587 return HasResolvedTypeClass() && |
| 2577 (type_class() == Type::Handle(Type::StringInterface()).type_class()); | 2588 (type_class() == Type::Handle(Type::StringInterface()).type_class()); |
| 2578 } | 2589 } |
| 2579 | 2590 |
| 2580 | 2591 |
| 2581 bool AbstractType::IsFunctionInterface() const { | 2592 bool AbstractType::IsFunctionType() const { |
| 2582 return HasResolvedTypeClass() && | 2593 return HasResolvedTypeClass() && |
| 2583 (type_class() == Type::Handle(Type::FunctionInterface()).type_class()); | 2594 (type_class() == Type::Handle(Type::Function()).type_class()); |
| 2584 } | 2595 } |
| 2585 | 2596 |
| 2586 | 2597 |
| 2587 bool AbstractType::IsListInterface() const { | 2598 bool AbstractType::IsListInterface() const { |
| 2588 return HasResolvedTypeClass() && | 2599 return HasResolvedTypeClass() && |
| 2589 (type_class() == Type::Handle(Type::ListInterface()).type_class()); | 2600 (type_class() == Type::Handle(Type::ListInterface()).type_class()); |
| 2590 } | 2601 } |
| 2591 | 2602 |
| 2592 | 2603 |
| 2593 bool AbstractType::TypeTest(TypeTestKind test_kind, | 2604 bool AbstractType::TypeTest(TypeTestKind test_kind, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 RawType* Type::IntInterface() { | 2700 RawType* Type::IntInterface() { |
| 2690 return Isolate::Current()->object_store()->int_interface(); | 2701 return Isolate::Current()->object_store()->int_interface(); |
| 2691 } | 2702 } |
| 2692 | 2703 |
| 2693 | 2704 |
| 2694 RawType* Type::DoubleInterface() { | 2705 RawType* Type::DoubleInterface() { |
| 2695 return Isolate::Current()->object_store()->double_interface(); | 2706 return Isolate::Current()->object_store()->double_interface(); |
| 2696 } | 2707 } |
| 2697 | 2708 |
| 2698 | 2709 |
| 2699 RawType* Type::NumberInterface() { | 2710 RawType* Type::Number() { |
| 2700 return Isolate::Current()->object_store()->number_interface(); | 2711 return Isolate::Current()->object_store()->number_type(); |
| 2701 } | 2712 } |
| 2702 | 2713 |
| 2703 | 2714 |
| 2704 RawType* Type::StringInterface() { | 2715 RawType* Type::StringInterface() { |
| 2705 return Isolate::Current()->object_store()->string_interface(); | 2716 return Isolate::Current()->object_store()->string_interface(); |
| 2706 } | 2717 } |
| 2707 | 2718 |
| 2708 | 2719 |
| 2709 RawType* Type::FunctionInterface() { | 2720 RawType* Type::Function() { |
| 2710 return Isolate::Current()->object_store()->function_interface(); | 2721 return Isolate::Current()->object_store()->function_type(); |
| 2711 } | 2722 } |
| 2712 | 2723 |
| 2713 | 2724 |
| 2714 RawType* Type::ListInterface() { | 2725 RawType* Type::ListInterface() { |
| 2715 return Isolate::Current()->object_store()->list_interface(); | 2726 return Isolate::Current()->object_store()->list_interface(); |
| 2716 } | 2727 } |
| 2717 | 2728 |
| 2718 | 2729 |
| 2719 RawType* Type::NewNonParameterizedType( | 2730 RawType* Type::NewNonParameterizedType( |
| 2720 const Class& type_class) { | 2731 const Class& type_class) { |
| (...skipping 8153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10874 void Closure::set_context(const Context& value) const { | 10885 void Closure::set_context(const Context& value) const { |
| 10875 StorePointer(&raw_ptr()->context_, value.raw()); | 10886 StorePointer(&raw_ptr()->context_, value.raw()); |
| 10876 } | 10887 } |
| 10877 | 10888 |
| 10878 | 10889 |
| 10879 void Closure::set_function(const Function& value) const { | 10890 void Closure::set_function(const Function& value) const { |
| 10880 StorePointer(&raw_ptr()->function_, value.raw()); | 10891 StorePointer(&raw_ptr()->function_, value.raw()); |
| 10881 } | 10892 } |
| 10882 | 10893 |
| 10883 | 10894 |
| 10895 const char* DartFunction::ToCString() const { |
| 10896 return "Function type class"; |
| 10897 } |
| 10898 |
| 10899 |
| 10884 const char* Closure::ToCString() const { | 10900 const char* Closure::ToCString() const { |
| 10885 const Function& fun = Function::Handle(function()); | 10901 const Function& fun = Function::Handle(function()); |
| 10886 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 10902 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
| 10887 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); | 10903 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); |
| 10888 const char* from = is_implicit_closure ? " from " : ""; | 10904 const char* from = is_implicit_closure ? " from " : ""; |
| 10889 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 10905 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
| 10890 const char* format = "Closure: %s%s%s"; | 10906 const char* format = "Closure: %s%s%s"; |
| 10891 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; | 10907 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; |
| 10892 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 10908 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 10893 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); | 10909 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11157 } | 11173 } |
| 11158 return result.raw(); | 11174 return result.raw(); |
| 11159 } | 11175 } |
| 11160 | 11176 |
| 11161 | 11177 |
| 11162 const char* WeakProperty::ToCString() const { | 11178 const char* WeakProperty::ToCString() const { |
| 11163 return "_WeakProperty"; | 11179 return "_WeakProperty"; |
| 11164 } | 11180 } |
| 11165 | 11181 |
| 11166 } // namespace dart | 11182 } // namespace dart |
| OLD | NEW |