Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: runtime/vm/object.cc

Issue 24395007: Improve NoSuchMethodError error messages (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
4846 ClassFinalizer::FinalizeType( 4846 ClassFinalizer::FinalizeType(
4847 signature_class, signature_type, ClassFinalizer::kCanonicalize); 4847 signature_class, signature_type, ClassFinalizer::kCanonicalize);
4848 } 4848 }
4849 ASSERT(closure_function.signature_class() == signature_class.raw()); 4849 ASSERT(closure_function.signature_class() == signature_class.raw());
4850 set_implicit_closure_function(closure_function); 4850 set_implicit_closure_function(closure_function);
4851 ASSERT(closure_function.IsImplicitClosureFunction()); 4851 ASSERT(closure_function.IsImplicitClosureFunction());
4852 return closure_function.raw(); 4852 return closure_function.raw();
4853 } 4853 }
4854 4854
4855 4855
4856 RawString* Function::BuildSignature( 4856 RawString* Function::UserVisibleFormalParameters() const {
4857 const GrowableObjectArray& pieces =
4858 GrowableObjectArray::Handle(GrowableObjectArray::New());
4859 const TypeArguments& instantiator = TypeArguments::Handle();
4860 BuildSinatureParameters(false, kUserVisibleName, instantiator, pieces);
4861 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4862 return String::ConcatAll(strings);
4863 }
4864
4865
4866 void Function::BuildSinatureParameters(
4857 bool instantiate, 4867 bool instantiate,
4858 NameVisibility name_visibility, 4868 NameVisibility name_visibility,
4859 const AbstractTypeArguments& instantiator) const { 4869 const AbstractTypeArguments& instantiator,
4860 const GrowableObjectArray& pieces = 4870 const GrowableObjectArray& pieces) const {
4861 GrowableObjectArray::Handle(GrowableObjectArray::New());
4862 String& name = String::Handle();
4863 if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
4864 // Prefix the signature with its signature class and type parameters, if any
4865 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the
4866 // signature class name is the alias name.
4867 // The signature of static functions cannot be type parameterized.
4868 const Class& function_class = Class::Handle(Owner());
4869 ASSERT(!function_class.IsNull());
4870 const TypeArguments& type_parameters = TypeArguments::Handle(
4871 function_class.type_parameters());
4872 if (!type_parameters.IsNull()) {
4873 const String& function_class_name = String::Handle(function_class.Name());
4874 pieces.Add(function_class_name);
4875 const intptr_t num_type_parameters = type_parameters.Length();
4876 pieces.Add(Symbols::LAngleBracket());
4877 TypeParameter& type_parameter = TypeParameter::Handle();
4878 AbstractType& bound = AbstractType::Handle();
4879 for (intptr_t i = 0; i < num_type_parameters; i++) {
4880 type_parameter ^= type_parameters.TypeAt(i);
4881 name = type_parameter.name();
4882 pieces.Add(name);
4883 bound = type_parameter.bound();
4884 if (!bound.IsNull() && !bound.IsObjectType()) {
4885 pieces.Add(Symbols::SpaceExtendsSpace());
4886 name = bound.BuildName(name_visibility);
4887 pieces.Add(name);
4888 }
4889 if (i < num_type_parameters - 1) {
4890 pieces.Add(Symbols::CommaSpace());
4891 }
4892 }
4893 pieces.Add(Symbols::RAngleBracket());
4894 }
4895 }
4896 AbstractType& param_type = AbstractType::Handle(); 4871 AbstractType& param_type = AbstractType::Handle();
4897 const intptr_t num_params = NumParameters(); 4872 const intptr_t num_params = NumParameters();
4898 const intptr_t num_fixed_params = num_fixed_parameters(); 4873 const intptr_t num_fixed_params = num_fixed_parameters();
4899 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 4874 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4900 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 4875 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4901 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params; 4876 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
4902 ASSERT((num_fixed_params + num_opt_params) == num_params); 4877 ASSERT((num_fixed_params + num_opt_params) == num_params);
4903 pieces.Add(Symbols::LParen()); 4878 String& name = String::Handle();
4904 intptr_t i = 0; 4879 intptr_t i = 0;
4905 if (name_visibility == kUserVisibleName) { 4880 if (name_visibility == kUserVisibleName) {
4906 // Hide implicit parameters. 4881 // Hide implicit parameters.
4907 i = NumImplicitParameters(); 4882 i = NumImplicitParameters();
4908 } 4883 }
4909 while (i < num_fixed_params) { 4884 while (i < num_fixed_params) {
4910 param_type = ParameterTypeAt(i); 4885 param_type = ParameterTypeAt(i);
4911 ASSERT(!param_type.IsNull()); 4886 ASSERT(!param_type.IsNull());
4912 if (instantiate && !param_type.IsInstantiated()) { 4887 if (instantiate && !param_type.IsInstantiated()) {
4913 param_type = param_type.InstantiateFrom(instantiator, NULL); 4888 param_type = param_type.InstantiateFrom(instantiator, NULL);
(...skipping 29 matching lines...) Expand all
4943 if (i != (num_params - 1)) { 4918 if (i != (num_params - 1)) {
4944 pieces.Add(Symbols::CommaSpace()); 4919 pieces.Add(Symbols::CommaSpace());
4945 } 4920 }
4946 } 4921 }
4947 if (num_opt_pos_params > 0) { 4922 if (num_opt_pos_params > 0) {
4948 pieces.Add(Symbols::RBracket()); 4923 pieces.Add(Symbols::RBracket());
4949 } else { 4924 } else {
4950 pieces.Add(Symbols::RBrace()); 4925 pieces.Add(Symbols::RBrace());
4951 } 4926 }
4952 } 4927 }
4928 }
4929
4930
4931 RawString* Function::BuildSignature(
4932 bool instantiate,
4933 NameVisibility name_visibility,
4934 const AbstractTypeArguments& instantiator) const {
4935 const GrowableObjectArray& pieces =
4936 GrowableObjectArray::Handle(GrowableObjectArray::New());
4937 String& name = String::Handle();
4938 if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
4939 // Prefix the signature with its signature class and type parameters, if any
4940 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the
4941 // signature class name is the alias name.
4942 // The signature of static functions cannot be type parameterized.
4943 const Class& function_class = Class::Handle(Owner());
4944 ASSERT(!function_class.IsNull());
4945 const TypeArguments& type_parameters = TypeArguments::Handle(
4946 function_class.type_parameters());
4947 if (!type_parameters.IsNull()) {
4948 const String& function_class_name = String::Handle(function_class.Name());
4949 pieces.Add(function_class_name);
4950 const intptr_t num_type_parameters = type_parameters.Length();
4951 pieces.Add(Symbols::LAngleBracket());
4952 TypeParameter& type_parameter = TypeParameter::Handle();
4953 AbstractType& bound = AbstractType::Handle();
4954 for (intptr_t i = 0; i < num_type_parameters; i++) {
4955 type_parameter ^= type_parameters.TypeAt(i);
4956 name = type_parameter.name();
4957 pieces.Add(name);
4958 bound = type_parameter.bound();
4959 if (!bound.IsNull() && !bound.IsObjectType()) {
4960 pieces.Add(Symbols::SpaceExtendsSpace());
4961 name = bound.BuildName(name_visibility);
4962 pieces.Add(name);
4963 }
4964 if (i < num_type_parameters - 1) {
4965 pieces.Add(Symbols::CommaSpace());
4966 }
4967 }
4968 pieces.Add(Symbols::RAngleBracket());
4969 }
4970 }
4971 pieces.Add(Symbols::LParen());
4972 BuildSinatureParameters(instantiate,
4973 name_visibility,
4974 instantiator,
4975 pieces);
4953 pieces.Add(Symbols::RParenArrow()); 4976 pieces.Add(Symbols::RParenArrow());
4954 AbstractType& res_type = AbstractType::Handle(result_type()); 4977 AbstractType& res_type = AbstractType::Handle(result_type());
4955 if (instantiate && !res_type.IsInstantiated()) { 4978 if (instantiate && !res_type.IsInstantiated()) {
4956 res_type = res_type.InstantiateFrom(instantiator, NULL); 4979 res_type = res_type.InstantiateFrom(instantiator, NULL);
4957 } 4980 }
4958 name = res_type.BuildName(name_visibility); 4981 name = res_type.BuildName(name_visibility);
4959 pieces.Add(name); 4982 pieces.Add(name);
4960 const Array& strings = Array::Handle(Array::MakeArray(pieces)); 4983 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4961 return Symbols::New(String::Handle(String::ConcatAll(strings))); 4984 return Symbols::New(String::Handle(String::ConcatAll(strings)));
4962 } 4985 }
(...skipping 10153 matching lines...) Expand 10 before | Expand all | Expand 10 after
15116 return "_MirrorReference"; 15139 return "_MirrorReference";
15117 } 15140 }
15118 15141
15119 15142
15120 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15143 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15121 JSONObject jsobj(stream); 15144 JSONObject jsobj(stream);
15122 } 15145 }
15123 15146
15124 15147
15125 } // namespace dart 15148 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698