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

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

Issue 226953002: Implement deferred constant support (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/ast.h" 5 #include "vm/ast.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 bool ClosureNode::IsPotentiallyConst() const { 412 bool ClosureNode::IsPotentiallyConst() const {
413 if (function().IsImplicitStaticClosureFunction()) { 413 if (function().IsImplicitStaticClosureFunction()) {
414 return true; 414 return true;
415 } 415 }
416 return false; 416 return false;
417 } 417 }
418 418
419 419
420 const Instance* ClosureNode::EvalConstExpr() const { 420 const Instance* ClosureNode::EvalConstExpr() const {
421 if (function().IsImplicitStaticClosureFunction()) { 421 if (!is_deferred_reference_ &&
422 function().IsImplicitStaticClosureFunction()) {
422 // Return a value that represents an instance. Only the type is relevant. 423 // Return a value that represents an instance. Only the type is relevant.
423 return &Instance::Handle(); 424 return &Instance::Handle();
424 } 425 }
425 return NULL; 426 return NULL;
426 } 427 }
427 428
428 429
429 AstNode* ClosureNode::MakeAssignmentNode(AstNode* rhs) { 430 AstNode* ClosureNode::MakeAssignmentNode(AstNode* rhs) {
430 if (scope() == NULL) { 431 if (scope() == NULL) {
431 // This is an implicit closure node created because a static getter was not 432 // This is an implicit closure node created because a static getter was not
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 const String& func_name = String::Handle(function().name()); 556 const String& func_name = String::Handle(function().name());
556 if (cls_name.Equals(Symbols::NoSuchMethodError()) && 557 if (cls_name.Equals(Symbols::NoSuchMethodError()) &&
557 func_name.StartsWith(Symbols::ThrowNew())) { 558 func_name.StartsWith(Symbols::ThrowNew())) {
558 return this; 559 return this;
559 } 560 }
560 return NULL; 561 return NULL;
561 } 562 }
562 563
563 564
564 bool StaticGetterNode::IsPotentiallyConst() const { 565 bool StaticGetterNode::IsPotentiallyConst() const {
566 if (is_deferred_reference_) {
567 return false;
568 }
565 const String& getter_name = 569 const String& getter_name =
566 String::Handle(Field::GetterName(this->field_name())); 570 String::Handle(Field::GetterName(this->field_name()));
567 const Function& getter_func = 571 const Function& getter_func =
568 Function::Handle(this->cls().LookupStaticFunction(getter_name)); 572 Function::Handle(this->cls().LookupStaticFunction(getter_name));
569 if (getter_func.IsNull() || !getter_func.is_const()) { 573 if (getter_func.IsNull() || !getter_func.is_const()) {
570 return false; 574 return false;
571 } 575 }
572 return true; 576 return true;
573 } 577 }
574 578
575 579
576 const Instance* StaticGetterNode::EvalConstExpr() const { 580 const Instance* StaticGetterNode::EvalConstExpr() const {
581 if (is_deferred_reference_) {
582 return NULL;
583 }
577 const String& getter_name = 584 const String& getter_name =
578 String::Handle(Field::GetterName(this->field_name())); 585 String::Handle(Field::GetterName(this->field_name()));
579 const Function& getter_func = 586 const Function& getter_func =
580 Function::Handle(this->cls().LookupStaticFunction(getter_name)); 587 Function::Handle(this->cls().LookupStaticFunction(getter_name));
581 if (getter_func.IsNull() || !getter_func.is_const()) { 588 if (getter_func.IsNull() || !getter_func.is_const()) {
582 return NULL; 589 return NULL;
583 } 590 }
584 const Object& result = Object::Handle( 591 const Object& result = Object::Handle(
585 DartEntry::InvokeFunction(getter_func, Object::empty_array())); 592 DartEntry::InvokeFunction(getter_func, Object::empty_array()));
586 if (result.IsError() || result.IsNull()) { 593 if (result.IsError() || result.IsNull()) {
587 // TODO(turnidge): We could get better error messages by returning 594 // TODO(turnidge): We could get better error messages by returning
588 // the Error object directly to the parser. This will involve 595 // the Error object directly to the parser. This will involve
589 // replumbing all of the EvalConstExpr methods. 596 // replumbing all of the EvalConstExpr methods.
590 return NULL; 597 return NULL;
591 } 598 }
592 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 599 return &Instance::ZoneHandle(Instance::Cast(result).raw());
593 } 600 }
594 601
595 } // namespace dart 602 } // namespace dart
OLDNEW
« runtime/vm/ast.h ('K') | « runtime/vm/ast.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698