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

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

Issue 1259813003: Fix #23871: identical on consts should be always const (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: comment Created 5 years, 4 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
« no previous file with comments | « no previous file | tests/language/const_syntax_test.dart » ('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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 case Token::kGT: 222 case Token::kGT:
223 case Token::kLTE: 223 case Token::kLTE:
224 case Token::kGTE: 224 case Token::kGTE:
225 if ((left_val->IsNumber() || left_val->IsNull()) && 225 if ((left_val->IsNumber() || left_val->IsNull()) &&
226 (right_val->IsNumber() || right_val->IsNull())) { 226 (right_val->IsNumber() || right_val->IsNull())) {
227 return &Bool::False(); 227 return &Bool::False();
228 } 228 }
229 return NULL; 229 return NULL;
230 case Token::kEQ: 230 case Token::kEQ:
231 case Token::kNE: 231 case Token::kNE:
232 case Token::kEQ_STRICT:
233 case Token::kNE_STRICT:
234 // The comparison is a compile time const if both operands are either a 232 // The comparison is a compile time const if both operands are either a
235 // number, string, or boolean value (but not necessarily the same type). 233 // number, string, or boolean value (but not necessarily the same type).
236 if ((left_val->IsNumber() || 234 if ((left_val->IsNumber() ||
237 left_val->IsString() || 235 left_val->IsString() ||
238 left_val->IsBool() || 236 left_val->IsBool() ||
239 left_val->IsNull()) && 237 left_val->IsNull()) &&
240 (right_val->IsNumber() || 238 (right_val->IsNumber() ||
241 right_val->IsString() || 239 right_val->IsString() ||
242 right_val->IsBool() || 240 right_val->IsBool() ||
243 right_val->IsNull())) { 241 right_val->IsNull())) {
244 return &Bool::False(); 242 return &Bool::False();
245 } 243 }
246 return NULL; 244 return NULL;
245 case Token::kEQ_STRICT:
246 case Token::kNE_STRICT:
247 // identical(a, b) is a compile time const if both operands are
248 // compile time constants, regardless of their type.
249 return &Bool::True();
247 default: 250 default:
248 return NULL; 251 return NULL;
249 } 252 }
250 return NULL; 253 return NULL;
251 } 254 }
252 255
253 256
254 257
255 bool BinaryOpNode::IsKindValid() const { 258 bool BinaryOpNode::IsKindValid() const {
256 switch (kind_) { 259 switch (kind_) {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 if (result.IsError() || result.IsNull()) { 752 if (result.IsError() || result.IsNull()) {
750 // TODO(turnidge): We could get better error messages by returning 753 // TODO(turnidge): We could get better error messages by returning
751 // the Error object directly to the parser. This will involve 754 // the Error object directly to the parser. This will involve
752 // replumbing all of the EvalConstExpr methods. 755 // replumbing all of the EvalConstExpr methods.
753 return NULL; 756 return NULL;
754 } 757 }
755 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 758 return &Instance::ZoneHandle(Instance::Cast(result).raw());
756 } 759 }
757 760
758 } // namespace dart 761 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/const_syntax_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698