| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 | 250 |
| 251 const char* BinaryOpWithMask32Node::TokenName() const { | 251 const char* BinaryOpWithMask32Node::TokenName() const { |
| 252 return Token::Str(kind()); | 252 return Token::Str(kind()); |
| 253 } | 253 } |
| 254 | 254 |
| 255 | 255 |
| 256 bool BinaryOpNode::IsPotentiallyConst() const { | 256 bool BinaryOpNode::IsPotentiallyConst() const { |
| 257 switch (kind_) { | 257 switch (kind_) { |
| 258 case Token::kOR: |
| 259 case Token::kAND: |
| 260 if (this->left()->IsLiteralNode() && |
| 261 this->left()->AsLiteralNode()->literal().IsNull()) { |
| 262 return false; |
| 263 } |
| 264 if (this->right()->IsLiteralNode() && |
| 265 this->right()->AsLiteralNode()->literal().IsNull()) { |
| 266 return false; |
| 267 } |
| 268 // Fall-through intentional. |
| 258 case Token::kADD: | 269 case Token::kADD: |
| 259 case Token::kSUB: | 270 case Token::kSUB: |
| 260 case Token::kMUL: | 271 case Token::kMUL: |
| 261 case Token::kDIV: | 272 case Token::kDIV: |
| 262 case Token::kMOD: | 273 case Token::kMOD: |
| 263 case Token::kTRUNCDIV: | 274 case Token::kTRUNCDIV: |
| 264 case Token::kBIT_OR: | 275 case Token::kBIT_OR: |
| 265 case Token::kBIT_XOR: | 276 case Token::kBIT_XOR: |
| 266 case Token::kBIT_AND: | 277 case Token::kBIT_AND: |
| 267 case Token::kSHL: | 278 case Token::kSHL: |
| 268 case Token::kSHR: | 279 case Token::kSHR: |
| 269 case Token::kOR: | |
| 270 case Token::kAND: | |
| 271 return this->left()->IsPotentiallyConst() && | 280 return this->left()->IsPotentiallyConst() && |
| 272 this->right()->IsPotentiallyConst(); | 281 this->right()->IsPotentiallyConst(); |
| 273 default: | 282 default: |
| 274 UNREACHABLE(); | 283 UNREACHABLE(); |
| 275 return false; | 284 return false; |
| 276 } | 285 } |
| 277 } | 286 } |
| 278 | 287 |
| 279 | 288 |
| 280 const Instance* BinaryOpNode::EvalConstExpr() const { | 289 const Instance* BinaryOpNode::EvalConstExpr() const { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 case Token::kNOT: | 357 case Token::kNOT: |
| 349 case Token::kBIT_NOT: | 358 case Token::kBIT_NOT: |
| 350 return true; | 359 return true; |
| 351 default: | 360 default: |
| 352 return false; | 361 return false; |
| 353 } | 362 } |
| 354 } | 363 } |
| 355 | 364 |
| 356 | 365 |
| 357 bool UnaryOpNode::IsPotentiallyConst() const { | 366 bool UnaryOpNode::IsPotentiallyConst() const { |
| 367 if (this->operand()->IsLiteralNode() && |
| 368 this->operand()->AsLiteralNode()->literal().IsNull()) { |
| 369 return false; |
| 370 } |
| 358 return this->operand()->IsPotentiallyConst(); | 371 return this->operand()->IsPotentiallyConst(); |
| 359 } | 372 } |
| 360 | 373 |
| 361 | 374 |
| 362 const Instance* UnaryOpNode::EvalConstExpr() const { | 375 const Instance* UnaryOpNode::EvalConstExpr() const { |
| 363 const Instance* val = this->operand()->EvalConstExpr(); | 376 const Instance* val = this->operand()->EvalConstExpr(); |
| 364 if (val == NULL) { | 377 if (val == NULL) { |
| 365 return NULL; | 378 return NULL; |
| 366 } | 379 } |
| 367 switch (kind_) { | 380 switch (kind_) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (result.IsError() || result.IsNull()) { | 586 if (result.IsError() || result.IsNull()) { |
| 574 // TODO(turnidge): We could get better error messages by returning | 587 // TODO(turnidge): We could get better error messages by returning |
| 575 // the Error object directly to the parser. This will involve | 588 // the Error object directly to the parser. This will involve |
| 576 // replumbing all of the EvalConstExpr methods. | 589 // replumbing all of the EvalConstExpr methods. |
| 577 return NULL; | 590 return NULL; |
| 578 } | 591 } |
| 579 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 592 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
| 580 } | 593 } |
| 581 | 594 |
| 582 } // namespace dart | 595 } // namespace dart |
| OLD | NEW |