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

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
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 4839 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 ClassFinalizer::FinalizeType( 4850 ClassFinalizer::FinalizeType(
4851 signature_class, signature_type, ClassFinalizer::kCanonicalize); 4851 signature_class, signature_type, ClassFinalizer::kCanonicalize);
4852 } 4852 }
4853 ASSERT(closure_function.signature_class() == signature_class.raw()); 4853 ASSERT(closure_function.signature_class() == signature_class.raw());
4854 set_implicit_closure_function(closure_function); 4854 set_implicit_closure_function(closure_function);
4855 ASSERT(closure_function.IsImplicitClosureFunction()); 4855 ASSERT(closure_function.IsImplicitClosureFunction());
4856 return closure_function.raw(); 4856 return closure_function.raw();
4857 } 4857 }
4858 4858
4859 4859
4860 RawString* Function::BuildSignature( 4860 RawString* Function::UserVisibleParameterSignature() const {
4861 const GrowableObjectArray& pieces =
4862 GrowableObjectArray::Handle(GrowableObjectArray::New());
4863 const TypeArguments& instantiator = TypeArguments::Handle();
4864 ParameterSignatureHelper(false, kUserVisibleName, instantiator, pieces);
4865 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4866 return String::ConcatAll(strings);
4867 }
4868
4869
4870 void Function::ParameterSignatureHelper(
4861 bool instantiate, 4871 bool instantiate,
4862 NameVisibility name_visibility, 4872 NameVisibility name_visibility,
4863 const AbstractTypeArguments& instantiator) const { 4873 const AbstractTypeArguments& instantiator,
4864 const GrowableObjectArray& pieces = 4874 const GrowableObjectArray& pieces) const {
4865 GrowableObjectArray::Handle(GrowableObjectArray::New());
4866 String& name = String::Handle();
4867 if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
4868 // Prefix the signature with its signature class and type parameters, if any
4869 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the
4870 // signature class name is the alias name.
4871 // The signature of static functions cannot be type parameterized.
4872 const Class& function_class = Class::Handle(Owner());
4873 ASSERT(!function_class.IsNull());
4874 const TypeArguments& type_parameters = TypeArguments::Handle(
4875 function_class.type_parameters());
4876 if (!type_parameters.IsNull()) {
4877 const String& function_class_name = String::Handle(function_class.Name());
4878 pieces.Add(function_class_name);
4879 const intptr_t num_type_parameters = type_parameters.Length();
4880 pieces.Add(Symbols::LAngleBracket());
4881 TypeParameter& type_parameter = TypeParameter::Handle();
4882 AbstractType& bound = AbstractType::Handle();
4883 for (intptr_t i = 0; i < num_type_parameters; i++) {
4884 type_parameter ^= type_parameters.TypeAt(i);
4885 name = type_parameter.name();
4886 pieces.Add(name);
4887 bound = type_parameter.bound();
4888 if (!bound.IsNull() && !bound.IsObjectType()) {
4889 pieces.Add(Symbols::SpaceExtendsSpace());
4890 name = bound.BuildName(name_visibility);
4891 pieces.Add(name);
4892 }
4893 if (i < num_type_parameters - 1) {
4894 pieces.Add(Symbols::CommaSpace());
4895 }
4896 }
4897 pieces.Add(Symbols::RAngleBracket());
4898 }
4899 }
4900 AbstractType& param_type = AbstractType::Handle(); 4875 AbstractType& param_type = AbstractType::Handle();
4901 const intptr_t num_params = NumParameters(); 4876 const intptr_t num_params = NumParameters();
4902 const intptr_t num_fixed_params = num_fixed_parameters(); 4877 const intptr_t num_fixed_params = num_fixed_parameters();
4903 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 4878 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4904 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 4879 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4905 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params; 4880 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
4906 ASSERT((num_fixed_params + num_opt_params) == num_params); 4881 ASSERT((num_fixed_params + num_opt_params) == num_params);
4907 pieces.Add(Symbols::LParen()); 4882 String& name = String::Handle();
4908 intptr_t i = 0; 4883 intptr_t i = 0;
4909 if (name_visibility == kUserVisibleName) { 4884 if (name_visibility == kUserVisibleName) {
4910 // Hide implicit parameters. 4885 // Hide implicit parameters.
4911 i = NumImplicitParameters(); 4886 i = NumImplicitParameters();
4912 } 4887 }
4913 while (i < num_fixed_params) { 4888 while (i < num_fixed_params) {
4914 param_type = ParameterTypeAt(i); 4889 param_type = ParameterTypeAt(i);
4915 ASSERT(!param_type.IsNull()); 4890 ASSERT(!param_type.IsNull());
4916 if (instantiate && !param_type.IsInstantiated()) { 4891 if (instantiate && !param_type.IsInstantiated()) {
4917 param_type = param_type.InstantiateFrom(instantiator, NULL); 4892 param_type = param_type.InstantiateFrom(instantiator, NULL);
(...skipping 29 matching lines...) Expand all
4947 if (i != (num_params - 1)) { 4922 if (i != (num_params - 1)) {
4948 pieces.Add(Symbols::CommaSpace()); 4923 pieces.Add(Symbols::CommaSpace());
4949 } 4924 }
4950 } 4925 }
4951 if (num_opt_pos_params > 0) { 4926 if (num_opt_pos_params > 0) {
4952 pieces.Add(Symbols::RBracket()); 4927 pieces.Add(Symbols::RBracket());
4953 } else { 4928 } else {
4954 pieces.Add(Symbols::RBrace()); 4929 pieces.Add(Symbols::RBrace());
4955 } 4930 }
4956 } 4931 }
4932 }
4933
4934
4935 RawString* Function::BuildSignature(
4936 bool instantiate,
4937 NameVisibility name_visibility,
4938 const AbstractTypeArguments& instantiator) const {
4939 const GrowableObjectArray& pieces =
4940 GrowableObjectArray::Handle(GrowableObjectArray::New());
4941 String& name = String::Handle();
4942 if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
4943 // Prefix the signature with its signature class and type parameters, if any
4944 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the
4945 // signature class name is the alias name.
4946 // The signature of static functions cannot be type parameterized.
4947 const Class& function_class = Class::Handle(Owner());
4948 ASSERT(!function_class.IsNull());
4949 const TypeArguments& type_parameters = TypeArguments::Handle(
4950 function_class.type_parameters());
4951 if (!type_parameters.IsNull()) {
4952 const String& function_class_name = String::Handle(function_class.Name());
4953 pieces.Add(function_class_name);
4954 const intptr_t num_type_parameters = type_parameters.Length();
4955 pieces.Add(Symbols::LAngleBracket());
4956 TypeParameter& type_parameter = TypeParameter::Handle();
4957 AbstractType& bound = AbstractType::Handle();
4958 for (intptr_t i = 0; i < num_type_parameters; i++) {
4959 type_parameter ^= type_parameters.TypeAt(i);
4960 name = type_parameter.name();
4961 pieces.Add(name);
4962 bound = type_parameter.bound();
4963 if (!bound.IsNull() && !bound.IsObjectType()) {
4964 pieces.Add(Symbols::SpaceExtendsSpace());
4965 name = bound.BuildName(name_visibility);
4966 pieces.Add(name);
4967 }
4968 if (i < num_type_parameters - 1) {
4969 pieces.Add(Symbols::CommaSpace());
4970 }
4971 }
4972 pieces.Add(Symbols::RAngleBracket());
4973 }
4974 }
4975 pieces.Add(Symbols::LParen());
4976 ParameterSignatureHelper(instantiate,
4977 name_visibility,
4978 instantiator,
4979 pieces);
4957 pieces.Add(Symbols::RParenArrow()); 4980 pieces.Add(Symbols::RParenArrow());
4958 AbstractType& res_type = AbstractType::Handle(result_type()); 4981 AbstractType& res_type = AbstractType::Handle(result_type());
4959 if (instantiate && !res_type.IsInstantiated()) { 4982 if (instantiate && !res_type.IsInstantiated()) {
4960 res_type = res_type.InstantiateFrom(instantiator, NULL); 4983 res_type = res_type.InstantiateFrom(instantiator, NULL);
4961 } 4984 }
4962 name = res_type.BuildName(name_visibility); 4985 name = res_type.BuildName(name_visibility);
4963 pieces.Add(name); 4986 pieces.Add(name);
4964 const Array& strings = Array::Handle(Array::MakeArray(pieces)); 4987 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4965 return Symbols::New(String::Handle(String::ConcatAll(strings))); 4988 return Symbols::New(String::Handle(String::ConcatAll(strings)));
4966 } 4989 }
(...skipping 10111 matching lines...) Expand 10 before | Expand all | Expand 10 after
15078 return "_MirrorReference"; 15101 return "_MirrorReference";
15079 } 15102 }
15080 15103
15081 15104
15082 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15105 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15083 JSONObject jsobj(stream); 15106 JSONObject jsobj(stream);
15084 } 15107 }
15085 15108
15086 15109
15087 } // namespace dart 15110 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698