| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 const String& name = String::Handle(String::NewSymbol(cname)); | 423 const String& name = String::Handle(String::NewSymbol(cname)); |
| 424 const Class& cls = Class::Handle( | 424 const Class& cls = Class::Handle( |
| 425 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); | 425 Class::NewInterface(name, script, Scanner::kDummyTokenIndex)); |
| 426 lib.AddClass(cls); | 426 lib.AddClass(cls); |
| 427 return cls.raw(); | 427 return cls.raw(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 | 430 |
| 431 void Object::RegisterClass(const Class& cls, | 431 void Object::RegisterClass(const Class& cls, |
| 432 const char* cname, | 432 const char* cname, |
| 433 const char* user_visible_cname, |
| 433 const Script& script, | 434 const Script& script, |
| 434 const Library& lib) { | 435 const Library& lib) { |
| 435 const String& name = String::Handle(String::NewSymbol(cname)); | 436 const String& name = String::Handle(String::NewSymbol(cname)); |
| 436 cls.set_name(name); | 437 cls.set_name(name); |
| 438 const String& user_visible_name = |
| 439 String::Handle(String::NewSymbol(user_visible_cname)); |
| 440 cls.set_user_visible_name(user_visible_name); |
| 437 cls.set_script(script); | 441 cls.set_script(script); |
| 438 lib.AddClass(cls); | 442 lib.AddClass(cls); |
| 439 } | 443 } |
| 440 | 444 |
| 441 | 445 |
| 442 void Object::RegisterPrivateClass(const Class& cls, | 446 void Object::RegisterPrivateClass(const Class& cls, |
| 443 const char* public_class_name, | 447 const char* public_class_name, |
| 448 const char* user_visible_cname, |
| 444 const Script& script, | 449 const Script& script, |
| 445 const Library& lib) { | 450 const Library& lib) { |
| 446 String& str = String::Handle(); | 451 String& str = String::Handle(); |
| 447 str = String::NewSymbol(public_class_name); | 452 str = String::NewSymbol(public_class_name); |
| 448 str = lib.PrivateName(str); | 453 str = lib.PrivateName(str); |
| 449 cls.set_name(str); | 454 cls.set_name(str); |
| 455 const String& user_visible_name = |
| 456 String::Handle(String::NewSymbol(user_visible_cname)); |
| 457 cls.set_user_visible_name(user_visible_name); |
| 450 cls.set_script(script); | 458 cls.set_script(script); |
| 451 lib.AddClass(cls); | 459 lib.AddClass(cls); |
| 452 } | 460 } |
| 453 | 461 |
| 454 | 462 |
| 455 RawError* Object::Init(Isolate* isolate) { | 463 RawError* Object::Init(Isolate* isolate) { |
| 456 TIMERSCOPE(time_bootstrap); | 464 TIMERSCOPE(time_bootstrap); |
| 457 ObjectStore* object_store = isolate->object_store(); | 465 ObjectStore* object_store = isolate->object_store(); |
| 458 | 466 |
| 459 Class& cls = Class::Handle(); | 467 Class& cls = Class::Handle(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 object_store->set_pending_classes(pending_classes); | 526 object_store->set_pending_classes(pending_classes); |
| 519 | 527 |
| 520 Context& context = Context::Handle(Context::New(0, Heap::kOld)); | 528 Context& context = Context::Handle(Context::New(0, Heap::kOld)); |
| 521 object_store->set_empty_context(context); | 529 object_store->set_empty_context(context); |
| 522 | 530 |
| 523 // Now that the symbol table is initialized and that the core dictionary as | 531 // Now that the symbol table is initialized and that the core dictionary as |
| 524 // well as the core implementation dictionary have been setup, preallocate | 532 // well as the core implementation dictionary have been setup, preallocate |
| 525 // remaining classes and register them by name in the dictionaries. | 533 // remaining classes and register them by name in the dictionaries. |
| 526 const Script& impl_script = Script::Handle(Bootstrap::LoadImplScript()); | 534 const Script& impl_script = Script::Handle(Bootstrap::LoadImplScript()); |
| 527 | 535 |
| 536 cls = Class::New<Integer>(); |
| 537 object_store->set_integer_implementation_class(cls); |
| 538 RegisterClass(cls, "IntegerImplementation", "int", |
| 539 impl_script, core_impl_lib); |
| 540 pending_classes.Add(cls, Heap::kOld); |
| 541 |
| 528 cls = Class::New<Smi>(); | 542 cls = Class::New<Smi>(); |
| 529 object_store->set_smi_class(cls); | 543 object_store->set_smi_class(cls); |
| 530 RegisterClass(cls, "Smi", impl_script, core_impl_lib); | 544 RegisterClass(cls, "Smi", "int", impl_script, core_impl_lib); |
| 531 pending_classes.Add(cls, Heap::kOld); | 545 pending_classes.Add(cls, Heap::kOld); |
| 532 | 546 |
| 533 cls = Class::New<Mint>(); | 547 cls = Class::New<Mint>(); |
| 534 object_store->set_mint_class(cls); | 548 object_store->set_mint_class(cls); |
| 535 RegisterClass(cls, "Mint", impl_script, core_impl_lib); | 549 RegisterClass(cls, "Mint", "int", impl_script, core_impl_lib); |
| 536 pending_classes.Add(cls, Heap::kOld); | 550 pending_classes.Add(cls, Heap::kOld); |
| 537 | 551 |
| 538 cls = Class::New<Bigint>(); | 552 cls = Class::New<Bigint>(); |
| 539 object_store->set_bigint_class(cls); | 553 object_store->set_bigint_class(cls); |
| 540 RegisterClass(cls, "Bigint", impl_script, core_impl_lib); | 554 RegisterClass(cls, "Bigint", "int", impl_script, core_impl_lib); |
| 541 pending_classes.Add(cls, Heap::kOld); | 555 pending_classes.Add(cls, Heap::kOld); |
| 542 | 556 |
| 543 cls = Class::New<Double>(); | 557 cls = Class::New<Double>(); |
| 544 object_store->set_double_class(cls); | 558 object_store->set_double_class(cls); |
| 545 RegisterClass(cls, "Double", impl_script, core_impl_lib); | 559 RegisterClass(cls, "Double", "double", impl_script, core_impl_lib); |
| 546 pending_classes.Add(cls, Heap::kOld); | 560 pending_classes.Add(cls, Heap::kOld); |
| 547 | 561 |
| 548 cls = Class::New<Bool>(); | 562 cls = Class::New<Bool>(); |
| 549 object_store->set_bool_class(cls); | 563 object_store->set_bool_class(cls); |
| 550 RegisterClass(cls, "Bool", impl_script, core_impl_lib); | 564 RegisterClass(cls, "Bool", "bool", impl_script, core_impl_lib); |
| 551 pending_classes.Add(cls, Heap::kOld); | 565 pending_classes.Add(cls, Heap::kOld); |
| 552 | 566 |
| 553 cls = object_store->array_class(); // Was allocated above. | 567 cls = object_store->array_class(); // Was allocated above. |
| 554 RegisterClass(cls, "ObjectArray", impl_script, core_impl_lib); | 568 RegisterClass(cls, "ObjectArray", "List", impl_script, core_impl_lib); |
| 555 pending_classes.Add(cls, Heap::kOld); | 569 pending_classes.Add(cls, Heap::kOld); |
| 556 | 570 |
| 557 cls = object_store->growable_object_array_class(); // Was allocated above. | 571 cls = object_store->growable_object_array_class(); // Was allocated above. |
| 558 RegisterClass(cls, "GrowableObjectArray", impl_script, core_impl_lib); | 572 RegisterClass(cls, "GrowableObjectArray", "List", impl_script, core_impl_lib); |
| 559 pending_classes.Add(cls, Heap::kOld); | 573 pending_classes.Add(cls, Heap::kOld); |
| 560 | 574 |
| 561 cls = Class::New<ImmutableArray>(); | 575 cls = Class::New<ImmutableArray>(); |
| 562 object_store->set_immutable_array_class(cls); | 576 object_store->set_immutable_array_class(cls); |
| 563 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset()); | 577 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset()); |
| 564 ASSERT(object_store->immutable_array_class() != object_store->array_class()); | 578 ASSERT(object_store->immutable_array_class() != object_store->array_class()); |
| 565 RegisterClass(cls, "ImmutableArray", impl_script, core_impl_lib); | 579 RegisterClass(cls, "ImmutableArray", "List", impl_script, core_impl_lib); |
| 566 pending_classes.Add(cls, Heap::kOld); | 580 pending_classes.Add(cls, Heap::kOld); |
| 567 | 581 |
| 568 cls = object_store->one_byte_string_class(); // Was allocated above. | 582 cls = object_store->one_byte_string_class(); // Was allocated above. |
| 569 RegisterClass(cls, "OneByteString", impl_script, core_impl_lib); | 583 RegisterClass(cls, "OneByteString", "String", impl_script, core_impl_lib); |
| 570 pending_classes.Add(cls, Heap::kOld); | 584 pending_classes.Add(cls, Heap::kOld); |
| 571 | 585 |
| 572 cls = Class::New<TwoByteString>(); | 586 cls = Class::New<TwoByteString>(); |
| 573 object_store->set_two_byte_string_class(cls); | 587 object_store->set_two_byte_string_class(cls); |
| 574 RegisterClass(cls, "TwoByteString", impl_script, core_impl_lib); | 588 RegisterClass(cls, "TwoByteString", "String", impl_script, core_impl_lib); |
| 575 pending_classes.Add(cls, Heap::kOld); | 589 pending_classes.Add(cls, Heap::kOld); |
| 576 | 590 |
| 577 cls = Class::New<FourByteString>(); | 591 cls = Class::New<FourByteString>(); |
| 578 object_store->set_four_byte_string_class(cls); | 592 object_store->set_four_byte_string_class(cls); |
| 579 RegisterClass(cls, "FourByteString", impl_script, core_impl_lib); | 593 RegisterClass(cls, "FourByteString", "String", impl_script, core_impl_lib); |
| 580 pending_classes.Add(cls, Heap::kOld); | 594 pending_classes.Add(cls, Heap::kOld); |
| 581 | 595 |
| 582 cls = Class::New<ExternalOneByteString>(); | 596 cls = Class::New<ExternalOneByteString>(); |
| 583 object_store->set_external_one_byte_string_class(cls); | 597 object_store->set_external_one_byte_string_class(cls); |
| 584 RegisterClass(cls, "ExternalOneByteString", impl_script, core_impl_lib); | 598 RegisterClass(cls, "ExternalOneByteString", "String", |
| 599 impl_script, core_impl_lib); |
| 585 pending_classes.Add(cls, Heap::kOld); | 600 pending_classes.Add(cls, Heap::kOld); |
| 586 | 601 |
| 587 cls = Class::New<ExternalTwoByteString>(); | 602 cls = Class::New<ExternalTwoByteString>(); |
| 588 object_store->set_external_two_byte_string_class(cls); | 603 object_store->set_external_two_byte_string_class(cls); |
| 589 RegisterClass(cls, "ExternalTwoByteString", impl_script, core_impl_lib); | 604 RegisterClass(cls, "ExternalTwoByteString", "String", |
| 605 impl_script, core_impl_lib); |
| 590 pending_classes.Add(cls, Heap::kOld); | 606 pending_classes.Add(cls, Heap::kOld); |
| 591 | 607 |
| 592 cls = Class::New<ExternalFourByteString>(); | 608 cls = Class::New<ExternalFourByteString>(); |
| 593 object_store->set_external_four_byte_string_class(cls); | 609 object_store->set_external_four_byte_string_class(cls); |
| 594 RegisterClass(cls, "ExternalFourByteString", impl_script, core_impl_lib); | 610 RegisterClass(cls, "ExternalFourByteString", "String", |
| 611 impl_script, core_impl_lib); |
| 595 pending_classes.Add(cls, Heap::kOld); | 612 pending_classes.Add(cls, Heap::kOld); |
| 596 | 613 |
| 597 cls = Class::New<Stacktrace>(); | 614 cls = Class::New<Stacktrace>(); |
| 598 object_store->set_stacktrace_class(cls); | 615 object_store->set_stacktrace_class(cls); |
| 599 RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib); | 616 RegisterClass(cls, "Stacktrace", "Stacktrace", impl_script, core_impl_lib); |
| 600 pending_classes.Add(cls, Heap::kOld); | 617 pending_classes.Add(cls, Heap::kOld); |
| 601 // Super type set below, after Object is allocated. | 618 // Super type set below, after Object is allocated. |
| 602 | 619 |
| 603 cls = Class::New<JSRegExp>(); | 620 cls = Class::New<JSRegExp>(); |
| 604 object_store->set_jsregexp_class(cls); | 621 object_store->set_jsregexp_class(cls); |
| 605 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); | 622 RegisterClass(cls, "JSSyntaxRegExp", "JSSyntaxRegExp", |
| 623 impl_script, core_impl_lib); |
| 606 pending_classes.Add(cls, Heap::kOld); | 624 pending_classes.Add(cls, Heap::kOld); |
| 607 | 625 |
| 608 // Initialize the base interfaces used by the core VM classes. | 626 // Initialize the base interfaces used by the core VM classes. |
| 609 const Script& script = Script::Handle(Bootstrap::LoadScript()); | 627 const Script& script = Script::Handle(Bootstrap::LoadScript()); |
| 610 | 628 |
| 611 // Allocate and initialize the Object class and type. The Object | 629 // Allocate and initialize the Object class and type. The Object |
| 612 // class and ByteArray subclasses are the only pre-allocated, | 630 // class and ByteArray subclasses are the only pre-allocated, |
| 613 // non-interface classes in the core library. | 631 // non-interface classes in the core library. |
| 614 cls = Class::New<Instance>(); | 632 cls = Class::New<Instance>(); |
| 615 object_store->set_object_class(cls); | 633 object_store->set_object_class(cls); |
| 616 cls.set_name(String::Handle(String::NewSymbol("Object"))); | 634 cls.set_name(String::Handle(String::NewSymbol("Object"))); |
| 635 cls.set_user_visible_name(String::Handle(String::NewSymbol("Object"))); |
| 617 cls.set_script(script); | 636 cls.set_script(script); |
| 618 cls.set_is_prefinalized(); | 637 cls.set_is_prefinalized(); |
| 619 core_lib.AddClass(cls); | 638 core_lib.AddClass(cls); |
| 620 pending_classes.Add(cls, Heap::kOld); | 639 pending_classes.Add(cls, Heap::kOld); |
| 621 type = Type::NewNonParameterizedType(cls); | 640 type = Type::NewNonParameterizedType(cls); |
| 622 object_store->set_object_type(type); | 641 object_store->set_object_type(type); |
| 623 | 642 |
| 624 cls = Class::New<Int8Array>(); | 643 cls = Class::New<Int8Array>(); |
| 625 object_store->set_int8_array_class(cls); | 644 object_store->set_int8_array_class(cls); |
| 626 RegisterPrivateClass(cls, "_Int8Array", script, core_lib); | 645 RegisterPrivateClass(cls, "_Int8Array", "Int8List", script, core_lib); |
| 627 | 646 |
| 628 cls = Class::New<Uint8Array>(); | 647 cls = Class::New<Uint8Array>(); |
| 629 object_store->set_uint8_array_class(cls); | 648 object_store->set_uint8_array_class(cls); |
| 630 RegisterPrivateClass(cls, "_Uint8Array", script, core_lib); | 649 RegisterPrivateClass(cls, "_Uint8Array", "Uint8List", script, core_lib); |
| 631 | 650 |
| 632 cls = Class::New<Int16Array>(); | 651 cls = Class::New<Int16Array>(); |
| 633 object_store->set_int16_array_class(cls); | 652 object_store->set_int16_array_class(cls); |
| 634 RegisterPrivateClass(cls, "_Int16Array", script, core_lib); | 653 RegisterPrivateClass(cls, "_Int16Array", "Int16List", script, core_lib); |
| 635 | 654 |
| 636 cls = Class::New<Uint16Array>(); | 655 cls = Class::New<Uint16Array>(); |
| 637 object_store->set_uint16_array_class(cls); | 656 object_store->set_uint16_array_class(cls); |
| 638 RegisterPrivateClass(cls, "_Uint16Array", script, core_lib); | 657 RegisterPrivateClass(cls, "_Uint16Array", "Uint16List", script, core_lib); |
| 639 | 658 |
| 640 cls = Class::New<Int32Array>(); | 659 cls = Class::New<Int32Array>(); |
| 641 object_store->set_int32_array_class(cls); | 660 object_store->set_int32_array_class(cls); |
| 642 RegisterPrivateClass(cls, "_Int32Array", script, core_lib); | 661 RegisterPrivateClass(cls, "_Int32Array", "Int32List", script, core_lib); |
| 643 | 662 |
| 644 cls = Class::New<Uint32Array>(); | 663 cls = Class::New<Uint32Array>(); |
| 645 object_store->set_uint32_array_class(cls); | 664 object_store->set_uint32_array_class(cls); |
| 646 RegisterPrivateClass(cls, "_Uint32Array", script, core_lib); | 665 RegisterPrivateClass(cls, "_Uint32Array", "Uint32List", script, core_lib); |
| 647 | 666 |
| 648 cls = Class::New<Int64Array>(); | 667 cls = Class::New<Int64Array>(); |
| 649 object_store->set_int64_array_class(cls); | 668 object_store->set_int64_array_class(cls); |
| 650 RegisterPrivateClass(cls, "_Int64Array", script, core_lib); | 669 RegisterPrivateClass(cls, "_Int64Array", "Int64List", script, core_lib); |
| 651 | 670 |
| 652 cls = Class::New<Uint64Array>(); | 671 cls = Class::New<Uint64Array>(); |
| 653 object_store->set_uint64_array_class(cls); | 672 object_store->set_uint64_array_class(cls); |
| 654 RegisterPrivateClass(cls, "_Uint64Array", script, core_lib); | 673 RegisterPrivateClass(cls, "_Uint64Array", "Uint64List", script, core_lib); |
| 655 | 674 |
| 656 cls = Class::New<Float32Array>(); | 675 cls = Class::New<Float32Array>(); |
| 657 object_store->set_float32_array_class(cls); | 676 object_store->set_float32_array_class(cls); |
| 658 RegisterPrivateClass(cls, "_Float32Array", script, core_lib); | 677 RegisterPrivateClass(cls, "_Float32Array", "Float32List", script, core_lib); |
| 659 | 678 |
| 660 cls = Class::New<Float64Array>(); | 679 cls = Class::New<Float64Array>(); |
| 661 object_store->set_float64_array_class(cls); | 680 object_store->set_float64_array_class(cls); |
| 662 RegisterPrivateClass(cls, "_Float64Array", script, core_lib); | 681 RegisterPrivateClass(cls, "_Float64Array", "Float64List", script, core_lib); |
| 663 | 682 |
| 664 cls = Class::New<ExternalInt8Array>(); | 683 cls = Class::New<ExternalInt8Array>(); |
| 665 object_store->set_external_int8_array_class(cls); | 684 object_store->set_external_int8_array_class(cls); |
| 666 RegisterPrivateClass(cls, "_ExternalInt8Array", script, core_lib); | 685 RegisterPrivateClass(cls, "_ExternalInt8Array", "Int8List", script, core_lib); |
| 667 | 686 |
| 668 cls = Class::New<ExternalUint8Array>(); | 687 cls = Class::New<ExternalUint8Array>(); |
| 669 object_store->set_external_uint8_array_class(cls); | 688 object_store->set_external_uint8_array_class(cls); |
| 670 RegisterPrivateClass(cls, "_ExternalUint8Array", script, core_lib); | 689 RegisterPrivateClass(cls, "_ExternalUint8Array", "Uint8List", |
| 690 script, core_lib); |
| 671 | 691 |
| 672 cls = Class::New<ExternalInt16Array>(); | 692 cls = Class::New<ExternalInt16Array>(); |
| 673 object_store->set_external_int16_array_class(cls); | 693 object_store->set_external_int16_array_class(cls); |
| 674 RegisterPrivateClass(cls, "_ExternalInt16Array", script, core_lib); | 694 RegisterPrivateClass(cls, "_ExternalInt16Array", "Int16List", |
| 695 script, core_lib); |
| 675 | 696 |
| 676 cls = Class::New<ExternalUint16Array>(); | 697 cls = Class::New<ExternalUint16Array>(); |
| 677 object_store->set_external_uint16_array_class(cls); | 698 object_store->set_external_uint16_array_class(cls); |
| 678 RegisterPrivateClass(cls, "_ExternalUint16Array", script, core_lib); | 699 RegisterPrivateClass(cls, "_ExternalUint16Array", "Uint16List", |
| 700 script, core_lib); |
| 679 | 701 |
| 680 cls = Class::New<ExternalInt32Array>(); | 702 cls = Class::New<ExternalInt32Array>(); |
| 681 object_store->set_external_int32_array_class(cls); | 703 object_store->set_external_int32_array_class(cls); |
| 682 RegisterPrivateClass(cls, "_ExternalInt32Array", script, core_lib); | 704 RegisterPrivateClass(cls, "_ExternalInt32Array", "Int32List", |
| 705 script, core_lib); |
| 683 | 706 |
| 684 cls = Class::New<ExternalUint32Array>(); | 707 cls = Class::New<ExternalUint32Array>(); |
| 685 object_store->set_external_uint32_array_class(cls); | 708 object_store->set_external_uint32_array_class(cls); |
| 686 RegisterPrivateClass(cls, "_ExternalUint32Array", script, core_lib); | 709 RegisterPrivateClass(cls, "_ExternalUint32Array", "Uint32List", |
| 710 script, core_lib); |
| 687 | 711 |
| 688 cls = Class::New<ExternalInt64Array>(); | 712 cls = Class::New<ExternalInt64Array>(); |
| 689 object_store->set_external_int64_array_class(cls); | 713 object_store->set_external_int64_array_class(cls); |
| 690 RegisterPrivateClass(cls, "_ExternalInt64Array", script, core_lib); | 714 RegisterPrivateClass(cls, "_ExternalInt64Array", "Int64List", |
| 715 script, core_lib); |
| 691 | 716 |
| 692 cls = Class::New<ExternalUint64Array>(); | 717 cls = Class::New<ExternalUint64Array>(); |
| 693 object_store->set_external_uint64_array_class(cls); | 718 object_store->set_external_uint64_array_class(cls); |
| 694 RegisterPrivateClass(cls, "_ExternalUint64Array", script, core_lib); | 719 RegisterPrivateClass(cls, "_ExternalUint64Array", "Uint64List", |
| 720 script, core_lib); |
| 695 | 721 |
| 696 cls = Class::New<ExternalFloat32Array>(); | 722 cls = Class::New<ExternalFloat32Array>(); |
| 697 object_store->set_external_float32_array_class(cls); | 723 object_store->set_external_float32_array_class(cls); |
| 698 RegisterPrivateClass(cls, "_ExternalFloat32Array", script, core_lib); | 724 RegisterPrivateClass(cls, "_ExternalFloat32Array", "Float32List", |
| 725 script, core_lib); |
| 699 | 726 |
| 700 cls = Class::New<ExternalFloat64Array>(); | 727 cls = Class::New<ExternalFloat64Array>(); |
| 701 object_store->set_external_float64_array_class(cls); | 728 object_store->set_external_float64_array_class(cls); |
| 702 RegisterPrivateClass(cls, "_ExternalFloat64Array", script, core_lib); | 729 RegisterPrivateClass(cls, "_ExternalFloat64Array", "Float64List", |
| 730 script, core_lib); |
| 703 | 731 |
| 704 // Set the super type of class Stacktrace to Object type so that the | 732 // Set the super type of class Stacktrace to Object type so that the |
| 705 // 'toString' method is implemented. | 733 // 'toString' method is implemented. |
| 706 cls = object_store->stacktrace_class(); | 734 cls = object_store->stacktrace_class(); |
| 707 cls.set_super_type(type); | 735 cls.set_super_type(type); |
| 708 | 736 |
| 709 cls = CreateAndRegisterInterface("Function", script, core_lib); | 737 cls = CreateAndRegisterInterface("Function", script, core_lib); |
| 710 pending_classes.Add(cls, Heap::kOld); | 738 pending_classes.Add(cls, Heap::kOld); |
| 711 type = Type::NewNonParameterizedType(cls); | 739 type = Type::NewNonParameterizedType(cls); |
| 712 object_store->set_function_interface(type); | 740 object_store->set_function_interface(type); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 | 929 |
| 902 cls = Class::New<ExternalUint64Array>(); | 930 cls = Class::New<ExternalUint64Array>(); |
| 903 object_store->set_external_uint64_array_class(cls); | 931 object_store->set_external_uint64_array_class(cls); |
| 904 | 932 |
| 905 cls = Class::New<ExternalFloat32Array>(); | 933 cls = Class::New<ExternalFloat32Array>(); |
| 906 object_store->set_external_float32_array_class(cls); | 934 object_store->set_external_float32_array_class(cls); |
| 907 | 935 |
| 908 cls = Class::New<ExternalFloat64Array>(); | 936 cls = Class::New<ExternalFloat64Array>(); |
| 909 object_store->set_external_float64_array_class(cls); | 937 object_store->set_external_float64_array_class(cls); |
| 910 | 938 |
| 939 cls = Class::New<Integer>(); |
| 940 object_store->set_integer_implementation_class(cls); |
| 941 |
| 911 cls = Class::New<Smi>(); | 942 cls = Class::New<Smi>(); |
| 912 object_store->set_smi_class(cls); | 943 object_store->set_smi_class(cls); |
| 913 | 944 |
| 914 cls = Class::New<Mint>(); | 945 cls = Class::New<Mint>(); |
| 915 object_store->set_mint_class(cls); | 946 object_store->set_mint_class(cls); |
| 916 | 947 |
| 917 cls = Class::New<Double>(); | 948 cls = Class::New<Double>(); |
| 918 object_store->set_double_class(cls); | 949 object_store->set_double_class(cls); |
| 919 | 950 |
| 920 cls = Class::New<Bigint>(); | 951 cls = Class::New<Bigint>(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 RawString* Class::Name() const { | 1070 RawString* Class::Name() const { |
| 1040 if (raw_ptr()->name_ != String::null()) { | 1071 if (raw_ptr()->name_ != String::null()) { |
| 1041 return raw_ptr()->name_; | 1072 return raw_ptr()->name_; |
| 1042 } | 1073 } |
| 1043 ASSERT(class_class() != Class::null()); // class_class_ should be set up. | 1074 ASSERT(class_class() != Class::null()); // class_class_ should be set up. |
| 1044 intptr_t index = GetSingletonClassIndex(raw()); | 1075 intptr_t index = GetSingletonClassIndex(raw()); |
| 1045 return String::NewSymbol(GetSingletonClassName(index)); | 1076 return String::NewSymbol(GetSingletonClassName(index)); |
| 1046 } | 1077 } |
| 1047 | 1078 |
| 1048 | 1079 |
| 1080 RawString* Class::UserVisibleName() const { |
| 1081 if (raw_ptr()->user_visible_name_ != String::null()) { |
| 1082 return raw_ptr()->user_visible_name_; |
| 1083 } |
| 1084 return Name(); |
| 1085 } |
| 1086 |
| 1087 |
| 1049 RawType* Class::SignatureType() const { | 1088 RawType* Class::SignatureType() const { |
| 1050 ASSERT(IsSignatureClass()); | 1089 ASSERT(IsSignatureClass()); |
| 1051 const Function& function = Function::Handle(signature_function()); | 1090 const Function& function = Function::Handle(signature_function()); |
| 1052 ASSERT(!function.IsNull()); | 1091 ASSERT(!function.IsNull()); |
| 1053 if (function.signature_class() != raw()) { | 1092 if (function.signature_class() != raw()) { |
| 1054 // This class is a function type alias. Return the canonical signature type. | 1093 // This class is a function type alias. Return the canonical signature type. |
| 1055 const Class& canonical_class = Class::Handle(function.signature_class()); | 1094 const Class& canonical_class = Class::Handle(function.signature_class()); |
| 1056 return canonical_class.SignatureType(); | 1095 return canonical_class.SignatureType(); |
| 1057 } | 1096 } |
| 1058 // Return the first canonical signature type if already computed. | 1097 // Return the first canonical signature type if already computed. |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 intptr_t token_pos) const { | 1359 intptr_t token_pos) const { |
| 1321 ASSERT(!type_name.IsNull()); | 1360 ASSERT(!type_name.IsNull()); |
| 1322 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1361 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1323 if (!type_params.IsNull()) { | 1362 if (!type_params.IsNull()) { |
| 1324 intptr_t num_type_params = type_params.Length(); | 1363 intptr_t num_type_params = type_params.Length(); |
| 1325 TypeParameter& type_param = TypeParameter::Handle(); | 1364 TypeParameter& type_param = TypeParameter::Handle(); |
| 1326 String& type_param_name = String::Handle(); | 1365 String& type_param_name = String::Handle(); |
| 1327 AbstractType& bound = AbstractType::Handle(); | 1366 AbstractType& bound = AbstractType::Handle(); |
| 1328 for (intptr_t i = 0; i < num_type_params; i++) { | 1367 for (intptr_t i = 0; i < num_type_params; i++) { |
| 1329 type_param ^= type_params.TypeAt(i); | 1368 type_param ^= type_params.TypeAt(i); |
| 1330 type_param_name = type_param.Name(); | 1369 type_param_name = type_param.name(); |
| 1331 if (type_param_name.Equals(type_name)) { | 1370 if (type_param_name.Equals(type_name)) { |
| 1332 intptr_t index = type_param.index(); | 1371 intptr_t index = type_param.index(); |
| 1333 bound = type_param.bound(); | 1372 bound = type_param.bound(); |
| 1334 // Create a non-finalized new TypeParameter with the given token_pos. | 1373 // Create a non-finalized new TypeParameter with the given token_pos. |
| 1335 if (type_param.IsFinalized()) { | 1374 if (type_param.IsFinalized()) { |
| 1336 // The index was adjusted during finalization. Revert. | 1375 // The index was adjusted during finalization. Revert. |
| 1337 index -= NumTypeArguments() - num_type_params; | 1376 index -= NumTypeArguments() - num_type_params; |
| 1338 } else { | 1377 } else { |
| 1339 ASSERT(type_param.index() == i); | 1378 ASSERT(type_param.index() == i); |
| 1340 } | 1379 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 return result.raw(); | 1485 return result.raw(); |
| 1447 } | 1486 } |
| 1448 | 1487 |
| 1449 | 1488 |
| 1450 template <class FakeInstance> | 1489 template <class FakeInstance> |
| 1451 RawClass* Class::New(const String& name, | 1490 RawClass* Class::New(const String& name, |
| 1452 const Script& script, | 1491 const Script& script, |
| 1453 intptr_t token_pos) { | 1492 intptr_t token_pos) { |
| 1454 Class& result = Class::Handle(New<FakeInstance>(kIllegalObjectKind)); | 1493 Class& result = Class::Handle(New<FakeInstance>(kIllegalObjectKind)); |
| 1455 result.set_name(name); | 1494 result.set_name(name); |
| 1495 result.set_user_visible_name(name); |
| 1456 result.set_script(script); | 1496 result.set_script(script); |
| 1457 result.set_token_pos(token_pos); | 1497 result.set_token_pos(token_pos); |
| 1458 return result.raw(); | 1498 return result.raw(); |
| 1459 } | 1499 } |
| 1460 | 1500 |
| 1461 | 1501 |
| 1462 RawClass* Class::New(const String& name, | 1502 RawClass* Class::New(const String& name, |
| 1463 const Script& script, | 1503 const Script& script, |
| 1464 intptr_t token_pos) { | 1504 intptr_t token_pos) { |
| 1465 Class& result = Class::Handle(New<Instance>(name, script, token_pos)); | 1505 Class& result = Class::Handle(New<Instance>(name, script, token_pos)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); | 1569 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); |
| 1530 new_canonical_types.SetAt(0, signature_type); | 1570 new_canonical_types.SetAt(0, signature_type); |
| 1531 result.set_canonical_types(new_canonical_types); | 1571 result.set_canonical_types(new_canonical_types); |
| 1532 return result.raw(); | 1572 return result.raw(); |
| 1533 } | 1573 } |
| 1534 | 1574 |
| 1535 | 1575 |
| 1536 RawClass* Class::GetClass(ObjectKind kind) { | 1576 RawClass* Class::GetClass(ObjectKind kind) { |
| 1537 ObjectStore* object_store = Isolate::Current()->object_store(); | 1577 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1538 switch (kind) { | 1578 switch (kind) { |
| 1579 case kInteger: |
| 1580 ASSERT(object_store->integer_implementation_class() != Class::null()); |
| 1581 return object_store->integer_implementation_class(); |
| 1539 case kSmi: | 1582 case kSmi: |
| 1540 ASSERT(object_store->smi_class() != Class::null()); | 1583 ASSERT(object_store->smi_class() != Class::null()); |
| 1541 return object_store->smi_class(); | 1584 return object_store->smi_class(); |
| 1542 case kMint: | 1585 case kMint: |
| 1543 ASSERT(object_store->mint_class() != Class::null()); | 1586 ASSERT(object_store->mint_class() != Class::null()); |
| 1544 return object_store->mint_class(); | 1587 return object_store->mint_class(); |
| 1545 case kBigint: | 1588 case kBigint: |
| 1546 ASSERT(object_store->bigint_class() != Class::null()); | 1589 ASSERT(object_store->bigint_class() != Class::null()); |
| 1547 return object_store->bigint_class(); | 1590 return object_store->bigint_class(); |
| 1548 case kDouble: | 1591 case kDouble: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 } | 1722 } |
| 1680 } | 1723 } |
| 1681 | 1724 |
| 1682 | 1725 |
| 1683 void Class::set_name(const String& value) const { | 1726 void Class::set_name(const String& value) const { |
| 1684 ASSERT(value.IsSymbol()); | 1727 ASSERT(value.IsSymbol()); |
| 1685 StorePointer(&raw_ptr()->name_, value.raw()); | 1728 StorePointer(&raw_ptr()->name_, value.raw()); |
| 1686 } | 1729 } |
| 1687 | 1730 |
| 1688 | 1731 |
| 1732 void Class::set_user_visible_name(const String& value) const { |
| 1733 ASSERT(value.IsSymbol()); |
| 1734 StorePointer(&raw_ptr()->user_visible_name_, value.raw()); |
| 1735 } |
| 1736 |
| 1737 |
| 1689 void Class::set_script(const Script& value) const { | 1738 void Class::set_script(const Script& value) const { |
| 1690 StorePointer(&raw_ptr()->script_, value.raw()); | 1739 StorePointer(&raw_ptr()->script_, value.raw()); |
| 1691 } | 1740 } |
| 1692 | 1741 |
| 1693 | 1742 |
| 1694 void Class::set_token_pos(intptr_t token_pos) const { | 1743 void Class::set_token_pos(intptr_t token_pos) const { |
| 1695 ASSERT(token_pos >= 0); | 1744 ASSERT(token_pos >= 0); |
| 1696 raw_ptr()->token_pos_ = token_pos; | 1745 raw_ptr()->token_pos_ = token_pos; |
| 1697 } | 1746 } |
| 1698 | 1747 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2303 } | 2352 } |
| 2304 | 2353 |
| 2305 | 2354 |
| 2306 RawAbstractType* AbstractType::Canonicalize() const { | 2355 RawAbstractType* AbstractType::Canonicalize() const { |
| 2307 // AbstractType is an abstract class. | 2356 // AbstractType is an abstract class. |
| 2308 UNREACHABLE(); | 2357 UNREACHABLE(); |
| 2309 return NULL; | 2358 return NULL; |
| 2310 } | 2359 } |
| 2311 | 2360 |
| 2312 | 2361 |
| 2313 // TODO(regis): Investigate if we can safely map internal integer types (Smi, | 2362 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { |
| 2314 // Mint, and Bigint) to 'int' and internal String types (OneByteString, etc...) | 2363 if (IsTypeParameter()) { |
| 2315 // to 'String' here. It may be too early. Also consider the upcoming type() | 2364 return TypeParameter::Cast(*this).name(); |
| 2316 // method. | 2365 } |
| 2317 RawString* AbstractType::Name() const { | |
| 2318 // If the type is still being finalized, we may be reporting an error about | 2366 // If the type is still being finalized, we may be reporting an error about |
| 2319 // an illformed type, so proceed with caution. | 2367 // a malformed type, so proceed with caution. |
| 2320 const AbstractTypeArguments& args = | 2368 const AbstractTypeArguments& args = |
| 2321 AbstractTypeArguments::Handle(arguments()); | 2369 AbstractTypeArguments::Handle(arguments()); |
| 2322 const intptr_t num_args = args.IsNull() ? 0 : args.Length(); | 2370 const intptr_t num_args = args.IsNull() ? 0 : args.Length(); |
| 2323 String& class_name = String::Handle(); | 2371 String& class_name = String::Handle(); |
| 2324 intptr_t first_type_param_index; | 2372 intptr_t first_type_param_index; |
| 2325 intptr_t num_type_params; // Number of type parameters to print. | 2373 intptr_t num_type_params; // Number of type parameters to print. |
| 2326 if (HasResolvedTypeClass()) { | 2374 if (HasResolvedTypeClass()) { |
| 2327 const Class& cls = Class::Handle(type_class()); | 2375 const Class& cls = Class::Handle(type_class()); |
| 2328 class_name = cls.Name(); | |
| 2329 num_type_params = cls.NumTypeParameters(); // Do not print the full vector. | 2376 num_type_params = cls.NumTypeParameters(); // Do not print the full vector. |
| 2377 if (name_visibility == kInternalName) { |
| 2378 class_name = cls.Name(); |
| 2379 } else { |
| 2380 ASSERT(name_visibility == kUserVisibleName); |
| 2381 // Map internal types to their corresponding public interfaces. |
| 2382 class_name = cls.UserVisibleName(); |
| 2383 } |
| 2330 if (num_type_params > num_args) { | 2384 if (num_type_params > num_args) { |
| 2331 first_type_param_index = 0; | 2385 first_type_param_index = 0; |
| 2332 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 2386 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 2333 // Most probably an illformed type. Do not fill up with "Dynamic", | 2387 // Most probably a malformed type. Do not fill up with "Dynamic", |
| 2334 // but use actual vector. | 2388 // but use actual vector. |
| 2335 num_type_params = num_args; | 2389 num_type_params = num_args; |
| 2336 } else { | 2390 } else { |
| 2337 ASSERT(num_args == 0); // Type is raw. | 2391 ASSERT(num_args == 0); // Type is raw. |
| 2338 // No need to fill up with "Dynamic". | 2392 // No need to fill up with "Dynamic". |
| 2339 num_type_params = 0; | 2393 num_type_params = 0; |
| 2340 } | 2394 } |
| 2341 } else { | 2395 } else { |
| 2342 first_type_param_index = num_args - num_type_params; | 2396 first_type_param_index = num_args - num_type_params; |
| 2343 } | 2397 } |
| 2344 if (cls.IsSignatureClass()) { | 2398 if (cls.IsSignatureClass()) { |
| 2345 // We may be reporting an error about an illformed function type. In that | 2399 // We may be reporting an error about a malformed function type. In that |
| 2346 // case, avoid instantiating the signature, since it may lead to cycles. | 2400 // case, avoid instantiating the signature, since it may lead to cycles. |
| 2347 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 2401 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 2348 return class_name.raw(); | 2402 return class_name.raw(); |
| 2349 } | 2403 } |
| 2350 if (num_type_params > 0) { | 2404 // In order to avoid cycles, print the name of a typedef (non-canonical |
| 2405 // signature class) as a regular, possibly parameterized, class. |
| 2406 if (cls.IsCanonicalSignatureClass()) { |
| 2351 const Function& signature_function = Function::Handle( | 2407 const Function& signature_function = Function::Handle( |
| 2352 cls.signature_function()); | 2408 cls.signature_function()); |
| 2353 // Signature classes have no super type. | 2409 // Signature classes have no super type. |
| 2354 ASSERT(first_type_param_index == 0); | 2410 ASSERT(first_type_param_index == 0); |
| 2355 return signature_function.InstantiatedSignatureFrom(args); | 2411 return signature_function.InstantiatedSignatureFrom(args, |
| 2412 name_visibility); |
| 2356 } | 2413 } |
| 2357 } | 2414 } |
| 2358 } else { | 2415 } else { |
| 2359 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); | 2416 const UnresolvedClass& cls = UnresolvedClass::Handle(unresolved_class()); |
| 2360 class_name = cls.Name(); | 2417 class_name = cls.Name(); |
| 2361 num_type_params = num_args; | 2418 num_type_params = num_args; |
| 2362 first_type_param_index = 0; | 2419 first_type_param_index = 0; |
| 2363 } | 2420 } |
| 2364 String& type_name = String::Handle(); | 2421 String& type_name = String::Handle(); |
| 2365 if (num_type_params == 0) { | 2422 if (num_type_params == 0) { |
| 2366 type_name = class_name.raw(); | 2423 type_name = class_name.raw(); |
| 2367 } else { | 2424 } else { |
| 2368 const String& args_name = String::Handle( | 2425 const String& args_name = String::Handle( |
| 2369 args.SubvectorName(first_type_param_index, num_type_params)); | 2426 args.SubvectorName(first_type_param_index, |
| 2427 num_type_params, |
| 2428 name_visibility)); |
| 2370 type_name = String::Concat(class_name, args_name); | 2429 type_name = String::Concat(class_name, args_name); |
| 2371 } | 2430 } |
| 2372 // The name is only used for type checking and debugging purposes. | 2431 // The name is only used for type checking and debugging purposes. |
| 2373 // Unless profiling data shows otherwise, it is not worth caching the name in | 2432 // Unless profiling data shows otherwise, it is not worth caching the name in |
| 2374 // the type. | 2433 // the type. |
| 2375 return String::NewSymbol(type_name); | 2434 return String::NewSymbol(type_name); |
| 2376 } | 2435 } |
| 2377 | 2436 |
| 2378 | 2437 |
| 2379 RawString* AbstractType::ClassName() const { | 2438 RawString* AbstractType::ClassName() const { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2867 const TypeParameter& other_type_param = TypeParameter::Cast(other); | 2926 const TypeParameter& other_type_param = TypeParameter::Cast(other); |
| 2868 if (IsFinalized() != other_type_param.IsFinalized()) { | 2927 if (IsFinalized() != other_type_param.IsFinalized()) { |
| 2869 return false; | 2928 return false; |
| 2870 } | 2929 } |
| 2871 if (parameterized_class() != other_type_param.parameterized_class()) { | 2930 if (parameterized_class() != other_type_param.parameterized_class()) { |
| 2872 return false; | 2931 return false; |
| 2873 } | 2932 } |
| 2874 if (index() != other_type_param.index()) { | 2933 if (index() != other_type_param.index()) { |
| 2875 return false; | 2934 return false; |
| 2876 } | 2935 } |
| 2877 const String& name = String::Handle(Name()); | 2936 const String& type_param_name = String::Handle(name()); |
| 2878 const String& other_type_param_name = String::Handle(other_type_param.Name()); | 2937 const String& other_type_param_name = String::Handle(other_type_param.name()); |
| 2879 return name.Equals(other_type_param_name); | 2938 return type_param_name.Equals(other_type_param_name); |
| 2880 } | 2939 } |
| 2881 | 2940 |
| 2882 | 2941 |
| 2883 bool TypeParameter::IsIdentical(const AbstractType& other, | 2942 bool TypeParameter::IsIdentical(const AbstractType& other, |
| 2884 bool check_type_parameter_bound) const { | 2943 bool check_type_parameter_bound) const { |
| 2885 if (raw() == other.raw()) { | 2944 if (raw() == other.raw()) { |
| 2886 return true; | 2945 return true; |
| 2887 } | 2946 } |
| 2888 if (!other.IsTypeParameter()) { | 2947 if (!other.IsTypeParameter()) { |
| 2889 return false; | 2948 return false; |
| 2890 } | 2949 } |
| 2891 const TypeParameter& other_type_param = TypeParameter::Cast(other); | 2950 const TypeParameter& other_type_param = TypeParameter::Cast(other); |
| 2892 // IsIdentical may be called on type parameters belonging to different | 2951 // IsIdentical may be called on type parameters belonging to different |
| 2893 // classes, e.g. to an interface and to its default factory class. | 2952 // classes, e.g. to an interface and to its default factory class. |
| 2894 // Therefore, both type parameters may have different parameterized classes | 2953 // Therefore, both type parameters may have different parameterized classes |
| 2895 // and different indices. Compare the type parameter names only, and their | 2954 // and different indices. Compare the type parameter names only, and their |
| 2896 // bounds if requested. | 2955 // bounds if requested. |
| 2897 String& name = String::Handle(Name()); | 2956 String& type_param_name = String::Handle(name()); |
| 2898 String& other_name = String::Handle(other_type_param.Name()); | 2957 String& other_type_param_name = String::Handle(other_type_param.name()); |
| 2899 if (!name.Equals(other_name)) { | 2958 if (!type_param_name.Equals(other_type_param_name)) { |
| 2900 return false; | 2959 return false; |
| 2901 } | 2960 } |
| 2902 if (check_type_parameter_bound) { | 2961 if (check_type_parameter_bound) { |
| 2903 AbstractType& this_bound = AbstractType::Handle(bound()); | 2962 AbstractType& this_bound = AbstractType::Handle(bound()); |
| 2904 AbstractType& other_bound = AbstractType::Handle(other_type_param.bound()); | 2963 AbstractType& other_bound = AbstractType::Handle(other_type_param.bound()); |
| 2905 // Bounds are only checked at the top level. | 2964 // Bounds are only checked at the top level. |
| 2906 const bool check_type_parameter_bounds = false; | 2965 const bool check_type_parameter_bounds = false; |
| 2907 if (!this_bound.IsIdentical(other_bound, check_type_parameter_bounds)) { | 2966 if (!this_bound.IsIdentical(other_bound, check_type_parameter_bounds)) { |
| 2908 return false; | 2967 return false; |
| 2909 } | 2968 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 } | 3089 } |
| 3031 | 3090 |
| 3032 | 3091 |
| 3033 bool AbstractTypeArguments::IsUninstantiatedIdentity() const { | 3092 bool AbstractTypeArguments::IsUninstantiatedIdentity() const { |
| 3034 // AbstractTypeArguments is an abstract class. | 3093 // AbstractTypeArguments is an abstract class. |
| 3035 UNREACHABLE(); | 3094 UNREACHABLE(); |
| 3036 return false; | 3095 return false; |
| 3037 } | 3096 } |
| 3038 | 3097 |
| 3039 | 3098 |
| 3040 RawString* AbstractTypeArguments::SubvectorName(intptr_t from_index, | 3099 RawString* AbstractTypeArguments::SubvectorName( |
| 3041 intptr_t len) const { | 3100 intptr_t from_index, |
| 3101 intptr_t len, |
| 3102 NameVisibility name_visibility) const { |
| 3042 ASSERT(from_index + len <= Length()); | 3103 ASSERT(from_index + len <= Length()); |
| 3043 String& name = String::Handle(); | 3104 String& name = String::Handle(); |
| 3044 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". | 3105 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". |
| 3045 const Array& strings = Array::Handle(Array::New(num_strings)); | 3106 const Array& strings = Array::Handle(Array::New(num_strings)); |
| 3046 intptr_t s = 0; | 3107 intptr_t s = 0; |
| 3047 strings.SetAt(s++, String::Handle(String::NewSymbol("<"))); | 3108 strings.SetAt(s++, String::Handle(String::NewSymbol("<"))); |
| 3048 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); | 3109 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); |
| 3049 AbstractType& type = AbstractType::Handle(); | 3110 AbstractType& type = AbstractType::Handle(); |
| 3050 for (intptr_t i = 0; i < len; i++) { | 3111 for (intptr_t i = 0; i < len; i++) { |
| 3051 type = TypeAt(from_index + i); | 3112 type = TypeAt(from_index + i); |
| 3052 name = type.Name(); | 3113 name = type.BuildName(name_visibility); |
| 3053 strings.SetAt(s++, name); | 3114 strings.SetAt(s++, name); |
| 3054 if (i < len - 1) { | 3115 if (i < len - 1) { |
| 3055 strings.SetAt(s++, kCommaSpace); | 3116 strings.SetAt(s++, kCommaSpace); |
| 3056 } | 3117 } |
| 3057 } | 3118 } |
| 3058 strings.SetAt(s++, String::Handle(String::NewSymbol(">"))); | 3119 strings.SetAt(s++, String::Handle(String::NewSymbol(">"))); |
| 3059 ASSERT(s == num_strings); | 3120 ASSERT(s == num_strings); |
| 3060 name = String::ConcatAll(strings); | 3121 name = String::ConcatAll(strings); |
| 3061 return String::NewSymbol(name); | 3122 return String::NewSymbol(name); |
| 3062 } | 3123 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 if (bound.IsMalformed()) { | 3269 if (bound.IsMalformed()) { |
| 3209 malformed_bound_error = bound.malformed_error(); | 3270 malformed_bound_error = bound.malformed_error(); |
| 3210 } else if (!bound.IsInstantiated()) { | 3271 } else if (!bound.IsInstantiated()) { |
| 3211 bound = bound.InstantiateFrom(bounds_instantiator); | 3272 bound = bound.InstantiateFrom(bounds_instantiator); |
| 3212 } | 3273 } |
| 3213 if (!malformed_bound_error.IsNull() || | 3274 if (!malformed_bound_error.IsNull() || |
| 3214 !this_type_arg.IsSubtypeOf(bound, malformed_error)) { | 3275 !this_type_arg.IsSubtypeOf(bound, malformed_error)) { |
| 3215 // Ignore this bound error if another malformed error was already | 3276 // Ignore this bound error if another malformed error was already |
| 3216 // reported for this type test. | 3277 // reported for this type test. |
| 3217 if (malformed_error->IsNull()) { | 3278 if (malformed_error->IsNull()) { |
| 3218 const String& type_arg_name = String::Handle(this_type_arg.Name()); | 3279 const String& type_arg_name = |
| 3280 String::Handle(this_type_arg.UserVisibleName()); |
| 3219 const String& class_name = String::Handle(cls.Name()); | 3281 const String& class_name = String::Handle(cls.Name()); |
| 3220 const String& bound_name = String::Handle(bound.Name()); | 3282 const String& bound_name = String::Handle(bound.UserVisibleName()); |
| 3221 const Script& script = Script::Handle(cls.script()); | 3283 const Script& script = Script::Handle(cls.script()); |
| 3222 // Since the bound was canonicalized, its token index was lost, | 3284 // Since the bound was canonicalized, its token index was lost, |
| 3223 // therefore, use the token index of the corresponding type parameter. | 3285 // therefore, use the token index of the corresponding type parameter. |
| 3224 *malformed_error ^= FormatError(malformed_bound_error, | 3286 *malformed_error ^= FormatError(malformed_bound_error, |
| 3225 script, cls_type_param.token_pos(), | 3287 script, cls_type_param.token_pos(), |
| 3226 "type argument '%s' does not " | 3288 "type argument '%s' does not " |
| 3227 "extend bound '%s' of '%s'\n", | 3289 "extend bound '%s' of '%s'\n", |
| 3228 type_arg_name.ToCString(), | 3290 type_arg_name.ToCString(), |
| 3229 bound_name.ToCString(), | 3291 bound_name.ToCString(), |
| 3230 class_name.ToCString()); | 3292 class_name.ToCString()); |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4117 } | 4179 } |
| 4118 ASSERT(closure_function.signature_class() == signature_class.raw()); | 4180 ASSERT(closure_function.signature_class() == signature_class.raw()); |
| 4119 set_implicit_closure_function(closure_function); | 4181 set_implicit_closure_function(closure_function); |
| 4120 ASSERT(closure_function.IsImplicitClosureFunction()); | 4182 ASSERT(closure_function.IsImplicitClosureFunction()); |
| 4121 return closure_function.raw(); | 4183 return closure_function.raw(); |
| 4122 } | 4184 } |
| 4123 | 4185 |
| 4124 | 4186 |
| 4125 RawString* Function::BuildSignature( | 4187 RawString* Function::BuildSignature( |
| 4126 bool instantiate, | 4188 bool instantiate, |
| 4189 NameVisibility name_visibility, |
| 4127 const AbstractTypeArguments& instantiator) const { | 4190 const AbstractTypeArguments& instantiator) const { |
| 4128 const GrowableObjectArray& pieces = | 4191 const GrowableObjectArray& pieces = |
| 4129 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 4192 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 4130 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); | 4193 const String& kCommaSpace = String::Handle(String::NewSymbol(", ")); |
| 4131 const String& kColonSpace = String::Handle(String::NewSymbol(": ")); | 4194 const String& kColonSpace = String::Handle(String::NewSymbol(": ")); |
| 4132 const String& kLParen = String::Handle(String::NewSymbol("(")); | 4195 const String& kLParen = String::Handle(String::NewSymbol("(")); |
| 4133 const String& kRParen = String::Handle(String::NewSymbol(") => ")); | 4196 const String& kRParen = String::Handle(String::NewSymbol(") => ")); |
| 4134 const String& kLBracket = String::Handle(String::NewSymbol("[")); | 4197 const String& kLBracket = String::Handle(String::NewSymbol("[")); |
| 4135 const String& kRBracket = String::Handle(String::NewSymbol("]")); | 4198 const String& kRBracket = String::Handle(String::NewSymbol("]")); |
| 4136 String& name = String::Handle(); | 4199 String& name = String::Handle(); |
| 4137 if (!instantiate && !is_static()) { | 4200 if (!instantiate && !is_static()) { |
| 4201 // Prefix the signature with its type parameters, if any (e.g. "<K, V>"). |
| 4202 // The signature of static functions cannot be type parameterized. |
| 4138 const String& kSpaceExtendsSpace = | 4203 const String& kSpaceExtendsSpace = |
| 4139 String::Handle(String::NewSymbol(" extends ")); | 4204 String::Handle(String::NewSymbol(" extends ")); |
| 4140 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); | 4205 const String& kLAngleBracket = String::Handle(String::NewSymbol("<")); |
| 4141 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); | 4206 const String& kRAngleBracket = String::Handle(String::NewSymbol(">")); |
| 4142 const Class& function_class = Class::Handle(owner()); | 4207 const Class& function_class = Class::Handle(owner()); |
| 4143 ASSERT(!function_class.IsNull()); | 4208 ASSERT(!function_class.IsNull()); |
| 4144 const TypeArguments& type_parameters = TypeArguments::Handle( | 4209 const TypeArguments& type_parameters = TypeArguments::Handle( |
| 4145 function_class.type_parameters()); | 4210 function_class.type_parameters()); |
| 4146 if (!type_parameters.IsNull()) { | 4211 if (!type_parameters.IsNull()) { |
| 4147 intptr_t num_type_parameters = type_parameters.Length(); | 4212 intptr_t num_type_parameters = type_parameters.Length(); |
| 4148 pieces.Add(kLAngleBracket); | 4213 pieces.Add(kLAngleBracket); |
| 4149 TypeParameter& type_parameter = TypeParameter::Handle(); | 4214 TypeParameter& type_parameter = TypeParameter::Handle(); |
| 4150 AbstractType& bound = AbstractType::Handle(); | 4215 AbstractType& bound = AbstractType::Handle(); |
| 4151 for (intptr_t i = 0; i < num_type_parameters; i++) { | 4216 for (intptr_t i = 0; i < num_type_parameters; i++) { |
| 4152 type_parameter ^= type_parameters.TypeAt(i); | 4217 type_parameter ^= type_parameters.TypeAt(i); |
| 4153 name = type_parameter.Name(); | 4218 name = type_parameter.name(); |
| 4154 pieces.Add(name); | 4219 pieces.Add(name); |
| 4155 bound = type_parameter.bound(); | 4220 bound = type_parameter.bound(); |
| 4156 if (!bound.IsNull() && !bound.IsDynamicType()) { | 4221 if (!bound.IsNull() && !bound.IsDynamicType()) { |
| 4157 pieces.Add(kSpaceExtendsSpace); | 4222 pieces.Add(kSpaceExtendsSpace); |
| 4158 name = bound.Name(); | 4223 name = bound.BuildName(name_visibility); |
| 4159 pieces.Add(name); | 4224 pieces.Add(name); |
| 4160 } | 4225 } |
| 4161 if (i < num_type_parameters - 1) { | 4226 if (i < num_type_parameters - 1) { |
| 4162 pieces.Add(kCommaSpace); | 4227 pieces.Add(kCommaSpace); |
| 4163 } | 4228 } |
| 4164 } | 4229 } |
| 4165 pieces.Add(kRAngleBracket); | 4230 pieces.Add(kRAngleBracket); |
| 4166 } | 4231 } |
| 4167 } | 4232 } |
| 4168 AbstractType& param_type = AbstractType::Handle(); | 4233 AbstractType& param_type = AbstractType::Handle(); |
| 4169 const intptr_t num_params = NumberOfParameters(); | 4234 const intptr_t num_params = NumberOfParameters(); |
| 4170 const intptr_t num_fixed_params = num_fixed_parameters(); | 4235 const intptr_t num_fixed_params = num_fixed_parameters(); |
| 4171 const intptr_t num_opt_params = num_optional_parameters(); | 4236 const intptr_t num_opt_params = num_optional_parameters(); |
| 4172 ASSERT((num_fixed_params + num_opt_params) == num_params); | 4237 ASSERT((num_fixed_params + num_opt_params) == num_params); |
| 4173 pieces.Add(kLParen); | 4238 pieces.Add(kLParen); |
| 4174 for (intptr_t i = 0; i < num_fixed_params; i++) { | 4239 for (intptr_t i = 0; i < num_fixed_params; i++) { |
| 4175 param_type = ParameterTypeAt(i); | 4240 param_type = ParameterTypeAt(i); |
| 4176 ASSERT(!param_type.IsNull()); | 4241 ASSERT(!param_type.IsNull()); |
| 4177 if (instantiate && !param_type.IsInstantiated()) { | 4242 if (instantiate && !param_type.IsInstantiated()) { |
| 4178 param_type = param_type.InstantiateFrom(instantiator); | 4243 param_type = param_type.InstantiateFrom(instantiator); |
| 4179 } | 4244 } |
| 4180 name = param_type.Name(); | 4245 name = param_type.BuildName(name_visibility); |
| 4181 pieces.Add(name); | 4246 pieces.Add(name); |
| 4182 if (i != (num_params - 1)) { | 4247 if (i != (num_params - 1)) { |
| 4183 pieces.Add(kCommaSpace); | 4248 pieces.Add(kCommaSpace); |
| 4184 } | 4249 } |
| 4185 } | 4250 } |
| 4186 if (num_opt_params > 0) { | 4251 if (num_opt_params > 0) { |
| 4187 pieces.Add(kLBracket); | 4252 pieces.Add(kLBracket); |
| 4188 for (intptr_t i = num_fixed_params; i < num_params; i++) { | 4253 for (intptr_t i = num_fixed_params; i < num_params; i++) { |
| 4189 name = ParameterNameAt(i); | 4254 name = ParameterNameAt(i); |
| 4190 pieces.Add(name); | 4255 pieces.Add(name); |
| 4191 pieces.Add(kColonSpace); | 4256 pieces.Add(kColonSpace); |
| 4192 param_type = ParameterTypeAt(i); | 4257 param_type = ParameterTypeAt(i); |
| 4193 if (instantiate && !param_type.IsInstantiated()) { | 4258 if (instantiate && !param_type.IsInstantiated()) { |
| 4194 param_type = param_type.InstantiateFrom(instantiator); | 4259 param_type = param_type.InstantiateFrom(instantiator); |
| 4195 } | 4260 } |
| 4196 ASSERT(!param_type.IsNull()); | 4261 ASSERT(!param_type.IsNull()); |
| 4197 name = param_type.Name(); | 4262 name = param_type.BuildName(name_visibility); |
| 4198 pieces.Add(name); | 4263 pieces.Add(name); |
| 4199 if (i != (num_params - 1)) { | 4264 if (i != (num_params - 1)) { |
| 4200 pieces.Add(kCommaSpace); | 4265 pieces.Add(kCommaSpace); |
| 4201 } | 4266 } |
| 4202 } | 4267 } |
| 4203 pieces.Add(kRBracket); | 4268 pieces.Add(kRBracket); |
| 4204 } | 4269 } |
| 4205 pieces.Add(kRParen); | 4270 pieces.Add(kRParen); |
| 4206 AbstractType& res_type = AbstractType::Handle(result_type()); | 4271 AbstractType& res_type = AbstractType::Handle(result_type()); |
| 4207 if (instantiate && !res_type.IsInstantiated()) { | 4272 if (instantiate && !res_type.IsInstantiated()) { |
| 4208 res_type = res_type.InstantiateFrom(instantiator); | 4273 res_type = res_type.InstantiateFrom(instantiator); |
| 4209 } | 4274 } |
| 4210 name = res_type.Name(); | 4275 name = res_type.BuildName(name_visibility); |
| 4211 pieces.Add(name); | 4276 pieces.Add(name); |
| 4212 const Array& strings = Array::Handle(Array::MakeArray(pieces)); | 4277 const Array& strings = Array::Handle(Array::MakeArray(pieces)); |
| 4213 return String::NewSymbol(String::Handle(String::ConcatAll(strings))); | 4278 return String::NewSymbol(String::Handle(String::ConcatAll(strings))); |
| 4214 } | 4279 } |
| 4215 | 4280 |
| 4216 | 4281 |
| 4217 bool Function::HasInstantiatedSignature() const { | 4282 bool Function::HasInstantiatedSignature() const { |
| 4218 AbstractType& type = AbstractType::Handle(result_type()); | 4283 AbstractType& type = AbstractType::Handle(result_type()); |
| 4219 if (!type.IsInstantiated()) { | 4284 if (!type.IsInstantiated()) { |
| 4220 return false; | 4285 return false; |
| (...skipping 6559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10780 const String& str = String::Handle(pattern()); | 10845 const String& str = String::Handle(pattern()); |
| 10781 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10846 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10782 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10847 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10783 char* chars = reinterpret_cast<char*>( | 10848 char* chars = reinterpret_cast<char*>( |
| 10784 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10849 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10785 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10850 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10786 return chars; | 10851 return chars; |
| 10787 } | 10852 } |
| 10788 | 10853 |
| 10789 } // namespace dart | 10854 } // namespace dart |
| OLD | NEW |