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

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

Issue 25456005: Add type check to const conditional expression evaluation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « no previous file | runtime/vm/parser.cc » ('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) 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 bool ConditionalExprNode::IsPotentiallyConst() const { 379 bool ConditionalExprNode::IsPotentiallyConst() const {
380 return this->condition()->IsPotentiallyConst() && 380 return this->condition()->IsPotentiallyConst() &&
381 this->true_expr()->IsPotentiallyConst() && 381 this->true_expr()->IsPotentiallyConst() &&
382 this->false_expr()->IsPotentiallyConst(); 382 this->false_expr()->IsPotentiallyConst();
383 } 383 }
384 384
385 385
386 const Instance* ConditionalExprNode::EvalConstExpr() const { 386 const Instance* ConditionalExprNode::EvalConstExpr() const {
387 const Instance* cond = this->condition()->EvalConstExpr(); 387 const Instance* cond = this->condition()->EvalConstExpr();
388 if ((cond != NULL) && 388 if ((cond != NULL) &&
389 cond->IsBool() &&
389 (this->true_expr()->EvalConstExpr() != NULL) && 390 (this->true_expr()->EvalConstExpr() != NULL) &&
390 (this->false_expr()->EvalConstExpr() != NULL)) { 391 (this->false_expr()->EvalConstExpr() != NULL)) {
391 return cond; 392 return cond;
392 } 393 }
393 return NULL; 394 return NULL;
394 } 395 }
395 396
396 397
397 bool ClosureNode::IsPotentiallyConst() const { 398 bool ClosureNode::IsPotentiallyConst() const {
398 if (function().IsImplicitStaticClosureFunction()) { 399 if (function().IsImplicitStaticClosureFunction()) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (result.IsError() || result.IsNull()) { 572 if (result.IsError() || result.IsNull()) {
572 // TODO(turnidge): We could get better error messages by returning 573 // TODO(turnidge): We could get better error messages by returning
573 // the Error object directly to the parser. This will involve 574 // the Error object directly to the parser. This will involve
574 // replumbing all of the EvalConstExpr methods. 575 // replumbing all of the EvalConstExpr methods.
575 return NULL; 576 return NULL;
576 } 577 }
577 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 578 return &Instance::ZoneHandle(Instance::Cast(result).raw());
578 } 579 }
579 580
580 } // namespace dart 581 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698