| 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 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 | 1763 |
| 1764 | 1764 |
| 1765 void ConstantEvaluator::VisitNot(Not* node) { | 1765 void ConstantEvaluator::VisitNot(Not* node) { |
| 1766 EvaluateExpression(node->expression()); | 1766 EvaluateExpression(node->expression()); |
| 1767 ASSERT(result_.IsBool()); | 1767 ASSERT(result_.IsBool()); |
| 1768 result_ = | 1768 result_ = |
| 1769 Bool::Cast(result_).value() ? Bool::False().raw() : Bool::True().raw(); | 1769 Bool::Cast(result_).value() ? Bool::False().raw() : Bool::True().raw(); |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 | 1772 |
| 1773 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { |
| 1774 const size_t kLengthLen = strlen("length"); |
| 1775 |
| 1776 String* string = node->name()->string(); |
| 1777 if (string->size() == kLengthLen && |
| 1778 memcmp(string->buffer(), "length", kLengthLen) == 0) { |
| 1779 node->receiver()->AcceptExpressionVisitor(this); |
| 1780 if (result_.IsString()) { |
| 1781 const dart::String& str = |
| 1782 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); |
| 1783 result_ = Integer::New(str.Length()); |
| 1784 } else { |
| 1785 H.ReportError( |
| 1786 "Constant expressions can only call " |
| 1787 "'length' on string constants."); |
| 1788 } |
| 1789 } else { |
| 1790 VisitDefaultExpression(node); |
| 1791 } |
| 1792 } |
| 1793 |
| 1794 |
| 1773 const TypeArguments* ConstantEvaluator::TranslateTypeArguments( | 1795 const TypeArguments* ConstantEvaluator::TranslateTypeArguments( |
| 1774 const Function& target, | 1796 const Function& target, |
| 1775 dart::Class* target_klass, | 1797 dart::Class* target_klass, |
| 1776 Arguments* kernel_arguments) { | 1798 Arguments* kernel_arguments) { |
| 1777 List<DartType>& kernel_type_arguments = kernel_arguments->types(); | 1799 List<DartType>& kernel_type_arguments = kernel_arguments->types(); |
| 1778 | 1800 |
| 1779 const TypeArguments* type_arguments = NULL; | 1801 const TypeArguments* type_arguments = NULL; |
| 1780 if (kernel_type_arguments.length() > 0) { | 1802 if (kernel_type_arguments.length() > 0) { |
| 1781 type_arguments = &T.TranslateInstantiatedTypeArguments( | 1803 type_arguments = &T.TranslateInstantiatedTypeArguments( |
| 1782 *target_klass, kernel_type_arguments.raw_array(), | 1804 *target_klass, kernel_type_arguments.raw_array(), |
| (...skipping 4063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5846 instructions += LoadLocal(parsed_function_->current_context_var()); | 5868 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 5847 instructions += StoreInstanceField(Closure::context_offset()); | 5869 instructions += StoreInstanceField(Closure::context_offset()); |
| 5848 | 5870 |
| 5849 return instructions; | 5871 return instructions; |
| 5850 } | 5872 } |
| 5851 | 5873 |
| 5852 | 5874 |
| 5853 } // namespace kernel | 5875 } // namespace kernel |
| 5854 } // namespace dart | 5876 } // namespace dart |
| 5855 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 5877 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |