| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 const char* BinaryOpNode::Name() const { | 181 const char* BinaryOpNode::Name() const { |
| 182 return Token::Str(kind_); | 182 return Token::Str(kind_); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 const Instance* StringConcatNode::EvalConstExpr() const { | |
| 187 for (int i = 0; i < values()->length(); i++) { | |
| 188 if (!values()->ElementAt(i)->IsLiteralNode()) { | |
| 189 return NULL; | |
| 190 } | |
| 191 } | |
| 192 // All nodes are literals, so this is a compile time constant string. | |
| 193 // We just return the first literal as value approximation. | |
| 194 return &values()->ElementAt(0)->AsLiteralNode()->literal(); | |
| 195 } | |
| 196 | |
| 197 | |
| 198 const Instance* BinaryOpNode::EvalConstExpr() const { | 186 const Instance* BinaryOpNode::EvalConstExpr() const { |
| 199 const Instance* left_val = this->left()->EvalConstExpr(); | 187 const Instance* left_val = this->left()->EvalConstExpr(); |
| 200 if (left_val == NULL) { | 188 if (left_val == NULL) { |
| 201 return NULL; | 189 return NULL; |
| 202 } | 190 } |
| 203 if (!left_val->IsNumber() && !left_val->IsBool()) { | 191 if (!left_val->IsNumber() && !left_val->IsBool()) { |
| 204 return NULL; | 192 return NULL; |
| 205 } | 193 } |
| 206 const Instance* right_val = this->right()->EvalConstExpr(); | 194 const Instance* right_val = this->right()->EvalConstExpr(); |
| 207 if (right_val == NULL) { | 195 if (right_val == NULL) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 if (result.IsError() || result.IsNull()) { | 368 if (result.IsError() || result.IsNull()) { |
| 381 // TODO(turnidge): We could get better error messages by returning | 369 // TODO(turnidge): We could get better error messages by returning |
| 382 // the Error object directly to the parser. This will involve | 370 // the Error object directly to the parser. This will involve |
| 383 // replumbing all of the EvalConstExpr methods. | 371 // replumbing all of the EvalConstExpr methods. |
| 384 return NULL; | 372 return NULL; |
| 385 } | 373 } |
| 386 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 374 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
| 387 } | 375 } |
| 388 | 376 |
| 389 } // namespace dart | 377 } // namespace dart |
| OLD | NEW |