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

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

Issue 9969023: Fix two compile time const issues (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | tests/co19/co19-runtime.status » ('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 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 case Token::kLTE: 131 case Token::kLTE:
132 case Token::kGTE: 132 case Token::kGTE:
133 if (left_val->IsNumber() && right_val->IsNumber()) { 133 if (left_val->IsNumber() && right_val->IsNumber()) {
134 return &Bool::ZoneHandle(Bool::False()); 134 return &Bool::ZoneHandle(Bool::False());
135 } 135 }
136 return NULL; 136 return NULL;
137 case Token::kEQ: 137 case Token::kEQ:
138 case Token::kNE: 138 case Token::kNE:
139 case Token::kEQ_STRICT: 139 case Token::kEQ_STRICT:
140 case Token::kNE_STRICT: 140 case Token::kNE_STRICT:
141 if ((left_val->IsNumber() && right_val->IsNumber()) || 141 // The comparison is a compile time const if both operands are either a
142 (left_val->IsString() && right_val->IsString()) || 142 // number, string, or boolean value (but not necessarily the same type).
143 (left_val->IsBool() && right_val->IsBool())) { 143 if ((left_val->IsNumber() ||
144 left_val->IsString() ||
145 left_val->IsBool()) &&
146 (right_val->IsNumber() ||
147 right_val->IsString() ||
148 right_val->IsBool())) {
144 return &Bool::ZoneHandle(Bool::False()); 149 return &Bool::ZoneHandle(Bool::False());
145 } 150 }
146 return NULL; 151 return NULL;
147 default: 152 default:
148 return NULL; 153 return NULL;
149 } 154 }
150 return NULL; 155 return NULL;
151 } 156 }
152 157
153 158
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 const Instance* right_val = this->right()->EvalConstExpr(); 207 const Instance* right_val = this->right()->EvalConstExpr();
203 if (right_val == NULL) { 208 if (right_val == NULL) {
204 return NULL; 209 return NULL;
205 } 210 }
206 switch (kind_) { 211 switch (kind_) {
207 case Token::kADD: 212 case Token::kADD:
208 case Token::kSUB: 213 case Token::kSUB:
209 case Token::kMUL: 214 case Token::kMUL:
210 case Token::kDIV: 215 case Token::kDIV:
211 case Token::kMOD: 216 case Token::kMOD:
217 case Token::kTRUNCDIV:
212 if (left_val->IsInteger()) { 218 if (left_val->IsInteger()) {
213 if (right_val->IsInteger()) { 219 if (right_val->IsInteger()) {
214 return left_val; 220 return left_val;
215 } else if (right_val->IsNumber()) { 221 } else if (right_val->IsNumber()) {
216 return right_val; 222 return right_val;
217 } 223 }
218 } else if (left_val->IsNumber() && 224 } else if (left_val->IsNumber() &&
219 right_val->IsNumber()) { 225 right_val->IsNumber()) {
220 return left_val; 226 return left_val;
221 } 227 }
222 return NULL; 228 return NULL;
223 case Token::kTRUNCDIV:
224 case Token::kBIT_OR: 229 case Token::kBIT_OR:
225 case Token::kBIT_XOR: 230 case Token::kBIT_XOR:
226 case Token::kBIT_AND: 231 case Token::kBIT_AND:
227 case Token::kSHL: 232 case Token::kSHL:
228 case Token::kSHR: 233 case Token::kSHR:
229 if (left_val->IsInteger() && 234 if (left_val->IsInteger() &&
230 right_val->IsInteger()) { 235 right_val->IsInteger()) {
231 return right_val; 236 return right_val;
232 } 237 }
233 return NULL; 238 return NULL;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // the Error object directly to the parser. This will involve 437 // the Error object directly to the parser. This will involve
433 // replumbing all of the EvalConstExpr methods. 438 // replumbing all of the EvalConstExpr methods.
434 return NULL; 439 return NULL;
435 } 440 }
436 Instance& field_value = Instance::ZoneHandle(); 441 Instance& field_value = Instance::ZoneHandle();
437 field_value ^= result.raw(); 442 field_value ^= result.raw();
438 return &field_value; 443 return &field_value;
439 } 444 }
440 445
441 } // namespace dart 446 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698