Chromium Code Reviews| 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 "vm/kernel_binary_flowgraph.h" | 5 #include "vm/kernel_binary_flowgraph.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/longjump.h" | 8 #include "vm/longjump.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 | 10 |
| (...skipping 2906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2917 instructions += LoadLocal(scopes()->this_variable); | 2917 instructions += LoadLocal(scopes()->this_variable); |
| 2918 instructions += BuildExpression(); | 2918 instructions += BuildExpression(); |
| 2919 instructions += flow_graph_builder_->StoreInstanceFieldGuarded(field, true); | 2919 instructions += flow_graph_builder_->StoreInstanceFieldGuarded(field, true); |
| 2920 return instructions; | 2920 return instructions; |
| 2921 } | 2921 } |
| 2922 | 2922 |
| 2923 Fragment StreamingFlowGraphBuilder::BuildInitializers( | 2923 Fragment StreamingFlowGraphBuilder::BuildInitializers( |
| 2924 intptr_t constructor_class_parent_offset) { | 2924 intptr_t constructor_class_parent_offset) { |
| 2925 Fragment instructions; | 2925 Fragment instructions; |
| 2926 | 2926 |
| 2927 // Start by getting the position of the constructors initializer. | |
| 2928 intptr_t initializers_offset = -1; | |
| 2929 { | |
| 2930 AlternativeReadingScope alt(reader_); | |
| 2931 SkipFunctionNode(); // read constructors function node. | |
| 2932 initializers_offset = ReaderOffset(); | |
| 2933 } | |
| 2934 | |
| 2927 // These come from: | 2935 // These come from: |
| 2928 // class A { | 2936 // class A { |
| 2929 // var x = (expr); | 2937 // var x = (expr); |
| 2930 // } | 2938 // } |
| 2939 // We don't want to do that when this is a Redirecting Constructors though | |
| 2940 // (i.e. has a single initializer being of type kRedirectingInitializer). | |
| 2941 bool is_redirecting_constructor = false; | |
| 2931 { | 2942 { |
| 2943 AlternativeReadingScope alt(reader_, initializers_offset); | |
| 2944 intptr_t list_length = ReadListLength(); // read initializers list length. | |
| 2945 if (list_length == 1) { | |
| 2946 Tag tag = ReadTag(); | |
| 2947 if (tag == kRedirectingInitializer) is_redirecting_constructor = true; | |
| 2948 } | |
| 2949 } | |
| 2950 | |
| 2951 if (!is_redirecting_constructor) { | |
| 2932 AlternativeReadingScope alt(reader_, constructor_class_parent_offset); | 2952 AlternativeReadingScope alt(reader_, constructor_class_parent_offset); |
| 2933 ReadClassUntilFields(); // read first part of class. | 2953 ReadClassUntilFields(); // read first part of class. |
| 2934 intptr_t list_length = ReadListLength(); // read fields list length. | 2954 intptr_t list_length = ReadListLength(); // read fields list length. |
| 2935 | 2955 |
| 2936 for (intptr_t i = 0; i < list_length; ++i) { | 2956 for (intptr_t i = 0; i < list_length; ++i) { |
| 2937 intptr_t field_offset = ReaderOffset(); | 2957 intptr_t field_offset = ReaderOffset(); |
| 2938 NameIndex canonical_name; | 2958 NameIndex canonical_name; |
| 2939 TokenPosition position; | 2959 TokenPosition position; |
| 2940 TokenPosition end_position; | 2960 TokenPosition end_position; |
| 2941 word flags; | 2961 word flags; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2956 } | 2976 } |
| 2957 } | 2977 } |
| 2958 | 2978 |
| 2959 // These to come from: | 2979 // These to come from: |
| 2960 // class A { | 2980 // class A { |
| 2961 // var x; | 2981 // var x; |
| 2962 // var y; | 2982 // var y; |
| 2963 // A(this.x) : super(expr), y = (expr); | 2983 // A(this.x) : super(expr), y = (expr); |
| 2964 // } | 2984 // } |
| 2965 { | 2985 { |
| 2966 AlternativeReadingScope alt(reader_); | 2986 AlternativeReadingScope alt(reader_, initializers_offset); |
| 2967 SkipFunctionNode(); // read constructors function node. | |
| 2968 | |
| 2969 intptr_t list_length = ReadListLength(); // read initializers list length. | 2987 intptr_t list_length = ReadListLength(); // read initializers list length. |
| 2970 for (intptr_t i = 0; i < list_length; ++i) { | 2988 for (intptr_t i = 0; i < list_length; ++i) { |
| 2971 Tag tag = ReadTag(); | 2989 Tag tag = ReadTag(); |
| 2972 switch (tag) { | 2990 switch (tag) { |
| 2973 case kInvalidInitializer: | 2991 case kInvalidInitializer: |
| 2974 UNIMPLEMENTED(); | 2992 UNIMPLEMENTED(); |
| 2975 return Fragment(); | 2993 return Fragment(); |
| 2976 case kFieldInitializer: { | 2994 case kFieldInitializer: { |
| 2977 NameIndex canonical_name = | 2995 NameIndex canonical_name = |
| 2978 ReadCanonicalNameReference(); // read field_reference. | 2996 ReadCanonicalNameReference(); // read field_reference. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2994 argument_count += 1; | 3012 argument_count += 1; |
| 2995 | 3013 |
| 2996 const Function& target = Function::ZoneHandle( | 3014 const Function& target = Function::ZoneHandle( |
| 2997 Z, H.LookupConstructorByKernelConstructor(canonical_target)); | 3015 Z, H.LookupConstructorByKernelConstructor(canonical_target)); |
| 2998 instructions += StaticCall(TokenPosition::kNoSource, target, | 3016 instructions += StaticCall(TokenPosition::kNoSource, target, |
| 2999 argument_count, argument_names); | 3017 argument_count, argument_names); |
| 3000 instructions += Drop(); | 3018 instructions += Drop(); |
| 3001 break; | 3019 break; |
| 3002 } | 3020 } |
| 3003 case kRedirectingInitializer: { | 3021 case kRedirectingInitializer: { |
| 3004 NameIndex canonical_target = | 3022 NameIndex canonical_target = |
|
Vyacheslav Egorov (Google)
2017/06/16 11:14:28
ASSERT(list_length == 1) here
| |
| 3005 ReadCanonicalNameReference(); // read target_reference. | 3023 ReadCanonicalNameReference(); // read target_reference. |
| 3006 | 3024 |
| 3007 instructions += LoadLocal(scopes()->this_variable); | 3025 instructions += LoadLocal(scopes()->this_variable); |
| 3008 instructions += PushArgument(); | 3026 instructions += PushArgument(); |
| 3009 | 3027 |
| 3010 // TODO(jensj): ASSERT(init->arguments()->types().length() == 0); | 3028 // TODO(jensj): ASSERT(init->arguments()->types().length() == 0); |
| 3011 Array& argument_names = Array::ZoneHandle(Z); | 3029 Array& argument_names = Array::ZoneHandle(Z); |
| 3012 intptr_t argument_count; | 3030 intptr_t argument_count; |
| 3013 instructions += BuildArguments(&argument_names, | 3031 instructions += BuildArguments(&argument_names, |
| 3014 &argument_count); // read arguments. | 3032 &argument_count); // read arguments. |
| (...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7150 metadata_values.SetAt(i, value); | 7168 metadata_values.SetAt(i, value); |
| 7151 } | 7169 } |
| 7152 | 7170 |
| 7153 return metadata_values.raw(); | 7171 return metadata_values.raw(); |
| 7154 } | 7172 } |
| 7155 | 7173 |
| 7156 } // namespace kernel | 7174 } // namespace kernel |
| 7157 } // namespace dart | 7175 } // namespace dart |
| 7158 | 7176 |
| 7159 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7177 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |