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

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

Issue 1180903002: null-aware operators in the VM (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add test for opt compiler Created 5 years, 6 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
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 bool BinaryOpNode::IsKindValid() const { 255 bool BinaryOpNode::IsKindValid() const {
256 switch (kind_) { 256 switch (kind_) {
257 case Token::kADD: 257 case Token::kADD:
258 case Token::kSUB: 258 case Token::kSUB:
259 case Token::kMUL: 259 case Token::kMUL:
260 case Token::kDIV: 260 case Token::kDIV:
261 case Token::kTRUNCDIV: 261 case Token::kTRUNCDIV:
262 case Token::kMOD: 262 case Token::kMOD:
263 case Token::kOR: 263 case Token::kOR:
264 case Token::kAND: 264 case Token::kAND:
265 case Token::kIFNULL:
265 case Token::kBIT_OR: 266 case Token::kBIT_OR:
266 case Token::kBIT_XOR: 267 case Token::kBIT_XOR:
267 case Token::kBIT_AND: 268 case Token::kBIT_AND:
268 case Token::kSHL: 269 case Token::kSHL:
269 case Token::kSHR: 270 case Token::kSHR:
270 return true; 271 return true;
271 default: 272 default:
272 return false; 273 return false;
273 } 274 }
274 } 275 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 field().token_pos(), 523 field().token_pos(),
523 rhs, 524 rhs,
524 AbstractType::ZoneHandle(field().type()), 525 AbstractType::ZoneHandle(field().type()),
525 String::ZoneHandle(field().name())); 526 String::ZoneHandle(field().name()));
526 } 527 }
527 return new StoreStaticFieldNode(token_pos(), field(), rhs); 528 return new StoreStaticFieldNode(token_pos(), field(), rhs);
528 } 529 }
529 530
530 531
531 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) { 532 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) {
532 return new InstanceSetterNode(token_pos(), receiver(), field_name(), rhs); 533 return new InstanceSetterNode(token_pos(),
534 receiver(),
535 field_name(),
536 rhs,
537 is_conditional());
533 } 538 }
534 539
535 540
536 bool InstanceGetterNode::IsPotentiallyConst() const { 541 bool InstanceGetterNode::IsPotentiallyConst() const {
537 return field_name().Equals(Symbols::Length()) && 542 return field_name().Equals(Symbols::Length()) &&
543 !is_conditional() &&
538 receiver()->IsPotentiallyConst(); 544 receiver()->IsPotentiallyConst();
539 } 545 }
540 546
541 547
542 const Instance* InstanceGetterNode::EvalConstExpr() const { 548 const Instance* InstanceGetterNode::EvalConstExpr() const {
543 if (field_name().Equals(Symbols::Length())) { 549 if (field_name().Equals(Symbols::Length()) && !is_conditional()) {
544 const Instance* receiver_val = receiver()->EvalConstExpr(); 550 const Instance* receiver_val = receiver()->EvalConstExpr();
545 if ((receiver_val != NULL) && receiver_val->IsString()) { 551 if ((receiver_val != NULL) && receiver_val->IsString()) {
546 return &Instance::ZoneHandle(Smi::New(1)); 552 return &Instance::ZoneHandle(Smi::New(1));
547 } 553 }
548 } 554 }
549 return NULL; 555 return NULL;
550 } 556 }
551 557
552 558
553 AstNode* LoadIndexedNode::MakeAssignmentNode(AstNode* rhs) { 559 AstNode* LoadIndexedNode::MakeAssignmentNode(AstNode* rhs) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 if (result.IsError() || result.IsNull()) { 749 if (result.IsError() || result.IsNull()) {
744 // TODO(turnidge): We could get better error messages by returning 750 // TODO(turnidge): We could get better error messages by returning
745 // the Error object directly to the parser. This will involve 751 // the Error object directly to the parser. This will involve
746 // replumbing all of the EvalConstExpr methods. 752 // replumbing all of the EvalConstExpr methods.
747 return NULL; 753 return NULL;
748 } 754 }
749 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 755 return &Instance::ZoneHandle(Instance::Cast(result).raw());
750 } 756 }
751 757
752 } // namespace dart 758 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698