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/kernel_binary.h" | 10 #include "vm/kernel_binary.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 library_helper.ReadUntilExcluding(LibraryHelper::kClasses); | 250 library_helper.ReadUntilExcluding(LibraryHelper::kClasses); |
251 | 251 |
252 // Load all classes. | 252 // Load all classes. |
253 int class_count = builder_.ReadListLength(); // read list length. | 253 int class_count = builder_.ReadListLength(); // read list length. |
254 for (intptr_t i = 0; i < class_count; ++i) { | 254 for (intptr_t i = 0; i < class_count; ++i) { |
255 classes.Add(ReadClass(library, toplevel_class), Heap::kOld); | 255 classes.Add(ReadClass(library, toplevel_class), Heap::kOld); |
256 } | 256 } |
257 | 257 |
258 fields_.Clear(); | 258 fields_.Clear(); |
259 functions_.Clear(); | 259 functions_.Clear(); |
260 ActiveClassScope active_class_scope(&active_class_, 0, -1, &toplevel_class); | 260 ActiveClassScope active_class_scope(&active_class_, &toplevel_class); |
261 // Load toplevel fields. | 261 // Load toplevel fields. |
262 intptr_t field_count = builder_.ReadListLength(); // read list length. | 262 intptr_t field_count = builder_.ReadListLength(); // read list length. |
263 for (intptr_t i = 0; i < field_count; ++i) { | 263 for (intptr_t i = 0; i < field_count; ++i) { |
264 intptr_t field_offset = builder_.ReaderOffset(); | 264 intptr_t field_offset = builder_.ReaderOffset(); |
265 ActiveMemberScope active_member_scope(&active_class_, false, false, 0, -1); | 265 ActiveMemberScope active_member_scope(&active_class_, NULL); |
266 FieldHelper field_helper(&builder_); | 266 FieldHelper field_helper(&builder_); |
267 field_helper.ReadUntilExcluding(FieldHelper::kName); | 267 field_helper.ReadUntilExcluding(FieldHelper::kName); |
268 | 268 |
269 const dart::String& name = builder_.ReadNameAsFieldName(); | 269 const dart::String& name = builder_.ReadNameAsFieldName(); |
270 field_helper.SetJustRead(FieldHelper::kName); | 270 field_helper.SetJustRead(FieldHelper::kName); |
271 field_helper.ReadUntilExcluding(FieldHelper::kType); | 271 field_helper.ReadUntilExcluding(FieldHelper::kType); |
272 const Object& script_class = | 272 const Object& script_class = |
273 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_); | 273 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_); |
274 dart::Field& field = dart::Field::Handle( | 274 dart::Field& field = dart::Field::Handle( |
275 Z, dart::Field::NewTopLevel(name, field_helper.IsFinal(), | 275 Z, dart::Field::NewTopLevel(name, field_helper.IsFinal(), |
(...skipping 27 matching lines...) Expand all Loading... | |
303 } | 303 } |
304 | 304 |
305 void KernelReader::ReadPreliminaryClass(dart::Class* klass, | 305 void KernelReader::ReadPreliminaryClass(dart::Class* klass, |
306 ClassHelper* class_helper, | 306 ClassHelper* class_helper, |
307 intptr_t type_parameter_count) { | 307 intptr_t type_parameter_count) { |
308 // Note: This assumes that ClassHelper is exactly at the position where | 308 // Note: This assumes that ClassHelper is exactly at the position where |
309 // the length of the type parameters have been read, and that the order in | 309 // the length of the type parameters have been read, and that the order in |
310 // the binary is as follows: [...], kTypeParameters, kSuperClass, kMixinType, | 310 // the binary is as follows: [...], kTypeParameters, kSuperClass, kMixinType, |
311 // kImplementedClasses, [...]. | 311 // kImplementedClasses, [...]. |
312 | 312 |
313 // First setup the type parameters, so if any of the following code uses it | 313 // Set type parameters. |
314 // (in a recursive way) we're fine. | 314 ReadAndSetupTypeParameters(klass, type_parameter_count, *klass, |
315 TypeArguments& type_parameters = | 315 Function::Handle(Z)); |
316 TypeArguments::Handle(Z, TypeArguments::null()); | |
317 if (type_parameter_count > 0) { | |
318 dart::TypeParameter& parameter = dart::TypeParameter::Handle(Z); | |
319 Type& null_bound = Type::Handle(Z, Type::null()); | |
320 | |
321 // Step a) Create array of [TypeParameter] objects (without bound). | |
322 type_parameters = TypeArguments::New(type_parameter_count); | |
323 { | |
324 AlternativeReadingScope alt(builder_.reader_); | |
325 for (intptr_t i = 0; i < type_parameter_count; i++) { | |
326 parameter = dart::TypeParameter::New( | |
327 *klass, Function::Handle(Z), i, | |
328 H.DartSymbol( | |
329 builder_.ReadStringReference()), // read ith name index. | |
330 null_bound, TokenPosition::kNoSource); | |
331 type_parameters.SetTypeAt(i, parameter); | |
332 builder_.SkipDartType(); // read guard. | |
333 } | |
334 } | |
335 klass->set_type_parameters(type_parameters); | |
336 | |
337 // Step b) Fill in the bounds of all [TypeParameter]s. | |
338 for (intptr_t i = 0; i < type_parameter_count; i++) { | |
339 builder_.SkipStringReference(); // read ith name index. | |
340 | |
341 // TODO(github.com/dart-lang/kernel/issues/42): This should be handled | |
342 // by the frontend. | |
343 parameter ^= type_parameters.TypeAt(i); | |
344 Tag tag = builder_.PeekTag(); // peek ith bound type. | |
345 if (tag == kDynamicType) { | |
346 builder_.SkipDartType(); // read ith bound. | |
347 parameter.set_bound(Type::Handle(Z, I->object_store()->object_type())); | |
348 } else { | |
349 AbstractType& bound = | |
350 T.BuildTypeWithoutFinalization(); // read ith bound. | |
351 if (bound.IsMalformedOrMalbounded()) { | |
352 bound = I->object_store()->object_type(); | |
353 } | |
354 parameter.set_bound(bound); | |
355 } | |
356 } | |
357 } | |
358 | 316 |
359 // Set super type. Some classes (e.g., Object) do not have one. | 317 // Set super type. Some classes (e.g., Object) do not have one. |
360 Tag type_tag = builder_.ReadTag(); // read super class type (part 1). | 318 Tag type_tag = builder_.ReadTag(); // read super class type (part 1). |
361 if (type_tag == kSomething) { | 319 if (type_tag == kSomething) { |
362 AbstractType& super_type = | 320 AbstractType& super_type = |
363 T.BuildTypeWithoutFinalization(); // read super class type (part 2). | 321 T.BuildTypeWithoutFinalization(); // read super class type (part 2). |
364 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); | 322 if (super_type.IsMalformed()) H.ReportError("Malformed super type"); |
365 klass->set_super_type(super_type); | 323 klass->set_super_type(super_type); |
366 } | 324 } |
367 | 325 |
(...skipping 29 matching lines...) Expand all Loading... | |
397 if (klass.script() == Script::null()) { | 355 if (klass.script() == Script::null()) { |
398 class_helper.ReadUntilIncluding(ClassHelper::kSourceUriIndex); | 356 class_helper.ReadUntilIncluding(ClassHelper::kSourceUriIndex); |
399 klass.set_script(ScriptAt(class_helper.source_uri_index_)); | 357 klass.set_script(ScriptAt(class_helper.source_uri_index_)); |
400 } | 358 } |
401 if (klass.token_pos() == TokenPosition::kNoSource) { | 359 if (klass.token_pos() == TokenPosition::kNoSource) { |
402 class_helper.ReadUntilIncluding(ClassHelper::kPosition); | 360 class_helper.ReadUntilIncluding(ClassHelper::kPosition); |
403 klass.set_token_pos(class_helper.position_); | 361 klass.set_token_pos(class_helper.position_); |
404 } | 362 } |
405 | 363 |
406 class_helper.ReadUntilExcluding(ClassHelper::kTypeParameters); | 364 class_helper.ReadUntilExcluding(ClassHelper::kTypeParameters); |
407 intptr_t type_paremeter_counts = | 365 intptr_t type_parameter_counts = |
408 builder_.ReadListLength(); // read type_parameters list length. | 366 builder_.ReadListLength(); // read type_parameters list length. |
409 intptr_t type_paremeter_offset = builder_.ReaderOffset(); | |
410 | 367 |
411 ActiveClassScope active_class_scope(&active_class_, type_paremeter_counts, | 368 ActiveClassScope active_class_scope(&active_class_, &klass); |
412 type_paremeter_offset, &klass); | |
413 if (!klass.is_cycle_free()) { | 369 if (!klass.is_cycle_free()) { |
414 ReadPreliminaryClass(&klass, &class_helper, type_paremeter_counts); | 370 ReadPreliminaryClass(&klass, &class_helper, type_parameter_counts); |
415 } else { | 371 } else { |
416 for (intptr_t i = 0; i < type_paremeter_counts; ++i) { | 372 for (intptr_t i = 0; i < type_parameter_counts; ++i) { |
417 builder_.SkipStringReference(); // read ith name index. | 373 builder_.SkipStringReference(); // read ith name index. |
418 builder_.SkipDartType(); // read ith bound. | 374 builder_.SkipDartType(); // read ith bound. |
419 } | 375 } |
420 class_helper.SetJustRead(ClassHelper::kTypeParameters); | 376 class_helper.SetJustRead(ClassHelper::kTypeParameters); |
421 } | 377 } |
422 | 378 |
423 fields_.Clear(); | 379 fields_.Clear(); |
424 functions_.Clear(); | 380 functions_.Clear(); |
425 | 381 |
426 if (library.raw() == dart::Library::InternalLibrary() && | 382 if (library.raw() == dart::Library::InternalLibrary() && |
427 klass.Name() == Symbols::ClassID().raw()) { | 383 klass.Name() == Symbols::ClassID().raw()) { |
428 // If this is a dart:internal.ClassID class ignore field declarations | 384 // If this is a dart:internal.ClassID class ignore field declarations |
429 // contained in the Kernel file and instead inject our own const | 385 // contained in the Kernel file and instead inject our own const |
430 // fields. | 386 // fields. |
431 klass.InjectCIDFields(); | 387 klass.InjectCIDFields(); |
432 } else { | 388 } else { |
433 class_helper.ReadUntilExcluding(ClassHelper::kFields); | 389 class_helper.ReadUntilExcluding(ClassHelper::kFields); |
434 int field_count = builder_.ReadListLength(); // read list length. | 390 int field_count = builder_.ReadListLength(); // read list length. |
435 for (intptr_t i = 0; i < field_count; ++i) { | 391 for (intptr_t i = 0; i < field_count; ++i) { |
436 intptr_t field_offset = builder_.ReaderOffset(); | 392 intptr_t field_offset = builder_.ReaderOffset(); |
437 ActiveMemberScope active_member(&active_class_, false, false, 0, -1); | 393 ActiveMemberScope active_member(&active_class_, NULL); |
438 FieldHelper field_helper(&builder_); | 394 FieldHelper field_helper(&builder_); |
439 field_helper.ReadUntilExcluding(FieldHelper::kName); | 395 field_helper.ReadUntilExcluding(FieldHelper::kName); |
440 | 396 |
441 const dart::String& name = builder_.ReadNameAsFieldName(); | 397 const dart::String& name = builder_.ReadNameAsFieldName(); |
442 field_helper.SetJustRead(FieldHelper::kName); | 398 field_helper.SetJustRead(FieldHelper::kName); |
443 field_helper.ReadUntilExcluding(FieldHelper::kType); | 399 field_helper.ReadUntilExcluding(FieldHelper::kType); |
444 const AbstractType& type = | 400 const AbstractType& type = |
445 T.BuildTypeWithoutFinalization(); // read type. | 401 T.BuildTypeWithoutFinalization(); // read type. |
446 field_helper.SetJustRead(FieldHelper::kType); | 402 field_helper.SetJustRead(FieldHelper::kType); |
447 const Object& script_class = | 403 const Object& script_class = |
(...skipping 22 matching lines...) Expand all Loading... | |
470 fields_.Add(&field); | 426 fields_.Add(&field); |
471 } | 427 } |
472 klass.AddFields(fields_); | 428 klass.AddFields(fields_); |
473 class_helper.SetJustRead(ClassHelper::kFields); | 429 class_helper.SetJustRead(ClassHelper::kFields); |
474 } | 430 } |
475 | 431 |
476 class_helper.ReadUntilExcluding(ClassHelper::kConstructors); | 432 class_helper.ReadUntilExcluding(ClassHelper::kConstructors); |
477 int constructor_count = builder_.ReadListLength(); // read list length. | 433 int constructor_count = builder_.ReadListLength(); // read list length. |
478 for (intptr_t i = 0; i < constructor_count; ++i) { | 434 for (intptr_t i = 0; i < constructor_count; ++i) { |
479 intptr_t constructor_offset = builder_.ReaderOffset(); | 435 intptr_t constructor_offset = builder_.ReaderOffset(); |
480 ActiveMemberScope active_member_scope(&active_class_, false, false, 0, -1); | 436 ActiveMemberScope active_member_scope(&active_class_, NULL); |
481 ConstructorHelper constructor_helper(&builder_); | 437 ConstructorHelper constructor_helper(&builder_); |
482 constructor_helper.ReadUntilExcluding(ConstructorHelper::kFunction); | 438 constructor_helper.ReadUntilExcluding(ConstructorHelper::kFunction); |
483 | 439 |
484 const dart::String& name = | 440 const dart::String& name = |
485 H.DartConstructorName(constructor_helper.canonical_name_); | 441 H.DartConstructorName(constructor_helper.canonical_name_); |
486 Function& function = dart::Function::ZoneHandle( | 442 Function& function = dart::Function::ZoneHandle( |
487 Z, dart::Function::New(name, RawFunction::kConstructor, | 443 Z, dart::Function::New(name, RawFunction::kConstructor, |
488 false, // is_static | 444 false, // is_static |
489 constructor_helper.IsConst(), | 445 constructor_helper.IsConst(), |
490 false, // is_abstract | 446 false, // is_abstract |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 | 492 |
537 return klass; | 493 return klass; |
538 } | 494 } |
539 | 495 |
540 void KernelReader::ReadProcedure(const dart::Library& library, | 496 void KernelReader::ReadProcedure(const dart::Library& library, |
541 const dart::Class& owner, | 497 const dart::Class& owner, |
542 bool in_class) { | 498 bool in_class) { |
543 intptr_t procedure_offset = builder_.ReaderOffset(); | 499 intptr_t procedure_offset = builder_.ReaderOffset(); |
544 ProcedureHelper procedure_helper(&builder_); | 500 ProcedureHelper procedure_helper(&builder_); |
545 | 501 |
546 bool member_is_procedure = false; | |
547 bool is_factory_procedure = false; | |
548 intptr_t member_type_parameters = 0; | |
549 intptr_t member_type_parameters_offset_start = -1; | |
550 builder_.GetTypeParameterInfoForPossibleProcedure( | |
551 builder_.ReaderOffset(), &member_is_procedure, &is_factory_procedure, | |
552 &member_type_parameters, &member_type_parameters_offset_start); | |
553 | |
554 ActiveMemberScope active_member(&active_class_, member_is_procedure, | |
555 is_factory_procedure, member_type_parameters, | |
556 member_type_parameters_offset_start); | |
557 | |
558 procedure_helper.ReadUntilExcluding(ProcedureHelper::kAnnotations); | 502 procedure_helper.ReadUntilExcluding(ProcedureHelper::kAnnotations); |
559 const dart::String& name = | 503 const dart::String& name = |
560 H.DartProcedureName(procedure_helper.canonical_name_); | 504 H.DartProcedureName(procedure_helper.canonical_name_); |
561 bool is_method = in_class && !procedure_helper.IsStatic(); | 505 bool is_method = in_class && !procedure_helper.IsStatic(); |
562 bool is_abstract = procedure_helper.IsAbstract(); | 506 bool is_abstract = procedure_helper.IsAbstract(); |
563 bool is_external = procedure_helper.IsExternal(); | 507 bool is_external = procedure_helper.IsExternal(); |
564 dart::String* native_name = NULL; | 508 dart::String* native_name = NULL; |
565 intptr_t annotation_count; | 509 intptr_t annotation_count; |
566 if (is_external) { | 510 if (is_external) { |
567 // Maybe it has a native implementation, which is not external as far as | 511 // Maybe it has a native implementation, which is not external as far as |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 Z, Function::New(name, GetFunctionType(procedure_helper.kind_), | 571 Z, Function::New(name, GetFunctionType(procedure_helper.kind_), |
628 !is_method, // is_static | 572 !is_method, // is_static |
629 false, // is_const | 573 false, // is_const |
630 is_abstract, is_external, | 574 is_abstract, is_external, |
631 native_name != NULL, // is_native | 575 native_name != NULL, // is_native |
632 script_class, procedure_helper.position_)); | 576 script_class, procedure_helper.position_)); |
633 function.set_end_token_pos(procedure_helper.end_position_); | 577 function.set_end_token_pos(procedure_helper.end_position_); |
634 functions_.Add(&function); | 578 functions_.Add(&function); |
635 function.set_kernel_offset(procedure_offset); | 579 function.set_kernel_offset(procedure_offset); |
636 | 580 |
581 ActiveMemberScope active_member(&active_class_, &function); | |
582 | |
637 procedure_helper.ReadUntilExcluding(ProcedureHelper::kFunction); | 583 procedure_helper.ReadUntilExcluding(ProcedureHelper::kFunction); |
638 Tag function_node_tag = builder_.ReadTag(); | 584 Tag function_node_tag = builder_.ReadTag(); |
639 ASSERT(function_node_tag == kSomething); | 585 ASSERT(function_node_tag == kSomething); |
640 FunctionNodeHelper function_node_helper(&builder_); | 586 FunctionNodeHelper function_node_helper(&builder_); |
641 function_node_helper.ReadUntilIncluding(FunctionNodeHelper::kDartAsyncMarker); | 587 function_node_helper.ReadUntilIncluding(FunctionNodeHelper::kDartAsyncMarker); |
642 function.set_is_debuggable(function_node_helper.dart_async_marker_ == | 588 function.set_is_debuggable(function_node_helper.dart_async_marker_ == |
643 FunctionNode::kSync); | 589 FunctionNode::kSync); |
644 switch (function_node_helper.dart_async_marker_) { | 590 switch (function_node_helper.dart_async_marker_) { |
645 case FunctionNode::kSyncStar: | 591 case FunctionNode::kSyncStar: |
646 function.set_modifier(RawFunction::kSyncGen); | 592 function.set_modifier(RawFunction::kSyncGen); |
647 break; | 593 break; |
648 case FunctionNode::kAsync: | 594 case FunctionNode::kAsync: |
649 function.set_modifier(RawFunction::kAsync); | 595 function.set_modifier(RawFunction::kAsync); |
650 function.set_is_inlinable(!FLAG_causal_async_stacks); | 596 function.set_is_inlinable(!FLAG_causal_async_stacks); |
651 break; | 597 break; |
652 case FunctionNode::kAsyncStar: | 598 case FunctionNode::kAsyncStar: |
653 function.set_modifier(RawFunction::kAsyncGen); | 599 function.set_modifier(RawFunction::kAsyncGen); |
654 function.set_is_inlinable(!FLAG_causal_async_stacks); | 600 function.set_is_inlinable(!FLAG_causal_async_stacks); |
655 break; | 601 break; |
656 default: | 602 default: |
657 // no special modifier | 603 // no special modifier |
658 break; | 604 break; |
659 } | 605 } |
660 ASSERT(function_node_helper.async_marker_ == FunctionNode::kSync); | 606 ASSERT(function_node_helper.async_marker_ == FunctionNode::kSync); |
661 | 607 |
662 if (native_name != NULL) { | 608 if (native_name != NULL) { |
663 function.set_native_name(*native_name); | 609 function.set_native_name(*native_name); |
664 } | 610 } |
665 | 611 |
612 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kTypeParameters); | |
613 if (!function.IsFactory()) { | |
614 // Read type_parameters list length. | |
615 intptr_t type_parameter_count = builder_.ReadListLength(); | |
616 // Set type parameters. | |
617 ReadAndSetupTypeParameters(&function, type_parameter_count, | |
618 Class::Handle(Z), function); | |
619 function_node_helper.SetJustRead(FunctionNodeHelper::kTypeParameters); | |
620 } | |
621 | |
666 function_node_helper.ReadUntilExcluding( | 622 function_node_helper.ReadUntilExcluding( |
667 FunctionNodeHelper::kRequiredParameterCount); | 623 FunctionNodeHelper::kRequiredParameterCount); |
668 builder_.SetupFunctionParameters(owner, function, is_method, | 624 builder_.SetupFunctionParameters(owner, function, is_method, |
669 false, // is_closure | 625 false, // is_closure |
670 &function_node_helper); | 626 &function_node_helper); |
671 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); | 627 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kEnd); |
672 procedure_helper.SetJustRead(ProcedureHelper::kFunction); | 628 procedure_helper.SetJustRead(ProcedureHelper::kFunction); |
673 | 629 |
674 if (!in_class) { | 630 if (!in_class) { |
675 library.AddObject(function, name); | 631 library.AddObject(function, name); |
676 ASSERT(!Object::Handle( | 632 ASSERT(!Object::Handle( |
677 Z, library.LookupObjectAllowPrivate( | 633 Z, library.LookupObjectAllowPrivate( |
678 H.DartProcedureName(procedure_helper.canonical_name_))) | 634 H.DartProcedureName(procedure_helper.canonical_name_))) |
679 .IsNull()); | 635 .IsNull()); |
680 } | 636 } |
681 if (FLAG_enable_mirrors && annotation_count > 0) { | 637 if (FLAG_enable_mirrors && annotation_count > 0) { |
682 library.AddFunctionMetadata(function, TokenPosition::kNoSource, | 638 library.AddFunctionMetadata(function, TokenPosition::kNoSource, |
683 procedure_offset); | 639 procedure_offset); |
684 } | 640 } |
685 | 641 |
686 procedure_helper.ReadUntilExcluding(ProcedureHelper::kEnd); | 642 procedure_helper.ReadUntilExcluding(ProcedureHelper::kEnd); |
687 } | 643 } |
688 | 644 |
645 template <typename U> | |
646 void KernelReader::ReadAndSetupTypeParameters( | |
647 U* set_on, | |
648 intptr_t type_parameter_count, | |
649 const Class& parameterized_class, | |
650 const Function& parameterized_function) { | |
651 if (type_parameter_count > 0) { | |
652 // First setup the type parameters, so if any of the following code uses it | |
653 // (in a recursive way) we're fine. | |
654 TypeArguments& type_parameters = | |
655 TypeArguments::Handle(Z, TypeArguments::null()); | |
656 dart::TypeParameter& parameter = dart::TypeParameter::Handle(Z); | |
657 Type& null_bound = Type::Handle(Z, Type::null()); | |
658 | |
659 // Step a) Create array of [TypeParameter] objects (without bound). | |
660 type_parameters = TypeArguments::New(type_parameter_count); | |
661 { | |
662 AlternativeReadingScope alt(builder_.reader_); | |
663 for (intptr_t i = 0; i < type_parameter_count; i++) { | |
664 parameter = dart::TypeParameter::New( | |
665 parameterized_class, parameterized_function, i, | |
666 H.DartSymbol( | |
667 builder_.ReadStringReference()), // read ith name index. | |
668 null_bound, TokenPosition::kNoSource); | |
669 type_parameters.SetTypeAt(i, parameter); | |
670 builder_.SkipDartType(); // read guard. | |
671 } | |
672 } | |
673 set_on->set_type_parameters(type_parameters); | |
Kevin Millikin (Google)
2017/08/08 14:08:51
Having two different template instantiations of th
jensj
2017/08/09 08:39:47
Done.
| |
674 | |
675 // Step b) Fill in the bounds of all [TypeParameter]s. | |
676 for (intptr_t i = 0; i < type_parameter_count; i++) { | |
677 builder_.SkipStringReference(); // read ith name index. | |
678 | |
679 // TODO(github.com/dart-lang/kernel/issues/42): This should be handled | |
680 // by the frontend. | |
681 parameter ^= type_parameters.TypeAt(i); | |
682 Tag tag = builder_.PeekTag(); // peek ith bound type. | |
683 if (tag == kDynamicType) { | |
684 builder_.SkipDartType(); // read ith bound. | |
685 parameter.set_bound(Type::Handle(Z, I->object_store()->object_type())); | |
686 } else { | |
687 AbstractType& bound = | |
688 T.BuildTypeWithoutFinalization(); // read ith bound. | |
689 if (bound.IsMalformedOrMalbounded()) { | |
690 bound = I->object_store()->object_type(); | |
691 } | |
692 parameter.set_bound(bound); | |
693 } | |
694 } | |
695 } | |
696 } | |
697 | |
689 const Object& KernelReader::ClassForScriptAt(const dart::Class& klass, | 698 const Object& KernelReader::ClassForScriptAt(const dart::Class& klass, |
690 intptr_t source_uri_index) { | 699 intptr_t source_uri_index) { |
691 Script& correct_script = ScriptAt(source_uri_index); | 700 Script& correct_script = ScriptAt(source_uri_index); |
692 if (klass.script() != correct_script.raw()) { | 701 if (klass.script() != correct_script.raw()) { |
693 // TODO(jensj): We could probably cache this so we don't create | 702 // TODO(jensj): We could probably cache this so we don't create |
694 // new PatchClasses all the time | 703 // new PatchClasses all the time |
695 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script)); | 704 return PatchClass::ZoneHandle(Z, PatchClass::New(klass, correct_script)); |
696 } | 705 } |
697 return klass; | 706 return klass; |
698 } | 707 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
933 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); | 942 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); |
934 initializer_fun.set_is_debuggable(false); | 943 initializer_fun.set_is_debuggable(false); |
935 initializer_fun.set_is_reflectable(false); | 944 initializer_fun.set_is_reflectable(false); |
936 initializer_fun.set_is_inlinable(false); | 945 initializer_fun.set_is_inlinable(false); |
937 return new (zone) ParsedFunction(thread, initializer_fun); | 946 return new (zone) ParsedFunction(thread, initializer_fun); |
938 } | 947 } |
939 | 948 |
940 } // namespace kernel | 949 } // namespace kernel |
941 } // namespace dart | 950 } // namespace dart |
942 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 951 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |