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 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 const dart::String& TranslationHelper::DartSymbol(const char* content) const { | 1034 const dart::String& TranslationHelper::DartSymbol(const char* content) const { |
1035 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); | 1035 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); |
1036 } | 1036 } |
1037 | 1037 |
1038 | 1038 |
1039 dart::String& TranslationHelper::DartSymbol(String* content) const { | 1039 dart::String& TranslationHelper::DartSymbol(String* content) const { |
1040 return dart::String::ZoneHandle( | 1040 return dart::String::ZoneHandle( |
1041 Z, dart::Symbols::FromUTF8(thread_, content->buffer(), content->size())); | 1041 Z, dart::Symbols::FromUTF8(thread_, content->buffer(), content->size())); |
1042 } | 1042 } |
1043 | 1043 |
| 1044 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, |
| 1045 intptr_t len) const { |
| 1046 return dart::String::ZoneHandle( |
| 1047 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len)); |
| 1048 } |
1044 | 1049 |
1045 const dart::String& TranslationHelper::DartClassName( | 1050 const dart::String& TranslationHelper::DartClassName( |
1046 CanonicalName* kernel_klass) { | 1051 CanonicalName* kernel_klass) { |
1047 dart::String& name = DartString(kernel_klass->name()); | 1052 dart::String& name = DartString(kernel_klass->name()); |
1048 return ManglePrivateName(kernel_klass->parent(), &name); | 1053 return ManglePrivateName(kernel_klass->parent(), &name); |
1049 } | 1054 } |
1050 | 1055 |
1051 | 1056 |
1052 const dart::String& TranslationHelper::DartConstructorName(Constructor* node) { | 1057 const dart::String& TranslationHelper::DartConstructorName(Constructor* node) { |
1053 Class* klass = Class::Cast(node->parent()); | 1058 Class* klass = Class::Cast(node->parent()); |
(...skipping 3178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4232 arguments->data()[i] = stack_->definition()->AsPushArgument(); | 4237 arguments->data()[i] = stack_->definition()->AsPushArgument(); |
4233 Drop(); | 4238 Drop(); |
4234 } | 4239 } |
4235 pending_argument_count_ -= count; | 4240 pending_argument_count_ -= count; |
4236 ASSERT(pending_argument_count_ >= 0); | 4241 ASSERT(pending_argument_count_ >= 0); |
4237 return arguments; | 4242 return arguments; |
4238 } | 4243 } |
4239 | 4244 |
4240 | 4245 |
4241 void FlowGraphBuilder::VisitInvalidExpression(InvalidExpression* node) { | 4246 void FlowGraphBuilder::VisitInvalidExpression(InvalidExpression* node) { |
4242 // The frontend will take care of emitting normal errors (like | 4247 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
4243 // [NoSuchMethodError]s) and only emit [InvalidExpression]s in very special | |
4244 // situations (e.g. an invalid annotation). | |
4245 fragment_ = ThrowNoSuchMethodError(); | |
4246 } | 4248 } |
4247 | 4249 |
4248 | 4250 |
4249 void FlowGraphBuilder::VisitNullLiteral(NullLiteral* node) { | 4251 void FlowGraphBuilder::VisitNullLiteral(NullLiteral* node) { |
4250 fragment_ = Constant(Instance::ZoneHandle(Z, Instance::null())); | 4252 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
4251 } | 4253 } |
4252 | 4254 |
4253 | 4255 |
4254 void FlowGraphBuilder::VisitBoolLiteral(BoolLiteral* node) { | 4256 void FlowGraphBuilder::VisitBoolLiteral(BoolLiteral* node) { |
4255 fragment_ = Constant(Bool::Get(node->value())); | 4257 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
4256 } | 4258 } |
4257 | 4259 |
4258 | 4260 |
4259 void FlowGraphBuilder::VisitIntLiteral(IntLiteral* node) { | 4261 void FlowGraphBuilder::VisitIntLiteral(IntLiteral* node) { |
4260 fragment_ = IntConstant(node->value()); | 4262 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
4261 } | 4263 } |
4262 | 4264 |
4263 | 4265 |
4264 void FlowGraphBuilder::VisitBigintLiteral(BigintLiteral* node) { | 4266 void FlowGraphBuilder::VisitBigintLiteral(BigintLiteral* node) { |
4265 const dart::String& value = H.DartString(node->value()); | 4267 const dart::String& value = H.DartString(node->value()); |
4266 fragment_ = Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))); | 4268 fragment_ = Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))); |
4267 } | 4269 } |
4268 | 4270 |
4269 | 4271 |
4270 void FlowGraphBuilder::VisitDoubleLiteral(DoubleLiteral* node) { | 4272 void FlowGraphBuilder::VisitDoubleLiteral(DoubleLiteral* node) { |
4271 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); | 4273 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); |
4272 } | 4274 } |
4273 | 4275 |
4274 | 4276 |
4275 void FlowGraphBuilder::VisitStringLiteral(StringLiteral* node) { | 4277 void FlowGraphBuilder::VisitStringLiteral(StringLiteral* node) { |
4276 fragment_ = Constant(H.DartSymbol(node->value())); | 4278 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
4277 } | 4279 } |
4278 | 4280 |
4279 | 4281 |
4280 void FlowGraphBuilder::VisitSymbolLiteral(SymbolLiteral* node) { | 4282 void FlowGraphBuilder::VisitSymbolLiteral(SymbolLiteral* node) { |
4281 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); | 4283 fragment_ = Constant(constant_evaluator_.EvaluateExpression(node)); |
4282 } | 4284 } |
4283 | 4285 |
4284 | 4286 |
4285 AbstractType& DartTypeTranslator::TranslateType(DartType* node) { | 4287 AbstractType& DartTypeTranslator::TranslateType(DartType* node) { |
4286 node->AcceptDartTypeVisitor(this); | 4288 node->AcceptDartTypeVisitor(this); |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 | 5175 |
5174 void FlowGraphBuilder::VisitNot(Not* node) { | 5176 void FlowGraphBuilder::VisitNot(Not* node) { |
5175 Fragment instructions = TranslateExpression(node->expression()); | 5177 Fragment instructions = TranslateExpression(node->expression()); |
5176 instructions += CheckBooleanInCheckedMode(); | 5178 instructions += CheckBooleanInCheckedMode(); |
5177 instructions += BooleanNegate(); | 5179 instructions += BooleanNegate(); |
5178 fragment_ = instructions; | 5180 fragment_ = instructions; |
5179 } | 5181 } |
5180 | 5182 |
5181 | 5183 |
5182 void FlowGraphBuilder::VisitThisExpression(ThisExpression* node) { | 5184 void FlowGraphBuilder::VisitThisExpression(ThisExpression* node) { |
5183 fragment_ = LoadLocal(scopes_->this_variable); | 5185 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); |
5184 } | 5186 } |
5185 | 5187 |
5186 | 5188 |
5187 void FlowGraphBuilder::VisitStringConcatenation(StringConcatenation* node) { | 5189 void FlowGraphBuilder::VisitStringConcatenation(StringConcatenation* node) { |
5188 List<Expression>& expressions = node->expressions(); | 5190 List<Expression>& expressions = node->expressions(); |
5189 | 5191 |
5190 Fragment instructions; | 5192 Fragment instructions; |
5191 | 5193 |
5192 if (node->expressions().length() == 1) { | 5194 if (node->expressions().length() == 1) { |
5193 instructions += TranslateExpression(node->expressions()[0]); | 5195 instructions += TranslateExpression(node->expressions()[0]); |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6458 thread->clear_sticky_error(); | 6460 thread->clear_sticky_error(); |
6459 return error.raw(); | 6461 return error.raw(); |
6460 } | 6462 } |
6461 } | 6463 } |
6462 | 6464 |
6463 | 6465 |
6464 } // namespace kernel | 6466 } // namespace kernel |
6465 } // namespace dart | 6467 } // namespace dart |
6466 | 6468 |
6467 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6469 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |