| 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 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 const Instance* right_val = this->right()->EvalConstExpr(); | 123 const Instance* right_val = this->right()->EvalConstExpr(); |
| 124 if (right_val == NULL) { | 124 if (right_val == NULL) { |
| 125 return NULL; | 125 return NULL; |
| 126 } | 126 } |
| 127 switch (kind_) { | 127 switch (kind_) { |
| 128 case Token::kLT: | 128 case Token::kLT: |
| 129 case Token::kGT: | 129 case Token::kGT: |
| 130 case Token::kLTE: | 130 case Token::kLTE: |
| 131 case Token::kGTE: | 131 case Token::kGTE: |
| 132 if (left_val->IsNumber() && right_val->IsNumber()) { | 132 if ((left_val->IsNumber() || left_val->IsNull()) && |
| 133 (right_val->IsNumber() || right_val->IsNull())) { |
| 133 return &Bool::ZoneHandle(Bool::False()); | 134 return &Bool::ZoneHandle(Bool::False()); |
| 134 } | 135 } |
| 135 return NULL; | 136 return NULL; |
| 136 case Token::kEQ: | 137 case Token::kEQ: |
| 137 case Token::kNE: | 138 case Token::kNE: |
| 138 case Token::kEQ_STRICT: | 139 case Token::kEQ_STRICT: |
| 139 case Token::kNE_STRICT: | 140 case Token::kNE_STRICT: |
| 140 // The comparison is a compile time const if both operands are either a | 141 // The comparison is a compile time const if both operands are either a |
| 141 // number, string, or boolean value (but not necessarily the same type). | 142 // number, string, or boolean value (but not necessarily the same type). |
| 142 if ((left_val->IsNumber() || | 143 if ((left_val->IsNumber() || |
| 143 left_val->IsString() || | 144 left_val->IsString() || |
| 144 left_val->IsBool()) && | 145 left_val->IsBool() || |
| 146 left_val->IsNull()) && |
| 145 (right_val->IsNumber() || | 147 (right_val->IsNumber() || |
| 146 right_val->IsString() || | 148 right_val->IsString() || |
| 147 right_val->IsBool())) { | 149 right_val->IsBool() || |
| 150 right_val->IsNull())) { |
| 148 return &Bool::ZoneHandle(Bool::False()); | 151 return &Bool::ZoneHandle(Bool::False()); |
| 149 } | 152 } |
| 150 return NULL; | 153 return NULL; |
| 151 default: | 154 default: |
| 152 return NULL; | 155 return NULL; |
| 153 } | 156 } |
| 154 return NULL; | 157 return NULL; |
| 155 } | 158 } |
| 156 | 159 |
| 157 | 160 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (result.IsError() || result.IsNull()) { | 371 if (result.IsError() || result.IsNull()) { |
| 369 // TODO(turnidge): We could get better error messages by returning | 372 // TODO(turnidge): We could get better error messages by returning |
| 370 // the Error object directly to the parser. This will involve | 373 // the Error object directly to the parser. This will involve |
| 371 // replumbing all of the EvalConstExpr methods. | 374 // replumbing all of the EvalConstExpr methods. |
| 372 return NULL; | 375 return NULL; |
| 373 } | 376 } |
| 374 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 377 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
| 375 } | 378 } |
| 376 | 379 |
| 377 } // namespace dart | 380 } // namespace dart |
| OLD | NEW |