Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: runtime/vm/kernel_to_il.h

Issue 2973633002: [kernel] Change how TypeParameterType is calculated. (Closed)
Patch Set: Rebased Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 MemberIsProcedure() {
204 Class* kernel_class; 196 if (member == NULL) return false;
Kevin Millikin (Google) 2017/08/08 14:08:51 This doesn't seem safe. I think if there is no me
jensj 2017/08/09 08:39:47 I've added as "HasMember" function, and guarded ca
205 intptr_t class_type_parameters; 197 RawFunction::Kind function_kind = member->kind();
206 intptr_t class_type_parameters_offset_start; 198 return function_kind == RawFunction::kRegularFunction ||
199 function_kind == RawFunction::kGetterFunction ||
200 function_kind == RawFunction::kSetterFunction ||
201 function_kind == RawFunction::kMethodExtractor ||
202 member->IsFactory();
203 }
207 204
208 // The current enclosing class (or the library top-level class). When this is 205 bool MemberIsFactoryProcedure() {
209 // a library's top-level class, the kernel_class will be NULL. 206 if (member == NULL) return false;
Kevin Millikin (Google) 2017/08/08 14:08:51 Likewise, I'm not sure this is safe.
jensj 2017/08/09 08:39:47 As above.
207 return member->IsFactory();
208 }
209
210 intptr_t MemberTypeParameterCount(Zone* zone) {
Kevin Millikin (Google) 2017/08/08 14:08:51 We don't need all this code in the header file, do
jensj 2017/08/09 08:39:47 I don't really care - but no, it doesn't have to b
211 if (member == NULL) return 0;
212 RawFunction::Kind function_kind = member->kind();
213 if (member->IsFactory()) {
214 TypeArguments& class_types =
215 dart::TypeArguments::Handle(zone, klass->type_parameters());
216 return class_types.Length();
217 } else if (function_kind == RawFunction::kMethodExtractor) {
Kevin Millikin (Google) 2017/08/08 14:08:51 member->IsMethodExtractor()
jensj 2017/08/09 08:39:47 Done.
218 Function& extracted =
219 Function::Handle(zone, member->extracted_method_closure());
220 TypeArguments& function_types =
221 dart::TypeArguments::Handle(zone, extracted.type_parameters());
222 return function_types.Length();
223 } else {
224 TypeArguments& function_types =
225 dart::TypeArguments::Handle(zone, member->type_parameters());
226 return function_types.Length();
227 }
228 }
229
230 intptr_t ClassTypeParameterCount(Zone* zone) {
231 if (klass == NULL) return 0;
232 TypeArguments& class_types =
233 dart::TypeArguments::Handle(zone, klass->type_parameters());
234 return class_types.Length();
235 }
236
237 // The current enclosing class (or the library top-level class).
210 const dart::Class* klass; 238 const dart::Class* klass;
211 239
212 bool member_is_procedure; 240 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 }; 241 };
217 242
218 class ActiveClassScope { 243 class ActiveClassScope {
219 public: 244 public:
220 ActiveClassScope(ActiveClass* active_class, 245 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) { 246 : 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; 247 active_class_->klass = klass;
230 } 248 }
231 249
232 ~ActiveClassScope() { *active_class_ = saved_; } 250 ~ActiveClassScope() { *active_class_ = saved_; }
233 251
234 private: 252 private:
235 ActiveClass* active_class_; 253 ActiveClass* active_class_;
236 ActiveClass saved_; 254 ActiveClass saved_;
237 }; 255 };
238 256
239 class ActiveMemberScope { 257 class ActiveMemberScope {
240 public: 258 public:
241 ActiveMemberScope(ActiveClass* active_class, 259 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) { 260 : active_class_(active_class), saved_(*active_class) {
247 // The class and kernel_class is inherited. 261 // The class is inherited.
248 active_class_->member_is_procedure = member_is_procedure; 262 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 } 263 }
254 264
255 ~ActiveMemberScope() { *active_class_ = saved_; } 265 ~ActiveMemberScope() { *active_class_ = saved_; }
256 266
257 private: 267 private:
258 ActiveClass* active_class_; 268 ActiveClass* active_class_;
259 ActiveClass saved_; 269 ActiveClass saved_;
260 }; 270 };
261 271
262 class TranslationHelper { 272 class TranslationHelper {
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 namespace kernel { 963 namespace kernel {
954 964
955 RawObject* EvaluateMetadata(const dart::Field& metadata_field); 965 RawObject* EvaluateMetadata(const dart::Field& metadata_field);
956 RawObject* BuildParameterDescriptor(const Function& function); 966 RawObject* BuildParameterDescriptor(const Function& function);
957 967
958 } // namespace kernel 968 } // namespace kernel
959 } // namespace dart 969 } // namespace dart
960 970
961 #endif // !defined(DART_PRECOMPILED_RUNTIME) 971 #endif // !defined(DART_PRECOMPILED_RUNTIME)
962 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 972 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698