Chromium Code Reviews| 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 "lib/invocation_mirror.h" | 5 #include "lib/invocation_mirror.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 // so as to produce the same NoSuchMethodError as the non-reflective case. | 1403 // so as to produce the same NoSuchMethodError as the non-reflective case. |
| 1404 lookup_constructor = Function::null(); | 1404 lookup_constructor = Function::null(); |
| 1405 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), | 1405 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), |
| 1406 internal_constructor_name, | 1406 internal_constructor_name, |
| 1407 lookup_constructor, | 1407 lookup_constructor, |
| 1408 InvocationMirror::kConstructor, | 1408 InvocationMirror::kConstructor, |
| 1409 InvocationMirror::kMethod); | 1409 InvocationMirror::kMethod); |
| 1410 UNREACHABLE(); | 1410 UNREACHABLE(); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 ASSERT(!type.IsNull()); | |
| 1414 AbstractTypeArguments& type_arguments = | |
| 1415 AbstractTypeArguments::Handle(type.arguments()); | |
| 1416 | |
| 1413 Class& redirected_klass = Class::Handle(klass.raw()); | 1417 Class& redirected_klass = Class::Handle(klass.raw()); |
| 1414 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); | 1418 Function& redirected_constructor = Function::Handle(lookup_constructor.raw()); |
| 1415 if (lookup_constructor.IsRedirectingFactory()) { | 1419 if (lookup_constructor.IsRedirectingFactory()) { |
| 1416 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); | 1420 ClassFinalizer::ResolveRedirectingFactory(klass, lookup_constructor); |
| 1417 Type& type = Type::Handle(lookup_constructor.RedirectionType()); | 1421 Type& redirect_type = Type::Handle(lookup_constructor.RedirectionType()); |
| 1422 | |
| 1423 if (!redirect_type.IsMalformed() && !redirect_type.IsInstantiated()) { | |
| 1424 // The type arguments of the redirection type are instantiated from the | |
| 1425 // type arguments of the parsed type of the 'new' or 'const' expression. | |
| 1426 Error& malformed_error = Error::Handle(); | |
|
regis
2013/10/01 18:01:53
Actually, this can only be a bound_error, not malf
rmacnak
2013/10/01 18:23:12
Done. Was from the parser code for new.
| |
| 1427 redirect_type ^= redirect_type.InstantiateFrom(type_arguments, | |
| 1428 &malformed_error); | |
| 1429 if (!malformed_error.IsNull()) { | |
| 1430 ThrowInvokeError(malformed_error); | |
| 1431 UNREACHABLE(); | |
| 1432 } | |
| 1433 } | |
| 1434 | |
| 1435 type = redirect_type.raw(); | |
| 1436 type_arguments = redirect_type.arguments(); | |
| 1437 | |
| 1418 redirected_constructor = lookup_constructor.RedirectionTarget(); | 1438 redirected_constructor = lookup_constructor.RedirectionTarget(); |
| 1419 ASSERT(!redirected_constructor.IsNull()); | 1439 ASSERT(!redirected_constructor.IsNull()); |
| 1420 redirected_klass = type.type_class(); | 1440 redirected_klass = type.type_class(); |
| 1421 } | 1441 } |
| 1422 | 1442 |
| 1423 const intptr_t num_explicit_args = explicit_args.Length(); | 1443 const intptr_t num_explicit_args = explicit_args.Length(); |
| 1424 const intptr_t num_implicit_args = | 1444 const intptr_t num_implicit_args = |
| 1425 redirected_constructor.IsConstructor() ? 2 : 1; | 1445 redirected_constructor.IsConstructor() ? 2 : 1; |
| 1426 const Array& args = | 1446 const Array& args = |
| 1427 Array::Handle(Array::New(num_implicit_args + num_explicit_args)); | 1447 Array::Handle(Array::New(num_implicit_args + num_explicit_args)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1444 // so as to produce the same NoSuchMethodError as the non-reflective case. | 1464 // so as to produce the same NoSuchMethodError as the non-reflective case. |
| 1445 redirected_constructor = Function::null(); | 1465 redirected_constructor = Function::null(); |
| 1446 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), | 1466 ThrowNoSuchMethod(AbstractType::Handle(klass.RareType()), |
| 1447 internal_constructor_name, | 1467 internal_constructor_name, |
| 1448 redirected_constructor, | 1468 redirected_constructor, |
| 1449 InvocationMirror::kConstructor, | 1469 InvocationMirror::kConstructor, |
| 1450 InvocationMirror::kMethod); | 1470 InvocationMirror::kMethod); |
| 1451 UNREACHABLE(); | 1471 UNREACHABLE(); |
| 1452 } | 1472 } |
| 1453 | 1473 |
| 1454 ASSERT(!type.IsNull()); | |
| 1455 const AbstractTypeArguments& type_arguments = | |
| 1456 AbstractTypeArguments::Handle(type.arguments()); | |
| 1457 | |
| 1458 Instance& new_object = Instance::Handle(); | 1474 Instance& new_object = Instance::Handle(); |
| 1459 if (redirected_constructor.IsConstructor()) { | 1475 if (redirected_constructor.IsConstructor()) { |
| 1460 // Constructors get the uninitialized object and a constructor phase. Note | 1476 // Constructors get the uninitialized object and a constructor phase. Note |
| 1461 // we have delayed allocation until after the function type and argument | 1477 // we have delayed allocation until after the function type and argument |
| 1462 // matching checks. | 1478 // matching checks. |
| 1463 new_object = Instance::New(redirected_klass); | 1479 new_object = Instance::New(redirected_klass); |
| 1464 if (!type_arguments.IsNull()) { | 1480 if (!type_arguments.IsNull()) { |
| 1465 // The type arguments will be null if the class has no type parameters, in | 1481 // The type arguments will be null if the class has no type parameters, in |
| 1466 // which case the following call would fail because there is no slot | 1482 // which case the following call would fail because there is no slot |
| 1467 // reserved in the object for the type vector. | 1483 // reserved in the object for the type vector. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1681 } | 1697 } |
| 1682 | 1698 |
| 1683 | 1699 |
| 1684 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1700 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1685 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1701 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1686 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1702 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1687 return field.type(); | 1703 return field.type(); |
| 1688 } | 1704 } |
| 1689 | 1705 |
| 1690 } // namespace dart | 1706 } // namespace dart |
| OLD | NEW |