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

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

Issue 10831142: Associate the correct type to method receivers (instead of Dynamic type). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { 341 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) {
342 EffectGraphVisitor for_effect(owner(), temp_index()); 342 EffectGraphVisitor for_effect(owner(), temp_index());
343 node->InlinedFinallyNodeAt(i)->Visit(&for_effect); 343 node->InlinedFinallyNodeAt(i)->Visit(&for_effect);
344 Append(for_effect); 344 Append(for_effect);
345 if (!is_open()) return; 345 if (!is_open()) return;
346 } 346 }
347 347
348 Value* return_value = for_value.value(); 348 Value* return_value = for_value.value();
349 if (FLAG_enable_type_checks) { 349 if (FLAG_enable_type_checks) {
350 const RawFunction::Kind kind = owner()->parsed_function().function().kind(); 350 const Function& function = owner()->parsed_function().function();
351 const bool is_implicit_getter = 351 const bool is_implicit_dynamic_getter =
352 (kind == RawFunction::kImplicitGetter) || 352 (!function.is_static() &&
353 (kind == RawFunction::kConstImplicitGetter); 353 ((function.kind() == RawFunction::kImplicitGetter) ||
354 const bool is_static = owner()->parsed_function().function().is_static(); 354 (function.kind() == RawFunction::kConstImplicitGetter)));
355 // Implicit getters do not need a type check at return, unless they compute 355 // Implicit getters do not need a type check at return, unless they compute
356 // the initial value of a static field. 356 // the initial value of a static field.
357 if (is_static || !is_implicit_getter) { 357 // The body of a constructor cannot modify the type of the
358 // constructed instance, which is passed in as an implicit parameter.
359 // However, factories may create an instance of the wrong type.
360 if (!is_implicit_dynamic_getter && !function.IsConstructor()) {
358 const AbstractType& dst_type = 361 const AbstractType& dst_type =
359 AbstractType::ZoneHandle( 362 AbstractType::ZoneHandle(
360 owner()->parsed_function().function().result_type()); 363 owner()->parsed_function().function().result_type());
361 const String& dst_name = 364 const String& dst_name =
362 String::ZoneHandle(Symbols::New("function result")); 365 String::ZoneHandle(Symbols::New("function result"));
363 return_value = BuildAssignableValue(node->value()->token_pos(), 366 return_value = BuildAssignableValue(node->value()->token_pos(),
364 return_value, 367 return_value,
365 dst_type, 368 dst_type,
366 dst_name); 369 dst_name);
367 } 370 }
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 char* chars = reinterpret_cast<char*>( 2688 char* chars = reinterpret_cast<char*>(
2686 Isolate::Current()->current_zone()->Allocate(len)); 2689 Isolate::Current()->current_zone()->Allocate(len));
2687 OS::SNPrint(chars, len, kFormat, function_name, reason); 2690 OS::SNPrint(chars, len, kFormat, function_name, reason);
2688 const Error& error = Error::Handle( 2691 const Error& error = Error::Handle(
2689 LanguageError::New(String::Handle(String::New(chars)))); 2692 LanguageError::New(String::Handle(String::New(chars))));
2690 Isolate::Current()->long_jump_base()->Jump(1, error); 2693 Isolate::Current()->long_jump_base()->Jump(1, error);
2691 } 2694 }
2692 2695
2693 2696
2694 } // namespace dart 2697 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698