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

Side by Side Diff: runtime/vm/compiler.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/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 LongJump* base = isolate->long_jump_base(); 439 LongJump* base = isolate->long_jump_base();
440 LongJump jump; 440 LongJump jump;
441 isolate->set_long_jump_base(&jump); 441 isolate->set_long_jump_base(&jump);
442 if (setjmp(*jump.Set()) == 0) { 442 if (setjmp(*jump.Set()) == 0) {
443 if (FLAG_trace_compiler) { 443 if (FLAG_trace_compiler) {
444 OS::Print("compiling expression: "); 444 OS::Print("compiling expression: ");
445 AstPrinter::PrintNode(fragment); 445 AstPrinter::PrintNode(fragment);
446 } 446 }
447 447
448 // Create a dummy function object for the code generator. 448 // Create a dummy function object for the code generator.
449 // The function needs to be associated with a named Class: the interface
450 // Function fits the bill.
449 const char* kEvalConst = "eval_const"; 451 const char* kEvalConst = "eval_const";
450 const Function& func = Function::Handle(Function::New( 452 const Function& func = Function::Handle(Function::New(
451 String::Handle(Symbols::New(kEvalConst)), 453 String::Handle(Symbols::New(kEvalConst)),
452 RawFunction::kConstImplicitGetter, 454 RawFunction::kConstImplicitGetter,
453 true, // static function. 455 true, // static function.
454 false, // not const function. 456 false, // not const function.
455 false, // not abstract 457 false, // not abstract
456 false, // not external. 458 false, // not external.
459 Class::Handle(Type::Handle(Type::FunctionInterface()).type_class()),
457 fragment->token_pos())); 460 fragment->token_pos()));
458 461
459 func.set_result_type(Type::Handle(Type::DynamicType())); 462 func.set_result_type(Type::Handle(Type::DynamicType()));
460 func.set_num_fixed_parameters(0); 463 func.set_num_fixed_parameters(0);
461 func.set_num_optional_parameters(0); 464 func.set_num_optional_parameters(0);
462 465
463 // The function needs to be associated with a named Class: the interface
464 // Function fits the bill.
465 func.set_owner(Class::Handle(
466 Type::Handle(Type::FunctionInterface()).type_class()));
467
468 // We compile the function here, even though InvokeStatic() below 466 // We compile the function here, even though InvokeStatic() below
469 // would compile func automatically. We are checking fewer invariants 467 // would compile func automatically. We are checking fewer invariants
470 // here. 468 // here.
471 ParsedFunction parsed_function(func); 469 ParsedFunction parsed_function(func);
472 parsed_function.SetNodeSequence(fragment); 470 parsed_function.SetNodeSequence(fragment);
473 parsed_function.set_default_parameter_values(Array::Handle()); 471 parsed_function.set_default_parameter_values(Array::Handle());
474 parsed_function.set_expression_temp_var( 472 parsed_function.set_expression_temp_var(
475 ParsedFunction::CreateExpressionTempVar(0)); 473 ParsedFunction::CreateExpressionTempVar(0));
476 fragment->scope()->AddVariable(parsed_function.expression_temp_var()); 474 fragment->scope()->AddVariable(parsed_function.expression_temp_var());
477 parsed_function.AllocateVariables(); 475 parsed_function.AllocateVariables();
(...skipping 15 matching lines...) Expand all
493 isolate->object_store()->clear_sticky_error(); 491 isolate->object_store()->clear_sticky_error();
494 isolate->set_long_jump_base(base); 492 isolate->set_long_jump_base(base);
495 return result.raw(); 493 return result.raw();
496 } 494 }
497 UNREACHABLE(); 495 UNREACHABLE();
498 return Object::null(); 496 return Object::null();
499 } 497 }
500 498
501 499
502 } // namespace dart 500 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698