OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
10 | 10 |
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 } | 1804 } |
1805 } | 1805 } |
1806 | 1806 |
1807 | 1807 |
1808 void ConstantEvaluator::VisitNot(Not* node) { | 1808 void ConstantEvaluator::VisitNot(Not* node) { |
1809 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); | 1809 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); |
1810 } | 1810 } |
1811 | 1811 |
1812 | 1812 |
1813 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { | 1813 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { |
1814 const size_t kLengthLen = strlen("length"); | 1814 const intptr_t kLengthLen = strlen("length"); |
1815 | 1815 |
1816 String* string = node->name()->string(); | 1816 String* string = node->name()->string(); |
1817 if (string->size() == kLengthLen && | 1817 if ((string->size() == kLengthLen) && |
1818 memcmp(string->buffer(), "length", kLengthLen) == 0) { | 1818 (memcmp(string->buffer(), "length", kLengthLen) == 0)) { |
1819 node->receiver()->AcceptExpressionVisitor(this); | 1819 node->receiver()->AcceptExpressionVisitor(this); |
1820 if (result_.IsString()) { | 1820 if (result_.IsString()) { |
1821 const dart::String& str = | 1821 const dart::String& str = |
1822 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); | 1822 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); |
1823 result_ = Integer::New(str.Length()); | 1823 result_ = Integer::New(str.Length()); |
1824 } else { | 1824 } else { |
1825 H.ReportError( | 1825 H.ReportError( |
1826 "Constant expressions can only call " | 1826 "Constant expressions can only call " |
1827 "'length' on string constants."); | 1827 "'length' on string constants."); |
1828 } | 1828 } |
(...skipping 4451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6280 thread->clear_sticky_error(); | 6280 thread->clear_sticky_error(); |
6281 return error.raw(); | 6281 return error.raw(); |
6282 } | 6282 } |
6283 } | 6283 } |
6284 | 6284 |
6285 | 6285 |
6286 } // namespace kernel | 6286 } // namespace kernel |
6287 } // namespace dart | 6287 } // namespace dart |
6288 | 6288 |
6289 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6289 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |