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

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
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 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 // hand side yet at this stage). If the parser establishes later that the 2361 // hand side yet at this stage). If the parser establishes later that the
2361 // field access is part of a left hand side expression, the 2362 // field access is part of a left hand side expression, the
2362 // StaticGetterNode is transformed into a StaticSetterNode referring to 2363 // StaticGetterNode is transformed into a StaticSetterNode referring to
2363 // the existing static setter. 2364 // the existing static setter.
2364 // However, if the field reference appears in a right hand side 2365 // However, if the field reference appears in a right hand side
2365 // expression, no such transformation occurs and we land here with a 2366 // expression, no such transformation occurs and we land here with a
2366 // StaticGetterNode missing a getter function, so we throw a 2367 // StaticGetterNode missing a getter function, so we throw a
2367 // NoSuchMethodError. 2368 // NoSuchMethodError.
2368 2369
2369 // Throw a NoSuchMethodError. 2370 // Throw a NoSuchMethodError.
2370 StaticCallInstr* call = BuildThrowNoSuchMethodError(node->token_pos(), 2371 StaticCallInstr* call = BuildThrowNoSuchMethodError(
2371 node->cls(), 2372 node->token_pos(),
2372 getter_name); 2373 node->cls(),
2374 getter_name,
2375 InvocationMirror::EncodeType(
2376 node->cls().IsTopLevel() ?
2377 InvocationMirror::kTopLevel :
2378 InvocationMirror::kStatic,
2379 InvocationMirror::kGetter));
2373 ReturnDefinition(call); 2380 ReturnDefinition(call);
2374 return; 2381 return;
2375 } 2382 }
2376 } 2383 }
2377 ASSERT(!getter_function.IsNull()); 2384 ASSERT(!getter_function.IsNull());
2378 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), 2385 StaticCallInstr* call = new StaticCallInstr(node->token_pos(),
2379 getter_function, 2386 getter_function,
2380 Array::ZoneHandle(), // No names. 2387 Array::ZoneHandle(), // No names.
2381 arguments); 2388 arguments);
2382 ReturnDefinition(call); 2389 ReturnDefinition(call);
(...skipping 21 matching lines...) Expand all
2404 // Resolve and call noSuchMethod. 2411 // Resolve and call noSuchMethod.
2405 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos()); 2412 ArgumentListNode* arguments = new ArgumentListNode(node->token_pos());
2406 arguments->Add(node->receiver()); 2413 arguments->Add(node->receiver());
2407 arguments->Add(node->value()); 2414 arguments->Add(node->value());
2408 call = BuildStaticNoSuchMethodCall(node->cls(), 2415 call = BuildStaticNoSuchMethodCall(node->cls(),
2409 node->receiver(), 2416 node->receiver(),
2410 setter_name, 2417 setter_name,
2411 arguments); 2418 arguments);
2412 } else { 2419 } else {
2413 // Throw a NoSuchMethodError. 2420 // Throw a NoSuchMethodError.
2414 call = BuildThrowNoSuchMethodError(node->token_pos(), 2421 call = BuildThrowNoSuchMethodError(
2415 node->cls(), 2422 node->token_pos(),
2416 setter_name); 2423 node->cls(),
2424 setter_name,
2425 InvocationMirror::EncodeType(
2426 node->cls().IsTopLevel() ?
2427 InvocationMirror::kTopLevel :
2428 InvocationMirror::kStatic,
2429 InvocationMirror::kGetter));
2417 } 2430 }
2418 } else { 2431 } else {
2419 if (is_super_setter) { 2432 if (is_super_setter) {
2420 // Add receiver of instance getter. 2433 // Add receiver of instance getter.
2421 ValueGraphVisitor for_receiver(owner(), temp_index()); 2434 ValueGraphVisitor for_receiver(owner(), temp_index());
2422 node->receiver()->Visit(&for_receiver); 2435 node->receiver()->Visit(&for_receiver);
2423 Append(for_receiver); 2436 Append(for_receiver);
2424 arguments->Add(PushArgument(for_receiver.value())); 2437 arguments->Add(PushArgument(for_receiver.value()));
2425 } 2438 }
2426 ValueGraphVisitor for_value(owner(), temp_index()); 2439 ValueGraphVisitor for_value(owner(), temp_index());
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 return new StaticCallInstr(args_pos, 3096 return new StaticCallInstr(args_pos,
3084 no_such_method_func, 3097 no_such_method_func,
3085 Array::ZoneHandle(), 3098 Array::ZoneHandle(),
3086 args); 3099 args);
3087 } 3100 }
3088 3101
3089 3102
3090 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError( 3103 StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
3091 intptr_t token_pos, 3104 intptr_t token_pos,
3092 const Class& function_class, 3105 const Class& function_class,
3093 const String& function_name) { 3106 const String& function_name,
3107 int invocation_type) {
3094 ZoneGrowableArray<PushArgumentInstr*>* arguments = 3108 ZoneGrowableArray<PushArgumentInstr*>* arguments =
3095 new ZoneGrowableArray<PushArgumentInstr*>(); 3109 new ZoneGrowableArray<PushArgumentInstr*>();
3096 // Object receiver. 3110 // Object receiver.
3097 // TODO(regis): For now, we pass a class literal of the unresolved 3111 // TODO(regis): For now, we pass a class literal of the unresolved
3098 // method's owner, but this is not specified and will probably change. 3112 // method's owner, but this is not specified and will probably change.
3099 Type& type = Type::ZoneHandle( 3113 Type& type = Type::ZoneHandle(
3100 Type::New(function_class, 3114 Type::New(function_class,
3101 TypeArguments::Handle(), 3115 TypeArguments::Handle(),
3102 token_pos, 3116 token_pos,
3103 Heap::kOld)); 3117 Heap::kOld));
3104 type ^= ClassFinalizer::FinalizeType( 3118 type ^= ClassFinalizer::FinalizeType(
3105 function_class, type, ClassFinalizer::kCanonicalize); 3119 function_class, type, ClassFinalizer::kCanonicalize);
3106 Value* receiver_value = Bind(new ConstantInstr(type)); 3120 Value* receiver_value = Bind(new ConstantInstr(type));
3107 arguments->Add(PushArgument(receiver_value)); 3121 arguments->Add(PushArgument(receiver_value));
3108 // String memberName. 3122 // String memberName.
3109 const String& member_name = String::ZoneHandle(Symbols::New(function_name)); 3123 const String& member_name = String::ZoneHandle(Symbols::New(function_name));
3110 Value* member_name_value = Bind(new ConstantInstr(member_name)); 3124 Value* member_name_value = Bind(new ConstantInstr(member_name));
3111 arguments->Add(PushArgument(member_name_value)); 3125 arguments->Add(PushArgument(member_name_value));
3126 // Smi invocation_type.
3127 Value* invocation_type_value = Bind(new ConstantInstr(
3128 Smi::ZoneHandle(Smi::New(invocation_type))));
3129 arguments->Add(PushArgument(invocation_type_value));
3112 // List arguments. 3130 // List arguments.
3113 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle())); 3131 Value* arguments_value = Bind(new ConstantInstr(Array::ZoneHandle()));
3114 arguments->Add(PushArgument(arguments_value)); 3132 arguments->Add(PushArgument(arguments_value));
3115 // List argumentNames. 3133 // List argumentNames.
3116 Value* argument_names_value = 3134 Value* argument_names_value =
3117 Bind(new ConstantInstr(Array::ZoneHandle())); 3135 Bind(new ConstantInstr(Array::ZoneHandle()));
3118 arguments->Add(PushArgument(argument_names_value)); 3136 arguments->Add(PushArgument(argument_names_value));
3119 // List existingArgumentNames. 3137 // List existingArgumentNames.
3120 Value* existing_argument_names_value = 3138 Value* existing_argument_names_value =
3121 Bind(new ConstantInstr(Array::ZoneHandle())); 3139 Bind(new ConstantInstr(Array::ZoneHandle()));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3260 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3243 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3261 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3244 OS::SNPrint(chars, len, kFormat, function_name, reason); 3262 OS::SNPrint(chars, len, kFormat, function_name, reason);
3245 const Error& error = Error::Handle( 3263 const Error& error = Error::Handle(
3246 LanguageError::New(String::Handle(String::New(chars)))); 3264 LanguageError::New(String::Handle(String::New(chars))));
3247 Isolate::Current()->long_jump_base()->Jump(1, error); 3265 Isolate::Current()->long_jump_base()->Jump(1, error);
3248 } 3266 }
3249 3267
3250 3268
3251 } // namespace dart 3269 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698