| 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 "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2762 invocation.set_result_type(Type::Handle(Type::DynamicType())); | 2762 invocation.set_result_type(Type::Handle(Type::DynamicType())); |
| 2763 invocation.set_is_debuggable(false); | 2763 invocation.set_is_debuggable(false); |
| 2764 invocation.set_is_visible(false); | 2764 invocation.set_is_visible(false); |
| 2765 invocation.set_is_reflectable(false); | 2765 invocation.set_is_reflectable(false); |
| 2766 invocation.set_saved_args_desc(args_desc); | 2766 invocation.set_saved_args_desc(args_desc); |
| 2767 | 2767 |
| 2768 return invocation.raw(); | 2768 return invocation.raw(); |
| 2769 } | 2769 } |
| 2770 | 2770 |
| 2771 | 2771 |
| 2772 // Method extractors are used to create implicit closures from methods. |
| 2773 // When an expression obj.M is evaluated for the first time and receiver obj |
| 2774 // does not have a getter called M but has a method called M then an extractor |
| 2775 // is created and injected as a getter (under the name get:M) into the class |
| 2776 // owning method M. |
| 2777 RawFunction* Function::CreateMethodExtractor(const String& getter_name) const { |
| 2778 const Function& closure_function = |
| 2779 Function::Handle(ImplicitClosureFunction()); |
| 2780 |
| 2781 const Class& owner = Class::Handle(closure_function.Owner()); |
| 2782 Function& extractor = Function::Handle( |
| 2783 Function::New(String::Handle(Symbols::New(getter_name)), |
| 2784 RawFunction::kMethodExtractor, |
| 2785 false, // Not static. |
| 2786 false, // Not const. |
| 2787 false, // Not abstract. |
| 2788 false, // Not external. |
| 2789 false, // Not native. |
| 2790 owner, |
| 2791 0)); // No token position. |
| 2792 |
| 2793 // Initialize signature: receiver is a single fixed parameter. |
| 2794 const intptr_t kNumParameters = 1; |
| 2795 extractor.set_num_fixed_parameters(kNumParameters); |
| 2796 extractor.SetNumOptionalParameters(0, 0); |
| 2797 extractor.set_parameter_types(Object::extractor_parameter_types()); |
| 2798 extractor.set_parameter_names(Object::extractor_parameter_names()); |
| 2799 extractor.set_result_type(Type::Handle(Type::DynamicType())); |
| 2800 |
| 2801 extractor.set_extracted_method_closure(closure_function); |
| 2802 extractor.set_is_debuggable(false); |
| 2803 extractor.set_is_visible(false); |
| 2804 owner.AddFunction(extractor); |
| 2805 |
| 2806 return extractor.raw(); |
| 2807 } |
| 2808 |
| 2809 |
| 2810 RawFunction* Function::GetMethodExtractor(const String& getter_name) const { |
| 2811 const Function& closure_function = |
| 2812 Function::Handle(ImplicitClosureFunction()); |
| 2813 const Class& owner = Class::Handle(closure_function.Owner()); |
| 2814 Function& result = Function::Handle(owner.LookupDynamicFunction(getter_name)); |
| 2815 if (result.IsNull()) { |
| 2816 result ^= CreateMethodExtractor(getter_name); |
| 2817 } |
| 2818 ASSERT(result.kind() == RawFunction::kMethodExtractor); |
| 2819 return result.raw(); |
| 2820 } |
| 2821 |
| 2822 |
| 2772 RawArray* Class::invocation_dispatcher_cache() const { | 2823 RawArray* Class::invocation_dispatcher_cache() const { |
| 2773 return raw_ptr()->invocation_dispatcher_cache_; | 2824 return raw_ptr()->invocation_dispatcher_cache_; |
| 2774 } | 2825 } |
| 2775 | 2826 |
| 2776 | 2827 |
| 2777 void Class::set_invocation_dispatcher_cache(const Array& cache) const { | 2828 void Class::set_invocation_dispatcher_cache(const Array& cache) const { |
| 2778 StorePointer(&raw_ptr()->invocation_dispatcher_cache_, cache.raw()); | 2829 StorePointer(&raw_ptr()->invocation_dispatcher_cache_, cache.raw()); |
| 2779 } | 2830 } |
| 2780 | 2831 |
| 2781 | 2832 |
| (...skipping 18790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21572 return tag_label.ToCString(); | 21623 return tag_label.ToCString(); |
| 21573 } | 21624 } |
| 21574 | 21625 |
| 21575 | 21626 |
| 21576 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21627 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21577 Instance::PrintJSONImpl(stream, ref); | 21628 Instance::PrintJSONImpl(stream, ref); |
| 21578 } | 21629 } |
| 21579 | 21630 |
| 21580 | 21631 |
| 21581 } // namespace dart | 21632 } // namespace dart |
| OLD | NEW |