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/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 | 1418 |
1419 DEFINE_NATIVE_ENTRY(InstanceMirror_computeType, 1) { | 1419 DEFINE_NATIVE_ENTRY(InstanceMirror_computeType, 1) { |
1420 GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0)); | 1420 GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0)); |
1421 const Type& type = Type::Handle(instance.GetType()); | 1421 const Type& type = Type::Handle(instance.GetType()); |
1422 // The static type of null is specified to be the bottom type, however, the | 1422 // The static type of null is specified to be the bottom type, however, the |
1423 // runtime type of null is the Null type, which we correctly return here. | 1423 // runtime type of null is the Null type, which we correctly return here. |
1424 return type.Canonicalize(); | 1424 return type.Canonicalize(); |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 DEFINE_NATIVE_ENTRY(ClosureMirror_apply, 3) { | 1428 DEFINE_NATIVE_ENTRY(ClosureMirror_apply, 2) { |
1429 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); | 1429 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(0)); |
1430 ASSERT(!closure.IsNull() && closure.IsCallable(NULL, NULL)); | 1430 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(1)); |
1431 GET_NON_NULL_NATIVE_ARGUMENT(Array, args, arguments->NativeArgAt(1)); | |
1432 GET_NON_NULL_NATIVE_ARGUMENT(Array, arg_names, arguments->NativeArgAt(2)); | |
1433 | 1431 |
1434 const Array& args_descriptor = | 1432 const Array& args_descriptor = |
1435 Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names)); | 1433 Array::Handle(ArgumentsDescriptor::New(args.Length(), arg_names)); |
1436 | 1434 |
1437 const Object& result = | 1435 const Object& result = |
1438 Object::Handle(DartEntry::InvokeClosure(args, args_descriptor)); | 1436 Object::Handle(DartEntry::InvokeClosure(args, args_descriptor)); |
1439 if (result.IsError()) { | 1437 if (result.IsError()) { |
1440 ThrowInvokeError(Error::Cast(result)); | 1438 ThrowInvokeError(Error::Cast(result)); |
1441 UNREACHABLE(); | 1439 UNREACHABLE(); |
1442 } | 1440 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 return result_tuple.raw(); | 1521 return result_tuple.raw(); |
1524 } | 1522 } |
1525 | 1523 |
1526 | 1524 |
1527 DEFINE_NATIVE_ENTRY(ClosureMirror_function, 1) { | 1525 DEFINE_NATIVE_ENTRY(ClosureMirror_function, 1) { |
1528 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); | 1526 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); |
1529 ASSERT(!closure.IsNull()); | 1527 ASSERT(!closure.IsNull()); |
1530 | 1528 |
1531 Function& function = Function::Handle(); | 1529 Function& function = Function::Handle(); |
1532 bool callable = closure.IsCallable(&function, NULL); | 1530 bool callable = closure.IsCallable(&function, NULL); |
1533 ASSERT(callable); | 1531 if (callable) { |
1534 | 1532 return CreateMethodMirror(function, Instance::null_instance()); |
1535 return CreateMethodMirror(function, Instance::null_instance()); | 1533 } |
| 1534 return Instance::null(); |
1536 } | 1535 } |
1537 | 1536 |
1538 | 1537 |
1539 DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) { | 1538 DEFINE_NATIVE_ENTRY(ClassMirror_invoke, 5) { |
1540 // Argument 0 is the mirror, which is unused by the native. It exists | 1539 // Argument 0 is the mirror, which is unused by the native. It exists |
1541 // because this native is an instance method in order to be polymorphic | 1540 // because this native is an instance method in order to be polymorphic |
1542 // with its cousins. | 1541 // with its cousins. |
1543 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 1542 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
1544 const Class& klass = Class::Handle(ref.GetClassReferent()); | 1543 const Class& klass = Class::Handle(ref.GetClassReferent()); |
1545 GET_NON_NULL_NATIVE_ARGUMENT( | 1544 GET_NON_NULL_NATIVE_ARGUMENT( |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 } | 1974 } |
1976 | 1975 |
1977 | 1976 |
1978 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1977 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
1979 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1978 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
1980 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1979 const Field& field = Field::Handle(ref.GetFieldReferent()); |
1981 return field.type(); | 1980 return field.type(); |
1982 } | 1981 } |
1983 | 1982 |
1984 } // namespace dart | 1983 } // namespace dart |
OLD | NEW |