| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 // below), we only check a prefix of the proper length. | 1231 // below), we only check a prefix of the proper length. |
| 1232 // Check for covariance. | 1232 // Check for covariance. |
| 1233 if (type_arguments.IsNull() || | 1233 if (type_arguments.IsNull() || |
| 1234 other_type_arguments.IsNull() || | 1234 other_type_arguments.IsNull() || |
| 1235 type_arguments.IsVarTypes(len) || | 1235 type_arguments.IsVarTypes(len) || |
| 1236 other_type_arguments.IsVarTypes(len)) { | 1236 other_type_arguments.IsVarTypes(len)) { |
| 1237 return true; | 1237 return true; |
| 1238 } | 1238 } |
| 1239 return type_arguments.IsMoreSpecificThan(other_type_arguments, len); | 1239 return type_arguments.IsMoreSpecificThan(other_type_arguments, len); |
| 1240 } | 1240 } |
| 1241 // Check for two function types. |
| 1242 if (IsSignatureClass() && other.IsSignatureClass()) { |
| 1243 const Function& fun = Function::Handle(signature_function()); |
| 1244 const Function& other_fun = Function::Handle(other.signature_function()); |
| 1245 return fun.IsSubtypeOf(type_arguments, |
| 1246 other_fun, |
| 1247 other_type_arguments); |
| 1248 } |
| 1241 // Check for 'direct super type' in the case of an interface and check for | 1249 // Check for 'direct super type' in the case of an interface and check for |
| 1242 // transitivity at the same time. | 1250 // transitivity at the same time. |
| 1243 if (other.is_interface()) { | 1251 if (other.is_interface()) { |
| 1244 Array& interfaces = Array::Handle(this->interfaces()); | 1252 Array& interfaces = Array::Handle(this->interfaces()); |
| 1245 Type& interface = Type::Handle(); | 1253 Type& interface = Type::Handle(); |
| 1246 Class& interface_class = Class::Handle(); | 1254 Class& interface_class = Class::Handle(); |
| 1247 TypeArguments& interface_args = TypeArguments::Handle(); | 1255 TypeArguments& interface_args = TypeArguments::Handle(); |
| 1248 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 1256 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 1249 interface ^= interfaces.At(i); | 1257 interface ^= interfaces.At(i); |
| 1250 interface_class = interface.type_class(); | 1258 interface_class = interface.type_class(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1272 // return null on failure? | 1280 // return null on failure? |
| 1273 } | 1281 } |
| 1274 } | 1282 } |
| 1275 if (interface_class.IsMoreSpecificThan(interface_args, | 1283 if (interface_class.IsMoreSpecificThan(interface_args, |
| 1276 other, | 1284 other, |
| 1277 other_type_arguments)) { | 1285 other_type_arguments)) { |
| 1278 return true; | 1286 return true; |
| 1279 } | 1287 } |
| 1280 } | 1288 } |
| 1281 } | 1289 } |
| 1282 if (IsSignatureClass() && other.IsSignatureClass()) { | 1290 // Check the interface case. |
| 1283 const Function& fun = Function::Handle(signature_function()); | |
| 1284 const Function& other_fun = Function::Handle(other.signature_function()); | |
| 1285 return fun.IsSubtypeOf(type_arguments, | |
| 1286 other_fun, | |
| 1287 other_type_arguments); | |
| 1288 } | |
| 1289 | |
| 1290 if (is_interface()) { | 1291 if (is_interface()) { |
| 1291 // We already checked the case where 'other' is an interface. Now, 'this', | 1292 // We already checked the case where 'other' is an interface. Now, 'this', |
| 1292 // an interface, cannot be more specific than a class, except class Object, | 1293 // an interface, cannot be more specific than a class, except class Object, |
| 1293 // because although Object is not considered an interface by the vm, it is | 1294 // because although Object is not considered an interface by the vm, it is |
| 1294 // one. In other words, all classes implementing this interface also extend | 1295 // one. In other words, all classes implementing this interface also extend |
| 1295 // class Object. An interface is also more specific than the VarType. | 1296 // class Object. An interface is also more specific than the VarType. |
| 1296 return (other.IsVarClass() || other.IsObjectClass()); | 1297 return (other.IsVarClass() || other.IsObjectClass()); |
| 1297 } | 1298 } |
| 1298 const Class& super_class = Class::Handle(SuperClass()); | 1299 const Class& super_class = Class::Handle(SuperClass()); |
| 1299 if (super_class.IsNull()) { | 1300 if (super_class.IsNull()) { |
| (...skipping 5486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6786 const String& str = String::Handle(pattern()); | 6787 const String& str = String::Handle(pattern()); |
| 6787 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6788 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 6788 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6789 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 6789 char* chars = reinterpret_cast<char*>( | 6790 char* chars = reinterpret_cast<char*>( |
| 6790 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6791 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 6791 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 6792 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 6792 return chars; | 6793 return chars; |
| 6793 } | 6794 } |
| 6794 | 6795 |
| 6795 } // namespace dart | 6796 } // namespace dart |
| OLD | NEW |