| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 node->finalizer()->AcceptStatementVisitor(this); | 638 node->finalizer()->AcceptStatementVisitor(this); |
| 639 --depth_.catch_; | 639 --depth_.catch_; |
| 640 } | 640 } |
| 641 | 641 |
| 642 | 642 |
| 643 void ScopeBuilder::VisitFunctionNode(FunctionNode* node) { | 643 void ScopeBuilder::VisitFunctionNode(FunctionNode* node) { |
| 644 List<TypeParameter>& type_parameters = node->type_parameters(); | 644 List<TypeParameter>& type_parameters = node->type_parameters(); |
| 645 for (intptr_t i = 0; i < type_parameters.length(); ++i) { | 645 for (intptr_t i = 0; i < type_parameters.length(); ++i) { |
| 646 VisitTypeParameter(type_parameters[i]); | 646 VisitTypeParameter(type_parameters[i]); |
| 647 } | 647 } |
| 648 |
| 649 if (node->async_marker() == FunctionNode::kSyncYielding) { |
| 650 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 651 for (intptr_t i = 0; |
| 652 i < parsed_function_->function().NumOptionalPositionalParameters(); |
| 653 i++) { |
| 654 scope->VariableAt(i)->set_is_forced_stack(); |
| 655 } |
| 656 } |
| 657 |
| 648 // Do not visit the positional and named parameters, because they've | 658 // Do not visit the positional and named parameters, because they've |
| 649 // already been added to the scope. | 659 // already been added to the scope. |
| 650 if (node->body() != NULL) { | 660 if (node->body() != NULL) { |
| 651 node->body()->AcceptStatementVisitor(this); | 661 node->body()->AcceptStatementVisitor(this); |
| 652 } | 662 } |
| 653 | 663 |
| 654 // Ensure that :await_jump_var and :await_ctx_var are captured. | 664 // Ensure that :await_jump_var and :await_ctx_var are captured. |
| 655 if (node->async_marker() == FunctionNode::kSyncYielding) { | 665 if (node->async_marker() == FunctionNode::kSyncYielding) { |
| 656 { | 666 { |
| 657 LocalVariable* temp = NULL; | 667 LocalVariable* temp = NULL; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 Library* kernel_library = Library::Cast(kernel_klass->parent()); | 1108 Library* kernel_library = Library::Cast(kernel_klass->parent()); |
| 1099 dart::Library& library = | 1109 dart::Library& library = |
| 1100 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); | 1110 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); |
| 1101 klass = library.LookupClassAllowPrivate(class_name); | 1111 klass = library.LookupClassAllowPrivate(class_name); |
| 1102 | 1112 |
| 1103 ASSERT(klass != Object::null()); | 1113 ASSERT(klass != Object::null()); |
| 1104 return klass; | 1114 return klass; |
| 1105 } | 1115 } |
| 1106 | 1116 |
| 1107 | 1117 |
| 1118 dart::RawUnresolvedClass* TranslationHelper::ToUnresolvedClass( |
| 1119 Class* kernel_klass) { |
| 1120 dart::RawClass* klass = NULL; |
| 1121 |
| 1122 const dart::String& class_name = DartClassName(kernel_klass); |
| 1123 Library* kernel_library = Library::Cast(kernel_klass->parent()); |
| 1124 dart::Library& library = |
| 1125 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); |
| 1126 |
| 1127 ASSERT(klass != Object::null()); |
| 1128 return dart::UnresolvedClass::New(library, class_name, |
| 1129 TokenPosition::kNoSource); |
| 1130 } |
| 1131 |
| 1132 |
| 1108 dart::RawField* TranslationHelper::LookupFieldByKernelField( | 1133 dart::RawField* TranslationHelper::LookupFieldByKernelField( |
| 1109 Field* kernel_field) { | 1134 Field* kernel_field) { |
| 1110 TreeNode* node = kernel_field->parent(); | 1135 TreeNode* node = kernel_field->parent(); |
| 1111 | 1136 |
| 1112 dart::Class& klass = dart::Class::Handle(Z); | 1137 dart::Class& klass = dart::Class::Handle(Z); |
| 1113 if (node->IsClass()) { | 1138 if (node->IsClass()) { |
| 1114 klass = LookupClassByKernelClass(Class::Cast(node)); | 1139 klass = LookupClassByKernelClass(Class::Cast(node)); |
| 1115 } else { | 1140 } else { |
| 1116 ASSERT(node->IsLibrary()); | 1141 ASSERT(node->IsLibrary()); |
| 1117 dart::Library& library = dart::Library::Handle( | 1142 dart::Library& library = dart::Library::Handle( |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 stack_(NULL), | 1857 stack_(NULL), |
| 1833 pending_argument_count_(0), | 1858 pending_argument_count_(0), |
| 1834 graph_entry_(NULL), | 1859 graph_entry_(NULL), |
| 1835 scopes_(NULL), | 1860 scopes_(NULL), |
| 1836 breakable_block_(NULL), | 1861 breakable_block_(NULL), |
| 1837 switch_block_(NULL), | 1862 switch_block_(NULL), |
| 1838 try_finally_block_(NULL), | 1863 try_finally_block_(NULL), |
| 1839 try_catch_block_(NULL), | 1864 try_catch_block_(NULL), |
| 1840 next_used_try_index_(0), | 1865 next_used_try_index_(0), |
| 1841 catch_block_(NULL), | 1866 catch_block_(NULL), |
| 1842 type_translator_(&translation_helper_, &active_class_), | 1867 type_translator_(&translation_helper_, |
| 1868 &active_class_, |
| 1869 /* finalize= */ true), |
| 1843 constant_evaluator_(this, | 1870 constant_evaluator_(this, |
| 1844 zone_, | 1871 zone_, |
| 1845 &translation_helper_, | 1872 &translation_helper_, |
| 1846 &type_translator_) {} | 1873 &type_translator_) {} |
| 1847 | 1874 |
| 1848 | 1875 |
| 1849 FlowGraphBuilder::~FlowGraphBuilder() {} | 1876 FlowGraphBuilder::~FlowGraphBuilder() {} |
| 1850 | 1877 |
| 1851 | 1878 |
| 1852 Fragment FlowGraphBuilder::TranslateFinallyFinalizers( | 1879 Fragment FlowGraphBuilder::TranslateFinallyFinalizers( |
| (...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3834 // We return a new `ZoneHandle` here on purpose: The intermediate language | 3861 // We return a new `ZoneHandle` here on purpose: The intermediate language |
| 3835 // instructions do not make a copy of the handle, so we do it. | 3862 // instructions do not make a copy of the handle, so we do it. |
| 3836 return dart::AbstractType::ZoneHandle(Z, result_.raw()); | 3863 return dart::AbstractType::ZoneHandle(Z, result_.raw()); |
| 3837 } | 3864 } |
| 3838 | 3865 |
| 3839 | 3866 |
| 3840 AbstractType& DartTypeTranslator::TranslateTypeWithoutFinalization( | 3867 AbstractType& DartTypeTranslator::TranslateTypeWithoutFinalization( |
| 3841 DartType* node) { | 3868 DartType* node) { |
| 3842 bool saved_finalize = finalize_; | 3869 bool saved_finalize = finalize_; |
| 3843 finalize_ = false; | 3870 finalize_ = false; |
| 3844 H.SetFinalize(false); | |
| 3845 AbstractType& result = TranslateType(node); | 3871 AbstractType& result = TranslateType(node); |
| 3846 finalize_ = saved_finalize; | 3872 finalize_ = saved_finalize; |
| 3847 H.SetFinalize(saved_finalize); | |
| 3848 return result; | 3873 return result; |
| 3849 } | 3874 } |
| 3850 | 3875 |
| 3851 | 3876 |
| 3852 const AbstractType& DartTypeTranslator::TranslateVariableType( | 3877 const AbstractType& DartTypeTranslator::TranslateVariableType( |
| 3853 VariableDeclaration* variable) { | 3878 VariableDeclaration* variable) { |
| 3854 AbstractType& abstract_type = TranslateType(variable->type()); | 3879 AbstractType& abstract_type = TranslateType(variable->type()); |
| 3855 | 3880 |
| 3856 // We return a new `ZoneHandle` here on purpose: The intermediate language | 3881 // We return a new `ZoneHandle` here on purpose: The intermediate language |
| 3857 // instructions do not make a copy of the handle, so we do it. | 3882 // instructions do not make a copy of the handle, so we do it. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3993 } | 4018 } |
| 3994 | 4019 |
| 3995 | 4020 |
| 3996 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) { | 4021 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) { |
| 3997 // NOTE: That an interface type like `T<A, B>` is considered to be | 4022 // NOTE: That an interface type like `T<A, B>` is considered to be |
| 3998 // malformed iff `T` is malformed. | 4023 // malformed iff `T` is malformed. |
| 3999 // => We therefore ignore errors in `A` or `B`. | 4024 // => We therefore ignore errors in `A` or `B`. |
| 4000 const TypeArguments& type_arguments = TranslateTypeArguments( | 4025 const TypeArguments& type_arguments = TranslateTypeArguments( |
| 4001 node->type_arguments().raw_array(), node->type_arguments().length()); | 4026 node->type_arguments().raw_array(), node->type_arguments().length()); |
| 4002 | 4027 |
| 4003 const dart::Class& klass = | 4028 |
| 4004 dart::Class::Handle(Z, H.LookupClassByKernelClass(node->klass())); | 4029 dart::Object& klass = dart::Object::Handle(Z); |
| 4030 |
| 4031 if (finalize_) { |
| 4032 klass = H.LookupClassByKernelClass(node->klass()); |
| 4033 } else { |
| 4034 klass = H.ToUnresolvedClass(node->klass()); |
| 4035 } |
| 4036 |
| 4005 | 4037 |
| 4006 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource); | 4038 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource); |
| 4007 result_.SetIsResolved(); | |
| 4008 if (finalize_) { | 4039 if (finalize_) { |
| 4009 result_ = ClassFinalizer::FinalizeType(klass, result_, | 4040 result_.SetIsResolved(); |
| 4041 result_ = ClassFinalizer::FinalizeType(dart::Class::Cast(klass), result_, |
| 4010 ClassFinalizer::kCanonicalize); | 4042 ClassFinalizer::kCanonicalize); |
| 4011 } | 4043 } |
| 4012 } | 4044 } |
| 4013 | 4045 |
| 4014 | 4046 |
| 4015 void DartTypeTranslator::VisitDynamicType(DynamicType* node) { | 4047 void DartTypeTranslator::VisitDynamicType(DynamicType* node) { |
| 4016 result_ = Object::dynamic_type().raw(); | 4048 result_ = Object::dynamic_type().raw(); |
| 4017 } | 4049 } |
| 4018 | 4050 |
| 4019 | 4051 |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5626 // ... | 5658 // ... |
| 5627 // } | 5659 // } |
| 5628 // | 5660 // |
| 5629 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 5661 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 5630 LocalVariable* exception_var = scope->VariableAt(2); | 5662 LocalVariable* exception_var = scope->VariableAt(2); |
| 5631 LocalVariable* stack_trace_var = scope->VariableAt(3); | 5663 LocalVariable* stack_trace_var = scope->VariableAt(3); |
| 5632 ASSERT(exception_var->name().raw() == Symbols::ExceptionParameter().raw()); | 5664 ASSERT(exception_var->name().raw() == Symbols::ExceptionParameter().raw()); |
| 5633 ASSERT(stack_trace_var->name().raw() == | 5665 ASSERT(stack_trace_var->name().raw() == |
| 5634 Symbols::StackTraceParameter().raw()); | 5666 Symbols::StackTraceParameter().raw()); |
| 5635 | 5667 |
| 5636 exception_var->set_is_forced_stack(); | |
| 5637 stack_trace_var->set_is_forced_stack(); | |
| 5638 | |
| 5639 TargetEntryInstr* no_error; | 5668 TargetEntryInstr* no_error; |
| 5640 TargetEntryInstr* error; | 5669 TargetEntryInstr* error; |
| 5641 | 5670 |
| 5642 continuation += LoadLocal(exception_var); | 5671 continuation += LoadLocal(exception_var); |
| 5643 continuation += BranchIfNull(&no_error, &error); | 5672 continuation += BranchIfNull(&no_error, &error); |
| 5644 | 5673 |
| 5645 Fragment rethrow(error); | 5674 Fragment rethrow(error); |
| 5646 rethrow += LoadLocal(exception_var); | 5675 rethrow += LoadLocal(exception_var); |
| 5647 rethrow += PushArgument(); | 5676 rethrow += PushArgument(); |
| 5648 rethrow += LoadLocal(stack_trace_var); | 5677 rethrow += LoadLocal(stack_trace_var); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5718 instructions += LoadLocal(closure); | 5747 instructions += LoadLocal(closure); |
| 5719 instructions += LoadLocal(parsed_function_->current_context_var()); | 5748 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 5720 instructions += StoreInstanceField(Closure::context_offset()); | 5749 instructions += StoreInstanceField(Closure::context_offset()); |
| 5721 | 5750 |
| 5722 return instructions; | 5751 return instructions; |
| 5723 } | 5752 } |
| 5724 | 5753 |
| 5725 | 5754 |
| 5726 } // namespace kernel | 5755 } // namespace kernel |
| 5727 } // namespace dart | 5756 } // namespace dart |
| OLD | NEW |