| OLD | NEW |
| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 case Token::kNOT: | 369 case Token::kNOT: |
| 370 return val->IsBool() ? val : NULL; | 370 return val->IsBool() ? val : NULL; |
| 371 case Token::kBIT_NOT: | 371 case Token::kBIT_NOT: |
| 372 return val->IsInteger() ? val : NULL; | 372 return val->IsInteger() ? val : NULL; |
| 373 default: | 373 default: |
| 374 return NULL; | 374 return NULL; |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 | 378 |
| 379 bool ConditionalExprNode::IsPotentiallyConst() const { |
| 380 return this->condition()->IsPotentiallyConst() && |
| 381 this->true_expr()->IsPotentiallyConst() && |
| 382 this->false_expr()->IsPotentiallyConst(); |
| 383 } |
| 384 |
| 385 |
| 386 const Instance* ConditionalExprNode::EvalConstExpr() const { |
| 387 const Instance* cond = this->condition()->EvalConstExpr(); |
| 388 if ((cond != NULL) && |
| 389 (this->true_expr()->EvalConstExpr() != NULL) && |
| 390 (this->false_expr()->EvalConstExpr() != NULL)) { |
| 391 return cond; |
| 392 } |
| 393 return NULL; |
| 394 } |
| 395 |
| 396 |
| 379 bool ClosureNode::IsPotentiallyConst() const { | 397 bool ClosureNode::IsPotentiallyConst() const { |
| 380 if (function().IsImplicitStaticClosureFunction()) { | 398 if (function().IsImplicitStaticClosureFunction()) { |
| 381 return true; | 399 return true; |
| 382 } | 400 } |
| 383 return false; | 401 return false; |
| 384 } | 402 } |
| 385 | 403 |
| 386 | 404 |
| 387 const Instance* ClosureNode::EvalConstExpr() const { | 405 const Instance* ClosureNode::EvalConstExpr() const { |
| 388 if (function().IsImplicitStaticClosureFunction()) { | 406 if (function().IsImplicitStaticClosureFunction()) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 if (result.IsError() || result.IsNull()) { | 571 if (result.IsError() || result.IsNull()) { |
| 554 // TODO(turnidge): We could get better error messages by returning | 572 // TODO(turnidge): We could get better error messages by returning |
| 555 // the Error object directly to the parser. This will involve | 573 // the Error object directly to the parser. This will involve |
| 556 // replumbing all of the EvalConstExpr methods. | 574 // replumbing all of the EvalConstExpr methods. |
| 557 return NULL; | 575 return NULL; |
| 558 } | 576 } |
| 559 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 577 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
| 560 } | 578 } |
| 561 | 579 |
| 562 } // namespace dart | 580 } // namespace dart |
| OLD | NEW |