| 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 2731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 | 2742 |
| 2743 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { | 2743 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { |
| 2744 Value* array = Pop(); | 2744 Value* array = Pop(); |
| 2745 StringInterpolateInstr* interpolate = | 2745 StringInterpolateInstr* interpolate = |
| 2746 new (Z) StringInterpolateInstr(array, position); | 2746 new (Z) StringInterpolateInstr(array, position); |
| 2747 Push(interpolate); | 2747 Push(interpolate); |
| 2748 return Fragment(interpolate); | 2748 return Fragment(interpolate); |
| 2749 } | 2749 } |
| 2750 | 2750 |
| 2751 | 2751 |
| 2752 Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) { |
| 2753 const int kNumberOfArguments = 1; |
| 2754 const Array& kNoArgumentNames = Object::null_array(); |
| 2755 const dart::Class& cls = dart::Class::Handle( |
| 2756 dart::Library::LookupCoreClass(Symbols::StringBase())); |
| 2757 ASSERT(!cls.IsNull()); |
| 2758 const Function& function = dart::Function::ZoneHandle( |
| 2759 Z, dart::Resolver::ResolveStatic(cls, dart::Library::PrivateCoreLibName( |
| 2760 Symbols::InterpolateSingle()), |
| 2761 kNumberOfArguments, kNoArgumentNames)); |
| 2762 Fragment instructions; |
| 2763 instructions += PushArgument(); |
| 2764 instructions += StaticCall(position, function, 1); |
| 2765 return instructions; |
| 2766 } |
| 2767 |
| 2768 |
| 2752 Fragment FlowGraphBuilder::ThrowTypeError() { | 2769 Fragment FlowGraphBuilder::ThrowTypeError() { |
| 2753 const dart::Class& klass = dart::Class::ZoneHandle( | 2770 const dart::Class& klass = dart::Class::ZoneHandle( |
| 2754 Z, dart::Library::LookupCoreClass(Symbols::TypeError())); | 2771 Z, dart::Library::LookupCoreClass(Symbols::TypeError())); |
| 2755 ASSERT(!klass.IsNull()); | 2772 ASSERT(!klass.IsNull()); |
| 2756 const dart::Function& constructor = dart::Function::ZoneHandle( | 2773 const dart::Function& constructor = dart::Function::ZoneHandle( |
| 2757 Z, | 2774 Z, |
| 2758 klass.LookupConstructorAllowPrivate(H.DartSymbol("_TypeError._create"))); | 2775 klass.LookupConstructorAllowPrivate(H.DartSymbol("_TypeError._create"))); |
| 2759 ASSERT(!constructor.IsNull()); | 2776 ASSERT(!constructor.IsNull()); |
| 2760 | 2777 |
| 2761 const dart::String& url = H.DartString( | 2778 const dart::String& url = H.DartString( |
| (...skipping 2400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5162 void FlowGraphBuilder::VisitThisExpression(ThisExpression* node) { | 5179 void FlowGraphBuilder::VisitThisExpression(ThisExpression* node) { |
| 5163 fragment_ = LoadLocal(scopes_->this_variable); | 5180 fragment_ = LoadLocal(scopes_->this_variable); |
| 5164 } | 5181 } |
| 5165 | 5182 |
| 5166 | 5183 |
| 5167 void FlowGraphBuilder::VisitStringConcatenation(StringConcatenation* node) { | 5184 void FlowGraphBuilder::VisitStringConcatenation(StringConcatenation* node) { |
| 5168 List<Expression>& expressions = node->expressions(); | 5185 List<Expression>& expressions = node->expressions(); |
| 5169 | 5186 |
| 5170 Fragment instructions; | 5187 Fragment instructions; |
| 5171 | 5188 |
| 5172 // The type arguments for CreateArray. | 5189 if (node->expressions().length() == 1) { |
| 5173 instructions += Constant(TypeArguments::ZoneHandle(Z)); | 5190 instructions += TranslateExpression(node->expressions()[0]); |
| 5174 instructions += IntConstant(expressions.length()); | 5191 instructions += StringInterpolateSingle(node->position()); |
| 5175 instructions += CreateArray(); | 5192 } else { |
| 5176 LocalVariable* array = MakeTemporary(); | 5193 // The type arguments for CreateArray. |
| 5194 instructions += Constant(TypeArguments::ZoneHandle(Z)); |
| 5195 instructions += IntConstant(expressions.length()); |
| 5196 instructions += CreateArray(); |
| 5197 LocalVariable* array = MakeTemporary(); |
| 5177 | 5198 |
| 5178 for (intptr_t i = 0; i < node->expressions().length(); i++) { | 5199 for (intptr_t i = 0; i < node->expressions().length(); i++) { |
| 5179 instructions += LoadLocal(array); | 5200 instructions += LoadLocal(array); |
| 5180 instructions += IntConstant(i); | 5201 instructions += IntConstant(i); |
| 5181 instructions += TranslateExpression(node->expressions()[i]); | 5202 instructions += TranslateExpression(node->expressions()[i]); |
| 5182 instructions += StoreIndexed(kArrayCid); | 5203 instructions += StoreIndexed(kArrayCid); |
| 5183 instructions += Drop(); | 5204 instructions += Drop(); |
| 5205 } |
| 5206 |
| 5207 instructions += StringInterpolate(node->position()); |
| 5184 } | 5208 } |
| 5185 | |
| 5186 instructions += StringInterpolate(node->position()); | |
| 5187 | |
| 5188 fragment_ = instructions; | 5209 fragment_ = instructions; |
| 5189 } | 5210 } |
| 5190 | 5211 |
| 5191 | 5212 |
| 5192 void FlowGraphBuilder::VisitListLiteral(ListLiteral* node) { | 5213 void FlowGraphBuilder::VisitListLiteral(ListLiteral* node) { |
| 5193 if (node->is_const()) { | 5214 if (node->is_const()) { |
| 5194 fragment_ = Constant(constant_evaluator_.EvaluateListLiteral(node)); | 5215 fragment_ = Constant(constant_evaluator_.EvaluateListLiteral(node)); |
| 5195 return; | 5216 return; |
| 5196 } | 5217 } |
| 5197 | 5218 |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6444 thread->clear_sticky_error(); | 6465 thread->clear_sticky_error(); |
| 6445 return error.raw(); | 6466 return error.raw(); |
| 6446 } | 6467 } |
| 6447 } | 6468 } |
| 6448 | 6469 |
| 6449 | 6470 |
| 6450 } // namespace kernel | 6471 } // namespace kernel |
| 6451 } // namespace dart | 6472 } // namespace dart |
| 6452 | 6473 |
| 6453 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6474 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |