| 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 "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 // Return the first canonical signature type if already computed. | 803 // Return the first canonical signature type if already computed. |
| 804 const Array& signature_types = Array::Handle(canonical_types()); | 804 const Array& signature_types = Array::Handle(canonical_types()); |
| 805 if (signature_types.Length() > 0) { | 805 if (signature_types.Length() > 0) { |
| 806 Type& signature_type = Type::Handle(); | 806 Type& signature_type = Type::Handle(); |
| 807 signature_type ^= signature_types.At(0); | 807 signature_type ^= signature_types.At(0); |
| 808 if (!signature_type.IsNull()) { | 808 if (!signature_type.IsNull()) { |
| 809 return signature_type.raw(); | 809 return signature_type.raw(); |
| 810 } | 810 } |
| 811 } | 811 } |
| 812 ASSERT(IsSignatureClass()); | 812 ASSERT(IsSignatureClass()); |
| 813 TypeArguments& signature_type_arguments = TypeArguments::Handle(); | |
| 814 const intptr_t num_type_params = NumTypeParameters(); | |
| 815 // A signature class extends class Instance and is parameterized in the same | 813 // A signature class extends class Instance and is parameterized in the same |
| 816 // way as the owner class of its non-static signature function. | 814 // way as the owner class of its non-static signature function. |
| 817 // It is not type parameterized if its signature function is static. | 815 // It is not type parameterized if its signature function is static. |
| 818 // See Class::NewSignatureClass() for the setup of its type parameters. | 816 // See Class::NewSignatureClass() for the setup of its type parameters. |
| 819 // During type finalization, the type arguments of the super class of the | 817 // During type finalization, the type arguments of the super class of the |
| 820 // owner class of its signature function will be prepended to the type | 818 // owner class of its signature function will be prepended to the type |
| 821 // argument vector. Therefore, we only need to set the type arguments | 819 // argument vector. Therefore, we only need to set the type arguments |
| 822 // matching the type parameters here. | 820 // matching the type parameters here. |
| 823 if (num_type_params > 0) { | 821 const TypeArguments& signature_type_arguments = |
| 824 const Array& type_params = Array::Handle(type_parameters()); | 822 TypeArguments::Handle(type_parameters()); |
| 825 // TODO(regis): Simply use the type parameters as type arguments, once type | |
| 826 // parameters are stored as an array of TypeParameter, rather than String. | |
| 827 signature_type_arguments = TypeArguments::New(num_type_params); | |
| 828 String& type_param_name = String::Handle(); | |
| 829 AbstractType& type_param = AbstractType::Handle(); | |
| 830 for (int i = 0; i < num_type_params; i++) { | |
| 831 type_param_name ^= type_params.At(i); | |
| 832 // TODO(regis): Use dummy token index 1 for now; see TODO above. | |
| 833 type_param = AbstractType::NewTypeParameter(i, type_param_name, 1); | |
| 834 signature_type_arguments.SetTypeAt(i, type_param); | |
| 835 } | |
| 836 } | |
| 837 const Type& signature_type = Type::Handle( | 823 const Type& signature_type = Type::Handle( |
| 838 Type::New(*this, signature_type_arguments, token_index())); | 824 Type::New(*this, signature_type_arguments, token_index())); |
| 839 | 825 |
| 840 // Return the still unfinalized signature type. | 826 // Return the still unfinalized signature type. |
| 841 ASSERT(!signature_type.IsFinalized()); | 827 ASSERT(!signature_type.IsFinalized()); |
| 842 return signature_type.raw(); | 828 return signature_type.raw(); |
| 843 } | 829 } |
| 844 | 830 |
| 845 | 831 |
| 846 template <class FakeObject> | 832 template <class FakeObject> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 state == RawClass::kFinalized); | 906 state == RawClass::kFinalized); |
| 921 raw_ptr()->class_state_ = state; | 907 raw_ptr()->class_state_ = state; |
| 922 } | 908 } |
| 923 | 909 |
| 924 | 910 |
| 925 void Class::set_library(const Library& value) const { | 911 void Class::set_library(const Library& value) const { |
| 926 StorePointer(&raw_ptr()->library_, value.raw()); | 912 StorePointer(&raw_ptr()->library_, value.raw()); |
| 927 } | 913 } |
| 928 | 914 |
| 929 | 915 |
| 930 void Class::set_type_parameters(const Array& value) const { | 916 void Class::set_type_parameters(const TypeArguments& value) const { |
| 931 StorePointer(&raw_ptr()->type_parameters_, value.raw()); | 917 StorePointer(&raw_ptr()->type_parameters_, value.raw()); |
| 932 } | 918 } |
| 933 | 919 |
| 934 | 920 |
| 935 void Class::set_type_parameter_extends(const TypeArguments& value) const { | 921 void Class::set_type_parameter_bounds(const TypeArguments& value) const { |
| 936 StorePointer(&raw_ptr()->type_parameter_extends_, value.raw()); | 922 StorePointer(&raw_ptr()->type_parameter_bounds_, value.raw()); |
| 937 } | 923 } |
| 938 | 924 |
| 939 | 925 |
| 940 intptr_t Class::NumTypeParameters() const { | 926 intptr_t Class::NumTypeParameters() const { |
| 941 const Array& type_params = Array::Handle(type_parameters()); | 927 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 942 if (type_params.IsNull()) { | 928 if (type_params.IsNull()) { |
| 943 return 0; | 929 return 0; |
| 944 } else { | 930 } else { |
| 945 return type_params.Length(); | 931 return type_params.Length(); |
| 946 } | 932 } |
| 947 } | 933 } |
| 948 | 934 |
| 949 | 935 |
| 950 intptr_t Class::NumTypeArguments() const { | 936 intptr_t Class::NumTypeArguments() const { |
| 951 // To work properly, this call requires the super class of this class to be | 937 // To work properly, this call requires the super class of this class to be |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 void Class::set_factory_class(const Object& value) const { | 1011 void Class::set_factory_class(const Object& value) const { |
| 1026 StorePointer(&raw_ptr()->factory_class_, value.raw()); | 1012 StorePointer(&raw_ptr()->factory_class_, value.raw()); |
| 1027 } | 1013 } |
| 1028 | 1014 |
| 1029 | 1015 |
| 1030 // Return a TypeParameter if the type_name is a type parameter of this class. | 1016 // Return a TypeParameter if the type_name is a type parameter of this class. |
| 1031 // Return null otherwise. | 1017 // Return null otherwise. |
| 1032 RawTypeParameter* Class::LookupTypeParameter(const String& type_name, | 1018 RawTypeParameter* Class::LookupTypeParameter(const String& type_name, |
| 1033 intptr_t token_index) const { | 1019 intptr_t token_index) const { |
| 1034 ASSERT(!type_name.IsNull()); | 1020 ASSERT(!type_name.IsNull()); |
| 1035 const Array& type_params = Array::Handle(type_parameters()); | 1021 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1036 if (!type_params.IsNull()) { | 1022 if (!type_params.IsNull()) { |
| 1037 intptr_t num_type_params = type_params.Length(); | 1023 intptr_t num_type_params = type_params.Length(); |
| 1038 String& type_param = String::Handle(); | 1024 TypeParameter& type_param = TypeParameter::Handle(); |
| 1025 String& type_param_name = String::Handle(); |
| 1039 for (intptr_t i = 0; i < num_type_params; i++) { | 1026 for (intptr_t i = 0; i < num_type_params; i++) { |
| 1040 type_param ^= type_params.At(i); | 1027 type_param ^= type_params.TypeAt(i); |
| 1041 if (type_param.Equals(type_name)) { | 1028 type_param_name = type_param.Name(); |
| 1029 if (type_param_name.Equals(type_name)) { |
| 1030 ASSERT(type_param.IsFinalized() || (type_param.Index() == i)); |
| 1031 // Create a new TypeParameter with the given token_index. |
| 1042 return TypeParameter::New(i, type_name, token_index); | 1032 return TypeParameter::New(i, type_name, token_index); |
| 1043 } | 1033 } |
| 1044 } | 1034 } |
| 1045 } | 1035 } |
| 1046 return TypeParameter::null(); | 1036 return TypeParameter::null(); |
| 1047 } | 1037 } |
| 1048 | 1038 |
| 1049 | 1039 |
| 1050 void Class::CalculateFieldOffsets() const { | 1040 void Class::CalculateFieldOffsets() const { |
| 1051 Array& flds = Array::Handle(fields()); | 1041 Array& flds = Array::Handle(fields()); |
| 1052 const Class& super = Class::Handle(SuperClass()); | 1042 const Class& super = Class::Handle(SuperClass()); |
| 1053 intptr_t offset = 0; | 1043 intptr_t offset = 0; |
| 1054 intptr_t type_args_field_offset = kNoTypeArguments; | 1044 intptr_t type_args_field_offset = kNoTypeArguments; |
| 1055 if (super.IsNull()) { | 1045 if (super.IsNull()) { |
| 1056 offset = sizeof(RawObject); | 1046 offset = sizeof(RawObject); |
| 1057 } else { | 1047 } else { |
| 1058 type_args_field_offset = super.type_arguments_instance_field_offset(); | 1048 type_args_field_offset = super.type_arguments_instance_field_offset(); |
| 1059 offset = super.next_field_offset(); | 1049 offset = super.next_field_offset(); |
| 1060 ASSERT(offset > 0); | 1050 ASSERT(offset > 0); |
| 1061 // We should never call CalculateFieldOffsets for native wrapper | 1051 // We should never call CalculateFieldOffsets for native wrapper |
| 1062 // classes, assert this. | 1052 // classes, assert this. |
| 1063 ASSERT(num_native_fields() == 0); | 1053 ASSERT(num_native_fields() == 0); |
| 1064 set_num_native_fields(super.num_native_fields()); | 1054 set_num_native_fields(super.num_native_fields()); |
| 1065 } | 1055 } |
| 1066 // If the super class is parameterized, use the same type_arguments field. | 1056 // If the super class is parameterized, use the same type_arguments field. |
| 1067 if (type_args_field_offset == kNoTypeArguments) { | 1057 if (type_args_field_offset == kNoTypeArguments) { |
| 1068 const Array& type_params = Array::Handle(type_parameters()); | 1058 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1069 if (!type_params.IsNull()) { | 1059 if (!type_params.IsNull()) { |
| 1070 ASSERT(type_params.Length() > 0); | 1060 ASSERT(type_params.Length() > 0); |
| 1071 // The instance needs a type_arguments field. | 1061 // The instance needs a type_arguments field. |
| 1072 type_args_field_offset = offset; | 1062 type_args_field_offset = offset; |
| 1073 offset += kWordSize; | 1063 offset += kWordSize; |
| 1074 } | 1064 } |
| 1075 } | 1065 } |
| 1076 set_type_arguments_instance_field_offset(type_args_field_offset); | 1066 set_type_arguments_instance_field_offset(type_args_field_offset); |
| 1077 ASSERT(offset != 0); | 1067 ASSERT(offset != 0); |
| 1078 Field& field = Field::Handle(); | 1068 Field& field = Field::Handle(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 return result.raw(); | 1158 return result.raw(); |
| 1169 } | 1159 } |
| 1170 | 1160 |
| 1171 | 1161 |
| 1172 RawClass* Class::NewSignatureClass(const String& name, | 1162 RawClass* Class::NewSignatureClass(const String& name, |
| 1173 const Function& signature_function, | 1163 const Function& signature_function, |
| 1174 const Script& script) { | 1164 const Script& script) { |
| 1175 ASSERT(!signature_function.IsNull()); | 1165 ASSERT(!signature_function.IsNull()); |
| 1176 const Class& owner_class = Class::Handle(signature_function.owner()); | 1166 const Class& owner_class = Class::Handle(signature_function.owner()); |
| 1177 ASSERT(!owner_class.IsNull()); | 1167 ASSERT(!owner_class.IsNull()); |
| 1178 Array& type_parameters = Array::Handle(); | 1168 TypeArguments& type_parameters = TypeArguments::Handle(); |
| 1179 TypeArguments& type_parameter_extends = TypeArguments::Handle(); | 1169 TypeArguments& type_parameter_bounds = TypeArguments::Handle(); |
| 1180 // A signature class extends class Instance and is parameterized in the same | 1170 // A signature class extends class Instance and is parameterized in the same |
| 1181 // way as the owner class of its non-static signature function. | 1171 // way as the owner class of its non-static signature function. |
| 1182 // It is not type parameterized if its signature function is static. | 1172 // It is not type parameterized if its signature function is static. |
| 1183 if (!signature_function.is_static()) { | 1173 if (!signature_function.is_static()) { |
| 1184 if ((owner_class.NumTypeParameters() > 0) && | 1174 if ((owner_class.NumTypeParameters() > 0) && |
| 1185 !signature_function.HasInstantiatedSignature()) { | 1175 !signature_function.HasInstantiatedSignature()) { |
| 1186 type_parameters = owner_class.type_parameters(); | 1176 type_parameters = owner_class.type_parameters(); |
| 1187 type_parameter_extends = owner_class.type_parameter_extends(); | 1177 type_parameter_bounds = owner_class.type_parameter_bounds(); |
| 1188 } | 1178 } |
| 1189 } | 1179 } |
| 1190 const intptr_t token_index = signature_function.token_index(); | 1180 const intptr_t token_index = signature_function.token_index(); |
| 1191 Class& result = Class::Handle(New<Closure>(name, script, token_index)); | 1181 Class& result = Class::Handle(New<Closure>(name, script, token_index)); |
| 1192 const Type& super_type = Type::Handle(Type::ObjectType()); | 1182 const Type& super_type = Type::Handle(Type::ObjectType()); |
| 1193 ASSERT(!super_type.IsNull()); | 1183 ASSERT(!super_type.IsNull()); |
| 1194 result.set_super_type(super_type); | 1184 result.set_super_type(super_type); |
| 1195 result.set_signature_function(signature_function); | 1185 result.set_signature_function(signature_function); |
| 1196 result.set_type_parameters(type_parameters); | 1186 result.set_type_parameters(type_parameters); |
| 1197 result.set_type_parameter_extends(type_parameter_extends); | 1187 result.set_type_parameter_bounds(type_parameter_bounds); |
| 1198 result.SetFields(Array::Handle(Array::Empty())); | 1188 result.SetFields(Array::Handle(Array::Empty())); |
| 1199 result.SetFunctions(Array::Handle(Array::Empty())); | 1189 result.SetFunctions(Array::Handle(Array::Empty())); |
| 1200 // Implements interface "Function". | 1190 // Implements interface "Function". |
| 1201 const Type& function_interface = Type::Handle(Type::FunctionInterface()); | 1191 const Type& function_interface = Type::Handle(Type::FunctionInterface()); |
| 1202 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld)); | 1192 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld)); |
| 1203 interfaces.SetAt(0, function_interface); | 1193 interfaces.SetAt(0, function_interface); |
| 1204 result.set_interfaces(interfaces); | 1194 result.set_interfaces(interfaces); |
| 1205 // Unless the signature function already has a signature class, create a | 1195 // Unless the signature function already has a signature class, create a |
| 1206 // canonical signature class by having the signature function point back to | 1196 // canonical signature class by having the signature function point back to |
| 1207 // the signature class. | 1197 // the signature class. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 // interface cannot be instantiated and we must check against a raw | 1441 // interface cannot be instantiated and we must check against a raw |
| 1452 // interface. | 1442 // interface. |
| 1453 interface_args = TypeArguments::null(); | 1443 interface_args = TypeArguments::null(); |
| 1454 } else { | 1444 } else { |
| 1455 // The type arguments of this type that are referred to by the type | 1445 // The type arguments of this type that are referred to by the type |
| 1456 // parameters of the interface are at the end of the type vector, | 1446 // parameters of the interface are at the end of the type vector, |
| 1457 // after the type arguments of the super type of this type. | 1447 // after the type arguments of the super type of this type. |
| 1458 // The index of the type parameters is adjusted upon finalization. | 1448 // The index of the type parameters is adjusted upon finalization. |
| 1459 ASSERT(interface.IsFinalized()); | 1449 ASSERT(interface.IsFinalized()); |
| 1460 interface_args = interface_args.InstantiateFrom(type_arguments); | 1450 interface_args = interface_args.InstantiateFrom(type_arguments); |
| 1461 // TODO(regis): Check the subtyping constraints if any, i.e. if | 1451 // TODO(regis): Do we have to consider the bounds of the type |
| 1462 // interface.type_parameter_extends() is not an array of DynamicType. | 1452 // parameters of the interface? |
| 1463 // Should we pass the constraints to InstantiateFrom and it would | |
| 1464 // return null on failure? | |
| 1465 } | 1453 } |
| 1466 } | 1454 } |
| 1467 if (interface_class.IsMoreSpecificThan(interface_args, | 1455 if (interface_class.IsMoreSpecificThan(interface_args, |
| 1468 other, | 1456 other, |
| 1469 other_type_arguments)) { | 1457 other_type_arguments)) { |
| 1470 return true; | 1458 return true; |
| 1471 } | 1459 } |
| 1472 } | 1460 } |
| 1473 } | 1461 } |
| 1474 // Check the interface case. | 1462 // Check the interface case. |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 RawType* Type::FunctionInterface() { | 2156 RawType* Type::FunctionInterface() { |
| 2169 return Isolate::Current()->object_store()->function_interface(); | 2157 return Isolate::Current()->object_store()->function_interface(); |
| 2170 } | 2158 } |
| 2171 | 2159 |
| 2172 | 2160 |
| 2173 RawType* Type::ListInterface() { | 2161 RawType* Type::ListInterface() { |
| 2174 return Isolate::Current()->object_store()->list_interface(); | 2162 return Isolate::Current()->object_store()->list_interface(); |
| 2175 } | 2163 } |
| 2176 | 2164 |
| 2177 | 2165 |
| 2178 RawType* Type::NewRawType(const Class& type_class, intptr_t token_index) { | |
| 2179 const AbstractTypeArguments& type_arguments = | |
| 2180 AbstractTypeArguments::Handle(type_class.type_parameter_extends()); | |
| 2181 return New(Object::Handle(type_class.raw()), type_arguments, token_index); | |
| 2182 } | |
| 2183 | |
| 2184 | |
| 2185 RawType* Type::NewNonParameterizedType( | 2166 RawType* Type::NewNonParameterizedType( |
| 2186 const Class& type_class) { | 2167 const Class& type_class) { |
| 2187 ASSERT(!type_class.HasTypeArguments()); | 2168 ASSERT(!type_class.HasTypeArguments()); |
| 2188 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 2169 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
| 2189 Type& type = Type::Handle(); | 2170 Type& type = Type::Handle(); |
| 2190 type ^= Type::New(Object::Handle(type_class.raw()), | 2171 type ^= Type::New(Object::Handle(type_class.raw()), |
| 2191 no_type_arguments, | 2172 no_type_arguments, |
| 2192 Scanner::kDummyTokenIndex); | 2173 Scanner::kDummyTokenIndex); |
| 2193 type.set_is_finalized(); | 2174 type.set_is_finalized(); |
| 2194 type ^= type.Canonicalize(); | 2175 type ^= type.Canonicalize(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 } | 2405 } |
| 2425 | 2406 |
| 2426 | 2407 |
| 2427 bool TypeParameter::Equals(const AbstractType& other) const { | 2408 bool TypeParameter::Equals(const AbstractType& other) const { |
| 2428 if (raw() == other.raw()) { | 2409 if (raw() == other.raw()) { |
| 2429 return true; | 2410 return true; |
| 2430 } | 2411 } |
| 2431 if (!other.IsTypeParameter()) { | 2412 if (!other.IsTypeParameter()) { |
| 2432 return false; | 2413 return false; |
| 2433 } | 2414 } |
| 2434 TypeParameter& other_type_parameter = TypeParameter::Handle(); | 2415 TypeParameter& other_type_param = TypeParameter::Handle(); |
| 2435 other_type_parameter ^= other.raw(); | 2416 other_type_param ^= other.raw(); |
| 2436 return Index() == other_type_parameter.Index(); | 2417 if (Index() != other_type_param.Index()) { |
| 2418 return false; |
| 2419 } |
| 2420 const String& name = String::Handle(Name()); |
| 2421 const String& other_type_param_name = String::Handle(other_type_param.Name()); |
| 2422 return name.Equals(other_type_param_name); |
| 2437 } | 2423 } |
| 2438 | 2424 |
| 2439 | 2425 |
| 2440 void TypeParameter::set_index(intptr_t value) const { | 2426 void TypeParameter::set_index(intptr_t value) const { |
| 2441 ASSERT(value >= 0); | 2427 ASSERT(value >= 0); |
| 2442 raw_ptr()->index_ = value; | 2428 raw_ptr()->index_ = value; |
| 2443 } | 2429 } |
| 2444 | 2430 |
| 2445 | 2431 |
| 2446 void TypeParameter::set_name(const String& value) const { | 2432 void TypeParameter::set_name(const String& value) const { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 | 2583 |
| 2598 | 2584 |
| 2599 bool AbstractTypeArguments::IsUninstantiatedIdentity() const { | 2585 bool AbstractTypeArguments::IsUninstantiatedIdentity() const { |
| 2600 // AbstractTypeArguments is an abstract class. | 2586 // AbstractTypeArguments is an abstract class. |
| 2601 UNREACHABLE(); | 2587 UNREACHABLE(); |
| 2602 return false; | 2588 return false; |
| 2603 } | 2589 } |
| 2604 | 2590 |
| 2605 | 2591 |
| 2606 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { | 2592 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { |
| 2593 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual(). |
| 2607 if (this->raw() == other.raw()) { | 2594 if (this->raw() == other.raw()) { |
| 2608 return true; | 2595 return true; |
| 2609 } | 2596 } |
| 2597 if (other.IsNull()) { |
| 2598 return false; |
| 2599 } |
| 2610 intptr_t num_types = Length(); | 2600 intptr_t num_types = Length(); |
| 2611 if (num_types != other.Length()) { | 2601 if (num_types != other.Length()) { |
| 2612 return false; | 2602 return false; |
| 2613 } | 2603 } |
| 2614 AbstractType& type = AbstractType::Handle(); | 2604 AbstractType& type = AbstractType::Handle(); |
| 2615 AbstractType& other_type = AbstractType::Handle(); | 2605 AbstractType& other_type = AbstractType::Handle(); |
| 2616 for (intptr_t i = 0; i < num_types; i++) { | 2606 for (intptr_t i = 0; i < num_types; i++) { |
| 2617 type = TypeAt(i); | 2607 type = TypeAt(i); |
| 2618 other_type = other.TypeAt(i); | 2608 other_type = other.TypeAt(i); |
| 2619 if (!type.Equals(other_type)) { | 2609 if (!type.Equals(other_type)) { |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 const String& kRParen = String::Handle(String::NewSymbol(") => ")); | 3477 const String& kRParen = String::Handle(String::NewSymbol(") => ")); |
| 3488 const String& kLBracket = String::Handle(String::NewSymbol("[")); | 3478 const String& kLBracket = String::Handle(String::NewSymbol("[")); |
| 3489 const String& kRBracket = String::Handle(String::NewSymbol("]")); | 3479 const String& kRBracket = String::Handle(String::NewSymbol("]")); |
| 3490 if (!instantiate && !is_static()) { | 3480 if (!instantiate && !is_static()) { |
| 3491 const String& kSpaceExtendsSpace = | 3481 const String& kSpaceExtendsSpace = |
| 3492 String::Handle(String::NewSymbol(" extends ")); | 3482 String::Handle(String::NewSymbol(" extends ")); |
| 3493 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); | 3483 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); |
| 3494 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); | 3484 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); |
| 3495 const Class& function_class = Class::Handle(owner()); | 3485 const Class& function_class = Class::Handle(owner()); |
| 3496 ASSERT(!function_class.IsNull()); | 3486 ASSERT(!function_class.IsNull()); |
| 3497 const Array& type_parameters = Array::Handle( | 3487 const TypeArguments& type_parameters = TypeArguments::Handle( |
| 3498 function_class.type_parameters()); | 3488 function_class.type_parameters()); |
| 3499 if (!type_parameters.IsNull()) { | 3489 if (!type_parameters.IsNull()) { |
| 3500 intptr_t num_type_parameters = type_parameters.Length(); | 3490 intptr_t num_type_parameters = type_parameters.Length(); |
| 3501 pieces.Add(&kLAngleBracket); | 3491 pieces.Add(&kLAngleBracket); |
| 3502 const TypeArguments& type_parameter_extends = TypeArguments::Handle( | 3492 const TypeArguments& bounds = TypeArguments::Handle( |
| 3503 function_class.type_parameter_extends()); | 3493 function_class.type_parameter_bounds()); |
| 3504 AbstractType& parameter_extends = AbstractType::Handle(); | 3494 AbstractType& type_parameter = AbstractType::Handle(); |
| 3495 AbstractType& bound = AbstractType::Handle(); |
| 3505 for (intptr_t i = 0; i < num_type_parameters; i++) { | 3496 for (intptr_t i = 0; i < num_type_parameters; i++) { |
| 3506 String& type_parameter = String::ZoneHandle(); | 3497 type_parameter ^= type_parameters.TypeAt(i); |
| 3507 type_parameter ^= type_parameters.At(i); | 3498 pieces.Add(&String::ZoneHandle(type_parameter.Name())); |
| 3508 pieces.Add(&type_parameter); | 3499 bound = bounds.TypeAt(i); |
| 3509 parameter_extends = type_parameter_extends.TypeAt(i); | 3500 if (!bound.IsNull() && !bound.IsDynamicType()) { |
| 3510 if (!parameter_extends.IsNull() && !parameter_extends.IsDynamicType()) { | |
| 3511 pieces.Add(&kSpaceExtendsSpace); | 3501 pieces.Add(&kSpaceExtendsSpace); |
| 3512 pieces.Add(&String::ZoneHandle(parameter_extends.Name())); | 3502 pieces.Add(&String::ZoneHandle(bound.Name())); |
| 3513 } | 3503 } |
| 3514 if (i < num_type_parameters - 1) { | 3504 if (i < num_type_parameters - 1) { |
| 3515 pieces.Add(&kCommaSpace); | 3505 pieces.Add(&kCommaSpace); |
| 3516 } | 3506 } |
| 3517 } | 3507 } |
| 3518 pieces.Add(&kRAngleBracket); | 3508 pieces.Add(&kRAngleBracket); |
| 3519 } | 3509 } |
| 3520 } | 3510 } |
| 3521 AbstractType& param_type = AbstractType::Handle(); | 3511 AbstractType& param_type = AbstractType::Handle(); |
| 3522 const intptr_t num_params = NumberOfParameters(); | 3512 const intptr_t num_params = NumberOfParameters(); |
| (...skipping 4463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7986 const String& str = String::Handle(pattern()); | 7976 const String& str = String::Handle(pattern()); |
| 7987 const char* format = "JSRegExp: pattern=%s flags=%s"; | 7977 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 7988 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 7978 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 7989 char* chars = reinterpret_cast<char*>( | 7979 char* chars = reinterpret_cast<char*>( |
| 7990 Isolate::Current()->current_zone()->Allocate(len + 1)); | 7980 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 7991 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7981 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 7992 return chars; | 7982 return chars; |
| 7993 } | 7983 } |
| 7994 | 7984 |
| 7995 } // namespace dart | 7985 } // namespace dart |
| OLD | NEW |