| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 Fragment operator+(const Fragment& first, const Fragment& second); | 189 Fragment operator+(const Fragment& first, const Fragment& second); |
| 190 Fragment operator<<(const Fragment& fragment, Instruction* next); | 190 Fragment operator<<(const Fragment& fragment, Instruction* next); |
| 191 | 191 |
| 192 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; | 192 typedef ZoneGrowableArray<PushArgumentInstr*>* ArgumentArray; |
| 193 | 193 |
| 194 | 194 |
| 195 class ActiveClass { | 195 class ActiveClass { |
| 196 public: | 196 public: |
| 197 ActiveClass() | 197 ActiveClass() : klass(NULL), member(NULL) {} |
| 198 : kernel_class(NULL), | |
| 199 class_type_parameters(0), | |
| 200 class_type_parameters_offset_start(-1), | |
| 201 klass(NULL), | |
| 202 member_is_procedure(false), | |
| 203 member_is_factory_procedure(false), | |
| 204 member_type_parameters(0), | |
| 205 member_type_parameters_offset_start(-1) {} | |
| 206 | 198 |
| 207 // The current enclosing kernel class (if available, otherwise NULL). | 199 bool MemberIsProcedure() { |
| 208 Class* kernel_class; | 200 if (member == NULL) return false; |
| 209 intptr_t class_type_parameters; | 201 RawFunction::Kind function_kind = member->kind(); |
| 210 intptr_t class_type_parameters_offset_start; | 202 return function_kind == RawFunction::kRegularFunction || |
| 203 function_kind == RawFunction::kGetterFunction || |
| 204 function_kind == RawFunction::kSetterFunction || |
| 205 function_kind == RawFunction::kMethodExtractor || |
| 206 member->IsFactory(); |
| 207 } |
| 211 | 208 |
| 212 // The current enclosing class (or the library top-level class). When this is | 209 bool MemberIsFactoryProcedure() { |
| 213 // a library's top-level class, the kernel_class will be NULL. | 210 if (member == NULL) return false; |
| 211 return member->IsFactory(); |
| 212 } |
| 213 |
| 214 intptr_t MemberTypeParameterCount(Zone* zone) { |
| 215 if (member == NULL) return 0; |
| 216 RawFunction::Kind function_kind = member->kind(); |
| 217 if (member->IsFactory()) { |
| 218 TypeArguments& class_types = |
| 219 dart::TypeArguments::Handle(zone, klass->type_parameters()); |
| 220 return class_types.Length(); |
| 221 } else if (function_kind == RawFunction::kMethodExtractor) { |
| 222 Function& extracted = |
| 223 Function::Handle(zone, member->extracted_method_closure()); |
| 224 TypeArguments& function_types = |
| 225 dart::TypeArguments::Handle(zone, extracted.type_parameters()); |
| 226 return function_types.Length(); |
| 227 } else { |
| 228 TypeArguments& function_types = |
| 229 dart::TypeArguments::Handle(zone, member->type_parameters()); |
| 230 return function_types.Length(); |
| 231 } |
| 232 } |
| 233 |
| 234 intptr_t ClassTypeParameterCount(Zone* zone) { |
| 235 if (klass == NULL) return 0; |
| 236 TypeArguments& class_types = |
| 237 dart::TypeArguments::Handle(zone, klass->type_parameters()); |
| 238 return class_types.Length(); |
| 239 } |
| 240 |
| 241 // The current enclosing class (or the library top-level class). |
| 214 const dart::Class* klass; | 242 const dart::Class* klass; |
| 215 | 243 |
| 216 bool member_is_procedure; | 244 const dart::Function* member; |
| 217 bool member_is_factory_procedure; | |
| 218 intptr_t member_type_parameters; | |
| 219 intptr_t member_type_parameters_offset_start; | |
| 220 }; | 245 }; |
| 221 | 246 |
| 222 | 247 |
| 223 class ActiveClassScope { | 248 class ActiveClassScope { |
| 224 public: | 249 public: |
| 225 ActiveClassScope(ActiveClass* active_class, | 250 ActiveClassScope(ActiveClass* active_class, const dart::Class* klass) |
| 226 intptr_t class_type_parameters, | |
| 227 intptr_t class_type_parameters_offset_start, | |
| 228 const dart::Class* klass) | |
| 229 : active_class_(active_class), saved_(*active_class) { | 251 : active_class_(active_class), saved_(*active_class) { |
| 230 active_class_->kernel_class = NULL; | |
| 231 active_class_->class_type_parameters = class_type_parameters; | |
| 232 active_class_->class_type_parameters_offset_start = | |
| 233 class_type_parameters_offset_start; | |
| 234 active_class_->klass = klass; | 252 active_class_->klass = klass; |
| 235 } | 253 } |
| 236 | 254 |
| 237 ~ActiveClassScope() { *active_class_ = saved_; } | 255 ~ActiveClassScope() { *active_class_ = saved_; } |
| 238 | 256 |
| 239 private: | 257 private: |
| 240 ActiveClass* active_class_; | 258 ActiveClass* active_class_; |
| 241 ActiveClass saved_; | 259 ActiveClass saved_; |
| 242 }; | 260 }; |
| 243 | 261 |
| 244 | 262 |
| 245 class ActiveMemberScope { | 263 class ActiveMemberScope { |
| 246 public: | 264 public: |
| 247 ActiveMemberScope(ActiveClass* active_class, | 265 ActiveMemberScope(ActiveClass* active_class, const Function* member) |
| 248 bool member_is_procedure, | |
| 249 bool member_is_factory_procedure, | |
| 250 intptr_t member_type_parameters, | |
| 251 intptr_t member_type_parameters_offset_start) | |
| 252 : active_class_(active_class), saved_(*active_class) { | 266 : active_class_(active_class), saved_(*active_class) { |
| 253 // The class and kernel_class is inherited. | 267 // The class is inherited. |
| 254 active_class_->member_is_procedure = member_is_procedure; | 268 active_class_->member = member; |
| 255 active_class_->member_is_factory_procedure = member_is_factory_procedure; | |
| 256 active_class_->member_type_parameters = member_type_parameters; | |
| 257 active_class_->member_type_parameters_offset_start = | |
| 258 member_type_parameters_offset_start; | |
| 259 } | 269 } |
| 260 | 270 |
| 261 ~ActiveMemberScope() { *active_class_ = saved_; } | 271 ~ActiveMemberScope() { *active_class_ = saved_; } |
| 262 | 272 |
| 263 private: | 273 private: |
| 264 ActiveClass* active_class_; | 274 ActiveClass* active_class_; |
| 265 ActiveClass saved_; | 275 ActiveClass saved_; |
| 266 }; | 276 }; |
| 267 | 277 |
| 268 | 278 |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 namespace kernel { | 976 namespace kernel { |
| 967 | 977 |
| 968 RawObject* EvaluateMetadata(const dart::Field& metadata_field); | 978 RawObject* EvaluateMetadata(const dart::Field& metadata_field); |
| 969 RawObject* BuildParameterDescriptor(const Function& function); | 979 RawObject* BuildParameterDescriptor(const Function& function); |
| 970 | 980 |
| 971 } // namespace kernel | 981 } // namespace kernel |
| 972 } // namespace dart | 982 } // namespace dart |
| 973 | 983 |
| 974 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 984 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 975 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ | 985 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ |
| OLD | NEW |