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 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 dispatcher ^= CreateNoSuchMethodDispatcher(target_name, args_desc); | 1820 dispatcher ^= CreateNoSuchMethodDispatcher(target_name, args_desc); |
1821 cache.SetAt(i + kNameIndex, target_name); | 1821 cache.SetAt(i + kNameIndex, target_name); |
1822 cache.SetAt(i + kArgsDescIndex, args_desc); | 1822 cache.SetAt(i + kArgsDescIndex, args_desc); |
1823 cache.SetAt(i + kFunctionIndex, dispatcher); | 1823 cache.SetAt(i + kFunctionIndex, dispatcher); |
1824 } | 1824 } |
1825 return dispatcher.raw(); | 1825 return dispatcher.raw(); |
1826 } | 1826 } |
1827 | 1827 |
1828 | 1828 |
1829 RawFunction* Class::CreateNoSuchMethodDispatcher(const String& target_name, | 1829 RawFunction* Class::CreateNoSuchMethodDispatcher(const String& target_name, |
1830 const Array& args_desc) const { | 1830 const Array& args_desc) const { |
1831 Function& invocation = Function::Handle( | 1831 Function& invocation = Function::Handle( |
1832 Function::New(String::Handle(Symbols::New(target_name)), | 1832 Function::New(String::Handle(Symbols::New(target_name)), |
1833 RawFunction::kNoSuchMethodDispatcher, | 1833 RawFunction::kNoSuchMethodDispatcher, |
1834 false, // Not static. | 1834 false, // Not static. |
1835 false, // Not const. | 1835 false, // Not const. |
1836 false, // Not abstract. | 1836 false, // Not abstract. |
1837 false, // Not external. | 1837 false, // Not external. |
1838 *this, | 1838 *this, |
1839 0)); // No token position. | 1839 0)); // No token position. |
1840 ArgumentsDescriptor desc(args_desc); | 1840 ArgumentsDescriptor desc(args_desc); |
1841 const intptr_t num_parameters = desc.Count(); | 1841 invocation.set_num_fixed_parameters(desc.PositionalCount()); |
1842 invocation.set_num_fixed_parameters(num_parameters); | 1842 invocation.SetNumOptionalParameters(desc.NamedCount(), |
1843 invocation.SetNumOptionalParameters(0, true); | 1843 false); // Not positional. |
1844 invocation.set_parameter_types(Array::Handle(Array::New(num_parameters, | 1844 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), |
1845 Heap::kOld))); | 1845 Heap::kOld))); |
1846 invocation.set_parameter_names(Array::Handle(Array::New(num_parameters, | 1846 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), |
1847 Heap::kOld))); | 1847 Heap::kOld))); |
1848 // Receiver. | 1848 // Receiver. |
1849 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); | 1849 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); |
1850 invocation.SetParameterNameAt(0, Symbols::This()); | 1850 invocation.SetParameterNameAt(0, Symbols::This()); |
1851 // Remaining parameters. | 1851 // Remaining positional parameters. |
1852 for (intptr_t i = 1; i < num_parameters; i++) { | 1852 intptr_t i = 1; |
| 1853 for (; i < desc.PositionalCount(); i++) { |
1853 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); | 1854 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); |
1854 char name[64]; | 1855 char name[64]; |
1855 OS::SNPrint(name, 64, ":p%"Pd, i); | 1856 OS::SNPrint(name, 64, ":p%"Pd, i); |
1856 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); | 1857 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); |
1857 } | 1858 } |
| 1859 |
| 1860 // Named parameters. |
| 1861 for (; i < desc.Count(); i++) { |
| 1862 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); |
| 1863 intptr_t index = i - desc.PositionalCount(); |
| 1864 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index))); |
| 1865 } |
1858 invocation.set_result_type(Type::Handle(Type::DynamicType())); | 1866 invocation.set_result_type(Type::Handle(Type::DynamicType())); |
1859 invocation.set_is_visible(false); // Not visible in stack trace. | 1867 invocation.set_is_visible(false); // Not visible in stack trace. |
1860 invocation.set_saved_args_desc(args_desc); | 1868 invocation.set_saved_args_desc(args_desc); |
1861 | 1869 |
1862 return invocation.raw(); | 1870 return invocation.raw(); |
1863 } | 1871 } |
1864 | 1872 |
1865 | 1873 |
1866 RawArray* Class::no_such_method_cache() const { | 1874 RawArray* Class::no_such_method_cache() const { |
1867 return raw_ptr()->no_such_method_cache_; | 1875 return raw_ptr()->no_such_method_cache_; |
(...skipping 12277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14145 } | 14153 } |
14146 | 14154 |
14147 | 14155 |
14148 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14156 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14149 stream->OpenObject(); | 14157 stream->OpenObject(); |
14150 stream->CloseObject(); | 14158 stream->CloseObject(); |
14151 } | 14159 } |
14152 | 14160 |
14153 | 14161 |
14154 } // namespace dart | 14162 } // namespace dart |
OLD | NEW |