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/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 595 } |
596 if (!result.IsSmi()) { | 596 if (!result.IsSmi()) { |
597 const Class& cls = Class::Handle(result.clazz()); | 597 const Class& cls = Class::Handle(result.clazz()); |
598 ASSERT(!cls.IsNull()); | 598 ASSERT(!cls.IsNull()); |
599 function = cls.signature_function(); | 599 function = cls.signature_function(); |
600 if (!function.IsNull()) { | 600 if (!function.IsNull()) { |
601 arguments.SetReturn(result); | 601 arguments.SetReturn(result); |
602 return; // Return closure object. | 602 return; // Return closure object. |
603 } | 603 } |
604 } | 604 } |
605 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, invoke_arguments); | 605 Exceptions::ThrowByType( |
| 606 result.IsNull() ? Exceptions::kNullPointer : |
| 607 Exceptions::kObjectNotClosure, |
| 608 invoke_arguments); |
606 } | 609 } |
607 | 610 |
608 | 611 |
609 // Invoke Implicit Closure function. | 612 // Invoke Implicit Closure function. |
610 // Arg0: closure object. | 613 // Arg0: closure object. |
611 // Arg1: arguments descriptor (originally passed as dart instance invocation). | 614 // Arg1: arguments descriptor (originally passed as dart instance invocation). |
612 // Arg2: arguments array (originally passed to dart instance invocation). | 615 // Arg2: arguments array (originally passed to dart instance invocation). |
613 DEFINE_RUNTIME_ENTRY(InvokeImplicitClosureFunction, 3) { | 616 DEFINE_RUNTIME_ENTRY(InvokeImplicitClosureFunction, 3) { |
614 ASSERT(arguments.Count() == | 617 ASSERT(arguments.Count() == |
615 kInvokeImplicitClosureFunctionRuntimeEntry.argument_count()); | 618 kInvokeImplicitClosureFunctionRuntimeEntry.argument_count()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 722 } |
720 | 723 |
721 | 724 |
722 // Report that an object is not a closure. | 725 // Report that an object is not a closure. |
723 // Arg0: non-closure object. | 726 // Arg0: non-closure object. |
724 // Arg1: arguments array. | 727 // Arg1: arguments array. |
725 DEFINE_RUNTIME_ENTRY(ReportObjectNotClosure, 2) { | 728 DEFINE_RUNTIME_ENTRY(ReportObjectNotClosure, 2) { |
726 ASSERT(arguments.Count() == | 729 ASSERT(arguments.Count() == |
727 kReportObjectNotClosureRuntimeEntry.argument_count()); | 730 kReportObjectNotClosureRuntimeEntry.argument_count()); |
728 const Instance& bad_closure = Instance::CheckedHandle(arguments.At(0)); | 731 const Instance& bad_closure = Instance::CheckedHandle(arguments.At(0)); |
| 732 if (bad_closure.IsNull()) { |
| 733 GrowableArray<const Object*> args; |
| 734 Exceptions::ThrowByType(Exceptions::kNullPointer, args); |
| 735 } |
729 // const Array& arguments = Array::CheckedHandle(arguments.At(1)); | 736 // const Array& arguments = Array::CheckedHandle(arguments.At(1)); |
730 OS::PrintErr("object '%s' is not a closure\n", bad_closure.ToCString()); | 737 OS::PrintErr("object '%s' is not a closure\n", bad_closure.ToCString()); |
731 GrowableArray<const Object*> args; | 738 GrowableArray<const Object*> args; |
732 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, args); | 739 Exceptions::ThrowByType(Exceptions::kObjectNotClosure, args); |
733 } | 740 } |
734 | 741 |
735 | 742 |
736 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { | 743 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { |
737 ASSERT(arguments.Count() == | 744 ASSERT(arguments.Count() == |
738 kClosureArgumentMismatchRuntimeEntry.argument_count()); | 745 kClosureArgumentMismatchRuntimeEntry.argument_count()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 } | 950 } |
944 } | 951 } |
945 } | 952 } |
946 // The cache is null terminated, therefore the loop above should never | 953 // The cache is null terminated, therefore the loop above should never |
947 // terminate by itself. | 954 // terminate by itself. |
948 UNREACHABLE(); | 955 UNREACHABLE(); |
949 return Code::null(); | 956 return Code::null(); |
950 } | 957 } |
951 | 958 |
952 } // namespace dart | 959 } // namespace dart |
OLD | NEW |