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 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ | 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ |
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ | 6 #define RUNTIME_VM_KERNEL_TO_IL_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 | 9 |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 Fragment closed(); | 183 Fragment closed(); |
184 }; | 184 }; |
185 | 185 |
186 Fragment operator+(const Fragment& first, const Fragment& second); | 186 Fragment operator+(const Fragment& first, const Fragment& second); |
187 Fragment operator<<(const Fragment& fragment, Instruction* next); | 187 Fragment operator<<(const Fragment& fragment, Instruction* next); |
188 | 188 |
189 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; | 189 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; |
190 | 190 |
191 class ActiveClass { | 191 class ActiveClass { |
192 public: | 192 public: |
193 ActiveClass() | 193 ActiveClass() : klass(NULL), member(NULL) {} |
194 : kernel_class(NULL), | |
195 class_type_parameters(0), | |
196 class_type_parameters_offset_start(-1), | |
197 klass(NULL), | |
198 member_is_procedure(false), | |
199 member_is_factory_procedure(false), | |
200 member_type_parameters(0), | |
201 member_type_parameters_offset_start(-1) {} | |
202 | 194 |
203 // The current enclosing kernel class (if available, otherwise NULL). | 195 bool HasMember() { return member != NULL; } |
204 Class* kernel_class; | |
205 intptr_t class_type_parameters; | |
206 intptr_t class_type_parameters_offset_start; | |
207 | 196 |
208 // The current enclosing class (or the library top-level class). When this is | 197 bool MemberIsProcedure() { |
209 // a library's top-level class, the kernel_class will be NULL. | 198 ASSERT(member != NULL); |
| 199 RawFunction::Kind function_kind = member->kind(); |
| 200 return function_kind == RawFunction::kRegularFunction || |
| 201 function_kind == RawFunction::kGetterFunction || |
| 202 function_kind == RawFunction::kSetterFunction || |
| 203 function_kind == RawFunction::kMethodExtractor || |
| 204 member->IsFactory(); |
| 205 } |
| 206 |
| 207 bool MemberIsFactoryProcedure() { |
| 208 ASSERT(member != NULL); |
| 209 return member->IsFactory(); |
| 210 } |
| 211 |
| 212 intptr_t MemberTypeParameterCount(Zone* zone); |
| 213 |
| 214 intptr_t ClassTypeParameterCount(Zone* zone) { |
| 215 ASSERT(member != NULL); |
| 216 TypeArguments& class_types = |
| 217 dart::TypeArguments::Handle(zone, klass->type_parameters()); |
| 218 return class_types.Length(); |
| 219 } |
| 220 |
| 221 // The current enclosing class (or the library top-level class). |
210 const dart::Class* klass; | 222 const dart::Class* klass; |
211 | 223 |
212 bool member_is_procedure; | 224 const dart::Function* member; |
213 bool member_is_factory_procedure; | |
214 intptr_t member_type_parameters; | |
215 intptr_t member_type_parameters_offset_start; | |
216 }; | 225 }; |
217 | 226 |
218 class ActiveClassScope { | 227 class ActiveClassScope { |
219 public: | 228 public: |
220 ActiveClassScope(ActiveClass* active_class, | 229 ActiveClassScope(ActiveClass* active_class, const dart::Class* klass) |
221 intptr_t class_type_parameters, | |
222 intptr_t class_type_parameters_offset_start, | |
223 const dart::Class* klass) | |
224 : active_class_(active_class), saved_(*active_class) { | 230 : active_class_(active_class), saved_(*active_class) { |
225 active_class_->kernel_class = NULL; | |
226 active_class_->class_type_parameters = class_type_parameters; | |
227 active_class_->class_type_parameters_offset_start = | |
228 class_type_parameters_offset_start; | |
229 active_class_->klass = klass; | 231 active_class_->klass = klass; |
230 } | 232 } |
231 | 233 |
232 ~ActiveClassScope() { *active_class_ = saved_; } | 234 ~ActiveClassScope() { *active_class_ = saved_; } |
233 | 235 |
234 private: | 236 private: |
235 ActiveClass* active_class_; | 237 ActiveClass* active_class_; |
236 ActiveClass saved_; | 238 ActiveClass saved_; |
237 }; | 239 }; |
238 | 240 |
239 class ActiveMemberScope { | 241 class ActiveMemberScope { |
240 public: | 242 public: |
241 ActiveMemberScope(ActiveClass* active_class, | 243 ActiveMemberScope(ActiveClass* active_class, const Function* member) |
242 bool member_is_procedure, | |
243 bool member_is_factory_procedure, | |
244 intptr_t member_type_parameters, | |
245 intptr_t member_type_parameters_offset_start) | |
246 : active_class_(active_class), saved_(*active_class) { | 244 : active_class_(active_class), saved_(*active_class) { |
247 // The class and kernel_class is inherited. | 245 // The class is inherited. |
248 active_class_->member_is_procedure = member_is_procedure; | 246 active_class_->member = member; |
249 active_class_->member_is_factory_procedure = member_is_factory_procedure; | |
250 active_class_->member_type_parameters = member_type_parameters; | |
251 active_class_->member_type_parameters_offset_start = | |
252 member_type_parameters_offset_start; | |
253 } | 247 } |
254 | 248 |
255 ~ActiveMemberScope() { *active_class_ = saved_; } | 249 ~ActiveMemberScope() { *active_class_ = saved_; } |
256 | 250 |
257 private: | 251 private: |
258 ActiveClass* active_class_; | 252 ActiveClass* active_class_; |
259 ActiveClass saved_; | 253 ActiveClass saved_; |
260 }; | 254 }; |
261 | 255 |
262 class TranslationHelper { | 256 class TranslationHelper { |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 namespace kernel { | 947 namespace kernel { |
954 | 948 |
955 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 949 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
956 RawObject* BuildParameterDescriptor(const Function& function); | 950 RawObject* BuildParameterDescriptor(const Function& function); |
957 | 951 |
958 } // namespace kernel | 952 } // namespace kernel |
959 } // namespace dart | 953 } // namespace dart |
960 | 954 |
961 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 955 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
962 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 956 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
OLD | NEW |