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

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

Issue 12328019: - Improve the message for NoSuchMethodErrors that are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/flow_graph_builder.h ('k') | runtime/vm/object.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/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h"
7 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 11 #include "vm/flags.h"
11 #include "vm/il_printer.h" 12 #include "vm/il_printer.h"
12 #include "vm/intermediate_language.h" 13 #include "vm/intermediate_language.h"
13 #include "vm/longjump.h" 14 #include "vm/longjump.h"
14 #include "vm/object_store.h" 15 #include "vm/object_store.h"
15 #include "vm/os.h" 16 #include "vm/os.h"
16 #include "vm/parser.h" 17 #include "vm/parser.h"
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 // hand side yet at this stage). If the parser establishes later that the 2368 // hand side yet at this stage). If the parser establishes later that the
2368 // field access is part of a left hand side expression, the 2369 // field access is part of a left hand side expression, the
2369 // StaticGetterNode is transformed into a StaticSetterNode referring to 2370 // StaticGetterNode is transformed into a StaticSetterNode referring to
2370 // the existing static setter. 2371 // the existing static setter.
2371 // However, if the field reference appears in a right hand side 2372 // However, if the field reference appears in a right hand side
2372 // expression, no such transformation occurs and we land here with a 2373 // expression, no such transformation occurs and we land here with a
2373 // StaticGetterNode missing a getter function, so we throw a 2374 // StaticGetterNode missing a getter function, so we throw a
2374 // NoSuchMethodError. 2375 // NoSuchMethodError.
2375 2376
2376 // Throw a NoSuchMethodError. 2377 // Throw a NoSuchMethodError.
2377 StaticCallInstr* call = BuildThrowNoSuchMethodError(node->token_pos(), 2378 StaticCallInstr* call = BuildThrowNoSuchMethodError(
2378 node->cls(), 2379 node->token_pos(),
2379 getter_name); 2380 node->cls(),
2381 getter_name,
2382 InvocationMirror::EncodeType(
2383 node->cls().IsTopLevel() ?
2384 InvocationMirror::kTopLevel :
2385 InvocationMirror::kStatic,
2386 InvocationMirror::kGetter));
2380 ReturnDefinition(call); 2387 ReturnDefinition(call);
2381 return; 2388 return;
2382 } 2389 }
2383 } 2390 }
2384 ASSERT(!getter_function.IsNull()); 2391 ASSERT(!getter_function.IsNull());
2385 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), 2392 StaticCallInstr* call = new StaticCallInstr(node->token_pos(),
2386 getter_function, 2393 getter_function,
2387 Array::ZoneHandle(), // No names. 2394 Array::ZoneHandle(), // No names.
2388 arguments); 2395 arguments);
2389 ReturnDefinition(call); 2396 ReturnDefinition(call);
(...skipping 21 matching lines...) Expand all
2411 // Resolve and call noSuchMethod. 2418 // Resolve and call noSuchMethod.
2412 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); 2419 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos());
2413 arguments->Add(node->receiver()); 2420 arguments->Add(node->receiver());
2414 arguments->Add(node->value()); 2421 arguments->Add(node->value());
2415 call = BuildStaticNoSuchMethodCall(node->cls(), 2422 call = BuildStaticNoSuchMethodCall(node->cls(),
2416 node->receiver(), 2423 node->receiver(),
2417 setter_name, 2424 setter_name,
2418 arguments); 2425 arguments);
2419 } else { 2426 } else {
2420 // Throw a NoSuchMethodError. 2427 // Throw a NoSuchMethodError.
2421 call = BuildThrowNoSuchMethodError(node->token_pos(), 2428 call = BuildThrowNoSuchMethodError(
2422 node->cls(), 2429 node->token_pos(),
2423 setter_name); 2430 node->cls(),
2431 setter_name,
2432 InvocationMirror::EncodeType(
2433 node->cls().IsTopLevel() ?
2434 InvocationMirror::kTopLevel :
2435 InvocationMirror::kStatic,
2436 InvocationMirror::kGetter));
2424 } 2437 }
2425 } else { 2438 } else {
2426 if (is_super_setter) { 2439 if (is_super_setter) {
2427 // Add receiver of instance getter. 2440 // Add receiver of instance getter.
2428 ValueGraphVisitor for_receiver(owner(), temp_index()); 2441 ValueGraphVisitor for_receiver(owner(), temp_index());
2429 node->receiver()->Visit(&for_receiver); 2442 node->receiver()->Visit(&for_receiver);
2430 Append(for_receiver); 2443 Append(for_receiver);
2431 arguments->Add(PushArgument(for_receiver.value())); 2444 arguments->Add(PushArgument(for_receiver.value()));
2432 } 2445 }
2433 ValueGraphVisitor for_value(owner(), temp_index()); 2446 ValueGraphVisitor for_value(owner(), temp_index());
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 return new StaticCallInstr(args_pos, 3103 return new StaticCallInstr(args_pos,
3091 no_such_method_func, 3104 no_such_method_func,
3092 Array::ZoneHandle(), 3105 Array::ZoneHandle(),
3093 args); 3106 args);
3094 } 3107 }
3095 3108
3096 3109
3097 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( 3110 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
3098 intptr_t token_pos, 3111 intptr_t token_pos,
3099 const Class& function_class, 3112 const Class& function_class,
3100 const String& function_name) { 3113 const String& function_name,
3114 int invocation_type) {
3101 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3115 ZoneGrowableArray<PushArgumentInstr*>* arguments =
3102 new ZoneGrowableArray<PushArgumentInstr*>(); 3116 new ZoneGrowableArray<PushArgumentInstr*>();
3103 // Object receiver. 3117 // Object receiver.
3104 // TODO(regis): For now, we pass a class literal of the unresolved 3118 // TODO(regis): For now, we pass a class literal of the unresolved
3105 // method's owner, but this is not specified and will probably change. 3119 // method's owner, but this is not specified and will probably change.
3106 Type& type = Type::ZoneHandle( 3120 Type& type = Type::ZoneHandle(
3107 Type::New(function_class, 3121 Type::New(function_class,
3108 TypeArguments::Handle(), 3122 TypeArguments::Handle(),
3109 token_pos, 3123 token_pos,
3110 Heap::kOld)); 3124 Heap::kOld));
3111 type ^= ClassFinalizer::FinalizeType( 3125 type ^= ClassFinalizer::FinalizeType(
3112 function_class, type, ClassFinalizer::kCanonicalize); 3126 function_class, type, ClassFinalizer::kCanonicalize);
3113 Value* receiver_value = Bind(new ConstantInstr(type)); 3127 Value* receiver_value = Bind(new ConstantInstr(type));
3114 arguments->Add(PushArgument(receiver_value)); 3128 arguments->Add(PushArgument(receiver_value));
3115 // String memberName. 3129 // String memberName.
3116 const String& member_name = String::ZoneHandle(Symbols::New(function_name)); 3130 const String& member_name = String::ZoneHandle(Symbols::New(function_name));
3117 Value* member_name_value = Bind(new ConstantInstr(member_name)); 3131 Value* member_name_value = Bind(new ConstantInstr(member_name));
3118 arguments->Add(PushArgument(member_name_value)); 3132 arguments->Add(PushArgument(member_name_value));
3133 // Smi invocation_type.
3134 Value* invocation_type_value = Bind(new ConstantInstr(
3135 Smi::ZoneHandle(Smi::New(invocation_type))));
3136 arguments->Add(PushArgument(invocation_type_value));
3119 // List arguments. 3137 // List arguments.
3120 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle())); 3138 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle()));
3121 arguments->Add(PushArgument(arguments_value)); 3139 arguments->Add(PushArgument(arguments_value));
3122 // List argumentNames. 3140 // List argumentNames.
3123 Value* argument_names_value = 3141 Value* argument_names_value =
3124 Bind(new ConstantInstr(Array::ZoneHandle())); 3142 Bind(new ConstantInstr(Array::ZoneHandle()));
3125 arguments->Add(PushArgument(argument_names_value)); 3143 arguments->Add(PushArgument(argument_names_value));
3126 // List existingArgumentNames. 3144 // List existingArgumentNames.
3127 Value* existing_argument_names_value = 3145 Value* existing_argument_names_value =
3128 Bind(new ConstantInstr(Array::ZoneHandle())); 3146 Bind(new ConstantInstr(Array::ZoneHandle()));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3267 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3250 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3268 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3251 OS::SNPrint(chars, len, kFormat, function_name, reason); 3269 OS::SNPrint(chars, len, kFormat, function_name, reason);
3252 const Error& error = Error::Handle( 3270 const Error& error = Error::Handle(
3253 LanguageError::New(String::Handle(String::New(chars)))); 3271 LanguageError::New(String::Handle(String::New(chars))));
3254 Isolate::Current()->long_jump_base()->Jump(1, error); 3272 Isolate::Current()->long_jump_base()->Jump(1, error);
3255 } 3273 }
3256 3274
3257 3275
3258 } // namespace dart 3276 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698