| 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_reader.h" | 5 #include "vm/kernel_reader.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 // Load all classes. | 219 // Load all classes. |
| 220 for (intptr_t i = 0; i < kernel_library->classes().length(); i++) { | 220 for (intptr_t i = 0; i < kernel_library->classes().length(); i++) { |
| 221 Class* kernel_klass = kernel_library->classes()[i]; | 221 Class* kernel_klass = kernel_library->classes()[i]; |
| 222 ReadClass(library, kernel_klass); | 222 ReadClass(library, kernel_klass); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 void KernelReader::ReadPreliminaryClass(dart::Class* klass, | 226 void KernelReader::ReadPreliminaryClass(dart::Class* klass, |
| 227 Class* kernel_klass) { | 227 Class* kernel_klass) { |
| 228 ASSERT(kernel_klass->IsNormalClass()); |
| 229 NormalClass* kernel_normal_class = NormalClass::Cast(kernel_klass); |
| 230 |
| 228 ActiveClassScope active_class_scope(&active_class_, kernel_klass, klass); | 231 ActiveClassScope active_class_scope(&active_class_, kernel_klass, klass); |
| 229 | 232 |
| 230 // First setup the type parameters, so if any of the following code uses it | 233 // First setup the type parameters, so if any of the following code uses it |
| 231 // (in a recursive way) we're fine. | 234 // (in a recursive way) we're fine. |
| 232 TypeArguments& type_parameters = | 235 TypeArguments& type_parameters = |
| 233 TypeArguments::Handle(Z, TypeArguments::null()); | 236 TypeArguments::Handle(Z, TypeArguments::null()); |
| 234 intptr_t num_type_parameters = kernel_klass->type_parameters().length(); | 237 intptr_t num_type_parameters = kernel_klass->type_parameters().length(); |
| 235 if (num_type_parameters > 0) { | 238 if (num_type_parameters > 0) { |
| 236 dart::TypeParameter& parameter = dart::TypeParameter::Handle(Z); | 239 dart::TypeParameter& parameter = dart::TypeParameter::Handle(Z); |
| 237 Type& null_bound = Type::Handle(Z, Type::null()); | 240 Type& null_bound = Type::Handle(Z, Type::null()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 261 if (bound.IsMalformedOrMalbounded()) { | 264 if (bound.IsMalformedOrMalbounded()) { |
| 262 bound = I->object_store()->object_type(); | 265 bound = I->object_store()->object_type(); |
| 263 } | 266 } |
| 264 | 267 |
| 265 parameter ^= type_parameters.TypeAt(i); | 268 parameter ^= type_parameters.TypeAt(i); |
| 266 parameter.set_bound(bound); | 269 parameter.set_bound(bound); |
| 267 } | 270 } |
| 268 } | 271 } |
| 269 } | 272 } |
| 270 | 273 |
| 271 if (kernel_klass->IsNormalClass()) { | 274 // Set super type. Some classes (e.g., Object) do not have one. |
| 272 NormalClass* kernel_normal_class = NormalClass::Cast(kernel_klass); | 275 if (kernel_normal_class->super_class() != NULL) { |
| 273 | 276 AbstractType& super_type = T.TranslateTypeWithoutFinalization( |
| 274 // Set super type. Some classes (e.g., Object) do not have one. | 277 kernel_normal_class->super_class()); |
| 275 if (kernel_normal_class->super_class() != NULL) { | 278 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); |
| 276 AbstractType& super_type = T.TranslateTypeWithoutFinalization( | |
| 277 kernel_normal_class->super_class()); | |
| 278 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); | |
| 279 klass->set_super_type(super_type); | |
| 280 } | |
| 281 } else { | |
| 282 MixinClass* kernel_mixin = MixinClass::Cast(kernel_klass); | |
| 283 | |
| 284 // Set super type. | |
| 285 AbstractType& super_type = | |
| 286 T.TranslateTypeWithoutFinalization(kernel_mixin->first()); | |
| 287 if (super_type.IsMalformed()) H.ReportError("Malformed super type."); | |
| 288 klass->set_super_type(super_type); | 279 klass->set_super_type(super_type); |
| 289 | |
| 290 // Tell the rest of the system there is nothing to resolve. | |
| 291 super_type.SetIsResolved(); | |
| 292 | |
| 293 // Set mixin type. | |
| 294 AbstractType& mixin_type = | |
| 295 T.TranslateTypeWithoutFinalization(kernel_mixin->second()); | |
| 296 if (mixin_type.IsMalformed()) H.ReportError("Malformed mixin type."); | |
| 297 klass->set_mixin(Type::Cast(mixin_type)); | |
| 298 } | 280 } |
| 299 | 281 |
| 300 // Build implemented interface types | 282 // Build implemented interface types |
| 301 intptr_t interface_count = kernel_klass->implemented_classes().length(); | 283 intptr_t interface_count = kernel_klass->implemented_classes().length(); |
| 302 const dart::Array& interfaces = | 284 const dart::Array& interfaces = |
| 303 dart::Array::Handle(Z, dart::Array::New(interface_count)); | 285 dart::Array::Handle(Z, dart::Array::New(interface_count)); |
| 304 dart::Class& interface_class = dart::Class::Handle(Z); | 286 dart::Class& interface_class = dart::Class::Handle(Z); |
| 305 for (intptr_t i = 0; i < interface_count; i++) { | 287 for (intptr_t i = 0; i < interface_count; i++) { |
| 306 InterfaceType* kernel_interface_type = | 288 InterfaceType* kernel_interface_type = |
| 307 kernel_klass->implemented_classes()[i]; | 289 kernel_klass->implemented_classes()[i]; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 if (kind == Procedure::kIncompleteProcedure) { | 689 if (kind == Procedure::kIncompleteProcedure) { |
| 708 return RawFunction::kSignatureFunction; | 690 return RawFunction::kSignatureFunction; |
| 709 } else { | 691 } else { |
| 710 ASSERT(0 <= kind && kind <= Procedure::kFactory); | 692 ASSERT(0 <= kind && kind <= Procedure::kFactory); |
| 711 return static_cast<RawFunction::Kind>(lookuptable[kind]); | 693 return static_cast<RawFunction::Kind>(lookuptable[kind]); |
| 712 } | 694 } |
| 713 } | 695 } |
| 714 | 696 |
| 715 } // namespace kernel | 697 } // namespace kernel |
| 716 } // namespace dart | 698 } // namespace dart |
| OLD | NEW |