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

Side by Side Diff: vm/object.cc

Issue 11667012: Convert all symbols accessor to return read only handles so that it is not necessary to create a ne… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 intptr_t suffix_len = at_pos - dot_pos; 180 intptr_t suffix_len = at_pos - dot_pos;
181 if (suffix_len > 1) { 181 if (suffix_len > 1) {
182 // This is a named constructor. Add the name back to the string. 182 // This is a named constructor. Add the name back to the string.
183 const String& suffix = 183 const String& suffix =
184 String::Handle(String::SubString(name, dot_pos, suffix_len)); 184 String::Handle(String::SubString(name, dot_pos, suffix_len));
185 return String::Concat(result, suffix); 185 return String::Concat(result, suffix);
186 } 186 }
187 187
188 if (is_setter) { 188 if (is_setter) {
189 // Setters need to end with '='. 189 // Setters need to end with '='.
190 const String& suffix = String::Handle(Symbols::Equals()); 190 return String::Concat(result, Symbols::Equals());
191 return String::Concat(result, suffix);
192 } 191 }
193 192
194 return result.raw(); 193 return result.raw();
195 } 194 }
196 195
197 196
198 template<typename type> 197 template<typename type>
199 static bool IsSpecialCharacter(type value) { 198 static bool IsSpecialCharacter(type value) {
200 return ((value == '"') || 199 return ((value == '"') ||
201 (value == '\n') || 200 (value == '\n') ||
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); 423 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld);
425 *empty_array_ = reinterpret_cast<RawArray*>(address + kHeapObjectTag); 424 *empty_array_ = reinterpret_cast<RawArray*>(address + kHeapObjectTag);
426 InitializeObject(address, kArrayCid, Array::InstanceSize(0)); 425 InitializeObject(address, kArrayCid, Array::InstanceSize(0));
427 empty_array_->raw()->ptr()->length_ = Smi::New(0); 426 empty_array_->raw()->ptr()->length_ = Smi::New(0);
428 } 427 }
429 } 428 }
430 429
431 430
432 #define SET_CLASS_NAME(class_name, name) \ 431 #define SET_CLASS_NAME(class_name, name) \
433 cls = class_name##_class(); \ 432 cls = class_name##_class(); \
434 str = Symbols::name(); \ 433 cls.set_name(Symbols::name()); \
435 cls.set_name(str); \
436 434
437 void Object::RegisterSingletonClassNames() { 435 void Object::RegisterSingletonClassNames() {
438 Class& cls = Class::Handle(); 436 Class& cls = Class::Handle();
439 String& str = String::Handle();
440 437
441 // Set up names for all VM singleton classes. 438 // Set up names for all VM singleton classes.
442 SET_CLASS_NAME(class, Class); 439 SET_CLASS_NAME(class, Class);
443 SET_CLASS_NAME(null, Null); 440 SET_CLASS_NAME(null, Null);
444 SET_CLASS_NAME(dynamic, Dynamic); 441 SET_CLASS_NAME(dynamic, Dynamic);
445 SET_CLASS_NAME(void, Void); 442 SET_CLASS_NAME(void, Void);
446 SET_CLASS_NAME(unresolved_class, UnresolvedClass); 443 SET_CLASS_NAME(unresolved_class, UnresolvedClass);
447 SET_CLASS_NAME(type_arguments, TypeArguments); 444 SET_CLASS_NAME(type_arguments, TypeArguments);
448 SET_CLASS_NAME(instantiated_type_arguments, InstantiatedTypeArguments); 445 SET_CLASS_NAME(instantiated_type_arguments, InstantiatedTypeArguments);
449 SET_CLASS_NAME(patch_class, PatchClass); 446 SET_CLASS_NAME(patch_class, PatchClass);
(...skipping 20 matching lines...) Expand all
470 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); 467 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache);
471 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); 468 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache);
472 SET_CLASS_NAME(api_error, ApiError); 469 SET_CLASS_NAME(api_error, ApiError);
473 SET_CLASS_NAME(language_error, LanguageError); 470 SET_CLASS_NAME(language_error, LanguageError);
474 SET_CLASS_NAME(unhandled_exception, UnhandledException); 471 SET_CLASS_NAME(unhandled_exception, UnhandledException);
475 SET_CLASS_NAME(unwind_error, UnwindError); 472 SET_CLASS_NAME(unwind_error, UnwindError);
476 473
477 // Set up names for object array and one byte string class which are 474 // Set up names for object array and one byte string class which are
478 // pre-allocated in the vm isolate also. 475 // pre-allocated in the vm isolate also.
479 cls = Dart::vm_isolate()->object_store()->array_class(); 476 cls = Dart::vm_isolate()->object_store()->array_class();
480 str = Symbols::ObjectArray(); 477 cls.set_name(Symbols::ObjectArray());
481 cls.set_name(str);
482 cls = Dart::vm_isolate()->object_store()->one_byte_string_class(); 478 cls = Dart::vm_isolate()->object_store()->one_byte_string_class();
483 str = Symbols::OneByteString(); 479 cls.set_name(Symbols::OneByteString());
484 cls.set_name(str);
485 } 480 }
486 481
487 482
488 // Make unused space in an object whose type has been transformed safe 483 // Make unused space in an object whose type has been transformed safe
489 // for traversing during GC. 484 // for traversing during GC.
490 // The unused part of the transformed object is marked as an Array 485 // The unused part of the transformed object is marked as an Array
491 // object or a regular Object so that it can be traversed during garbage 486 // object or a regular Object so that it can be traversed during garbage
492 // collection. 487 // collection.
493 void Object::MakeUnusedSpaceTraversable(const Object& obj, 488 void Object::MakeUnusedSpaceTraversable(const Object& obj,
494 intptr_t original_size, 489 intptr_t original_size,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 611
617 Context& context = Context::Handle(Context::New(0, Heap::kOld)); 612 Context& context = Context::Handle(Context::New(0, Heap::kOld));
618 object_store->set_empty_context(context); 613 object_store->set_empty_context(context);
619 614
620 // Now that the symbol table is initialized and that the core dictionary as 615 // Now that the symbol table is initialized and that the core dictionary as
621 // well as the core implementation dictionary have been setup, preallocate 616 // well as the core implementation dictionary have been setup, preallocate
622 // remaining classes and register them by name in the dictionaries. 617 // remaining classes and register them by name in the dictionaries.
623 String& name = String::Handle(); 618 String& name = String::Handle();
624 cls = Class::New<Bool>(); 619 cls = Class::New<Bool>();
625 object_store->set_bool_class(cls); 620 object_store->set_bool_class(cls);
626 name = Symbols::Bool(); 621 RegisterClass(cls, Symbols::Bool(), core_lib);
627 RegisterClass(cls, name, core_lib);
628 pending_classes.Add(cls, Heap::kOld); 622 pending_classes.Add(cls, Heap::kOld);
629 623
630 cls = object_store->array_class(); // Was allocated above. 624 cls = object_store->array_class(); // Was allocated above.
631 name = Symbols::ObjectArray(); 625 RegisterPrivateClass(cls, Symbols::ObjectArray(), core_lib);
632 RegisterPrivateClass(cls, name, core_lib);
633 pending_classes.Add(cls, Heap::kOld); 626 pending_classes.Add(cls, Heap::kOld);
634 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 627 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
635 type ^= Type::New(Object::Handle(cls.raw()), 628 type ^= Type::New(Object::Handle(cls.raw()),
636 TypeArguments::Handle(), 629 TypeArguments::Handle(),
637 Scanner::kDummyTokenIndex); 630 Scanner::kDummyTokenIndex);
638 type.set_is_finalized_instantiated(); 631 type.set_is_finalized_instantiated();
639 type ^= type.Canonicalize(); 632 type ^= type.Canonicalize();
640 object_store->set_array_type(type); 633 object_store->set_array_type(type);
641 634
642 cls = object_store->growable_object_array_class(); // Was allocated above. 635 cls = object_store->growable_object_array_class(); // Was allocated above.
643 name = Symbols::GrowableObjectArray(); 636 RegisterPrivateClass(cls, Symbols::GrowableObjectArray(), core_lib);
644 RegisterPrivateClass(cls, name, core_lib);
645 pending_classes.Add(cls, Heap::kOld); 637 pending_classes.Add(cls, Heap::kOld);
646 638
647 cls = Class::New<ImmutableArray>(); 639 cls = Class::New<ImmutableArray>();
648 object_store->set_immutable_array_class(cls); 640 object_store->set_immutable_array_class(cls);
649 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); 641 cls.set_type_arguments_field_offset(Array::type_arguments_offset());
650 ASSERT(object_store->immutable_array_class() != object_store->array_class()); 642 ASSERT(object_store->immutable_array_class() != object_store->array_class());
651 name = Symbols::ImmutableArray(); 643 RegisterPrivateClass(cls, Symbols::ImmutableArray(), core_lib);
652 RegisterPrivateClass(cls, name, core_lib);
653 pending_classes.Add(cls, Heap::kOld); 644 pending_classes.Add(cls, Heap::kOld);
654 645
655 cls = object_store->one_byte_string_class(); // Was allocated above. 646 cls = object_store->one_byte_string_class(); // Was allocated above.
656 name = Symbols::OneByteString(); 647 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib);
657 RegisterPrivateClass(cls, name, core_lib);
658 pending_classes.Add(cls, Heap::kOld); 648 pending_classes.Add(cls, Heap::kOld);
659 649
660 cls = object_store->two_byte_string_class(); // Was allocated above. 650 cls = object_store->two_byte_string_class(); // Was allocated above.
661 name = Symbols::TwoByteString(); 651 RegisterPrivateClass(cls, Symbols::TwoByteString(), core_lib);
662 RegisterPrivateClass(cls, name, core_lib);
663 pending_classes.Add(cls, Heap::kOld); 652 pending_classes.Add(cls, Heap::kOld);
664 653
665 cls = Class::NewStringClass(kExternalOneByteStringCid); 654 cls = Class::NewStringClass(kExternalOneByteStringCid);
666 object_store->set_external_one_byte_string_class(cls); 655 object_store->set_external_one_byte_string_class(cls);
667 name = Symbols::ExternalOneByteString(); 656 RegisterPrivateClass(cls, Symbols::ExternalOneByteString(), core_lib);
668 RegisterPrivateClass(cls, name, core_lib);
669 pending_classes.Add(cls, Heap::kOld); 657 pending_classes.Add(cls, Heap::kOld);
670 658
671 cls = Class::NewStringClass(kExternalTwoByteStringCid); 659 cls = Class::NewStringClass(kExternalTwoByteStringCid);
672 object_store->set_external_two_byte_string_class(cls); 660 object_store->set_external_two_byte_string_class(cls);
673 name = Symbols::ExternalTwoByteString(); 661 RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib);
674 RegisterPrivateClass(cls, name, core_lib);
675 pending_classes.Add(cls, Heap::kOld); 662 pending_classes.Add(cls, Heap::kOld);
676 663
677 cls = Class::New<Stacktrace>(); 664 cls = Class::New<Stacktrace>();
678 object_store->set_stacktrace_class(cls); 665 object_store->set_stacktrace_class(cls);
679 name = Symbols::Stacktrace(); 666 RegisterClass(cls, Symbols::Stacktrace(), core_lib);
680 RegisterClass(cls, name, core_lib);
681 pending_classes.Add(cls, Heap::kOld); 667 pending_classes.Add(cls, Heap::kOld);
682 // Super type set below, after Object is allocated. 668 // Super type set below, after Object is allocated.
683 669
684 cls = Class::New<JSRegExp>(); 670 cls = Class::New<JSRegExp>();
685 object_store->set_jsregexp_class(cls); 671 object_store->set_jsregexp_class(cls);
686 name = Symbols::JSSyntaxRegExp(); 672 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib);
687 RegisterPrivateClass(cls, name, core_lib);
688 pending_classes.Add(cls, Heap::kOld); 673 pending_classes.Add(cls, Heap::kOld);
689 674
690 // Initialize the base interfaces used by the core VM classes. 675 // Initialize the base interfaces used by the core VM classes.
691 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false)); 676 const Script& script = Script::Handle(Bootstrap::LoadCoreScript(false));
692 677
693 // Allocate and initialize the pre-allocated classes in the core library. 678 // Allocate and initialize the pre-allocated classes in the core library.
694 cls = Class::New<Instance>(kInstanceCid); 679 cls = Class::New<Instance>(kInstanceCid);
695 object_store->set_object_class(cls); 680 object_store->set_object_class(cls);
696 name = Symbols::Object(); 681 cls.set_name(Symbols::Object());
697 cls.set_name(name);
698 cls.set_script(script); 682 cls.set_script(script);
699 cls.set_is_prefinalized(); 683 cls.set_is_prefinalized();
700 core_lib.AddClass(cls); 684 core_lib.AddClass(cls);
701 pending_classes.Add(cls, Heap::kOld); 685 pending_classes.Add(cls, Heap::kOld);
702 type = Type::NewNonParameterizedType(cls); 686 type = Type::NewNonParameterizedType(cls);
703 object_store->set_object_type(type); 687 object_store->set_object_type(type);
704 688
705 cls = object_store->type_class(); 689 cls = object_store->type_class();
706 name = Symbols::Type(); 690 RegisterPrivateClass(cls, Symbols::Type(), core_lib);
707 RegisterPrivateClass(cls, name, core_lib);
708 pending_classes.Add(cls, Heap::kOld); 691 pending_classes.Add(cls, Heap::kOld);
709 692
710 cls = object_store->type_parameter_class(); 693 cls = object_store->type_parameter_class();
711 name = Symbols::TypeParameter(); 694 RegisterPrivateClass(cls, Symbols::TypeParameter(), core_lib);
712 RegisterPrivateClass(cls, name, core_lib);
713 pending_classes.Add(cls, Heap::kOld); 695 pending_classes.Add(cls, Heap::kOld);
714 696
715 cls = Class::New<Integer>(); 697 cls = Class::New<Integer>();
716 object_store->set_integer_implementation_class(cls); 698 object_store->set_integer_implementation_class(cls);
717 name = Symbols::IntegerImplementation(); 699 RegisterPrivateClass(cls, Symbols::IntegerImplementation(), core_lib);
718 RegisterPrivateClass(cls, name, core_lib);
719 pending_classes.Add(cls, Heap::kOld); 700 pending_classes.Add(cls, Heap::kOld);
720 701
721 cls = Class::New<Smi>(); 702 cls = Class::New<Smi>();
722 object_store->set_smi_class(cls); 703 object_store->set_smi_class(cls);
723 name = Symbols::Smi(); 704 RegisterPrivateClass(cls, Symbols::_Smi(), core_lib);
724 RegisterPrivateClass(cls, name, core_lib);
725 pending_classes.Add(cls, Heap::kOld); 705 pending_classes.Add(cls, Heap::kOld);
726 706
727 cls = Class::New<Mint>(); 707 cls = Class::New<Mint>();
728 object_store->set_mint_class(cls); 708 object_store->set_mint_class(cls);
729 name = Symbols::Mint(); 709 RegisterPrivateClass(cls, Symbols::_Mint(), core_lib);
730 RegisterPrivateClass(cls, name, core_lib);
731 pending_classes.Add(cls, Heap::kOld); 710 pending_classes.Add(cls, Heap::kOld);
732 711
733 cls = Class::New<Bigint>(); 712 cls = Class::New<Bigint>();
734 object_store->set_bigint_class(cls); 713 object_store->set_bigint_class(cls);
735 name = Symbols::Bigint(); 714 RegisterPrivateClass(cls, Symbols::_Bigint(), core_lib);
736 RegisterPrivateClass(cls, name, core_lib);
737 pending_classes.Add(cls, Heap::kOld); 715 pending_classes.Add(cls, Heap::kOld);
738 716
739 cls = Class::New<Double>(); 717 cls = Class::New<Double>();
740 object_store->set_double_class(cls); 718 object_store->set_double_class(cls);
741 name = Symbols::Double(); 719 RegisterPrivateClass(cls, Symbols::_Double(), core_lib);
742 RegisterPrivateClass(cls, name, core_lib);
743 pending_classes.Add(cls, Heap::kOld); 720 pending_classes.Add(cls, Heap::kOld);
744 721
745 cls = Class::New<WeakProperty>(); 722 cls = Class::New<WeakProperty>();
746 object_store->set_weak_property_class(cls); 723 object_store->set_weak_property_class(cls);
747 name = Symbols::_WeakProperty(); 724 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib);
748 RegisterPrivateClass(cls, name, core_lib);
749 725
750 Library::InitScalarlistLibrary(isolate); 726 Library::InitScalarlistLibrary(isolate);
751 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary()); 727 Library& scalarlist_lib = Library::Handle(Library::ScalarlistLibrary());
752 728
753 cls = Class::New<Int8Array>(); 729 cls = Class::New<Int8Array>();
754 object_store->set_int8_array_class(cls); 730 object_store->set_int8_array_class(cls);
755 name = Symbols::_Int8Array(); 731 RegisterPrivateClass(cls, Symbols::_Int8Array(), scalarlist_lib);
756 RegisterPrivateClass(cls, name, scalarlist_lib);
757 732
758 cls = Class::New<Uint8Array>(); 733 cls = Class::New<Uint8Array>();
759 object_store->set_uint8_array_class(cls); 734 object_store->set_uint8_array_class(cls);
760 name = Symbols::_Uint8Array(); 735 RegisterPrivateClass(cls, Symbols::_Uint8Array(), scalarlist_lib);
761 RegisterPrivateClass(cls, name, scalarlist_lib);
762 736
763 cls = Class::New<Uint8ClampedArray>(); 737 cls = Class::New<Uint8ClampedArray>();
764 object_store->set_uint8_clamped_array_class(cls); 738 object_store->set_uint8_clamped_array_class(cls);
765 name = Symbols::_Uint8ClampedArray(); 739 RegisterPrivateClass(cls, Symbols::_Uint8ClampedArray(), scalarlist_lib);
766 RegisterPrivateClass(cls, name, scalarlist_lib);
767 740
768 cls = Class::New<Int16Array>(); 741 cls = Class::New<Int16Array>();
769 object_store->set_int16_array_class(cls); 742 object_store->set_int16_array_class(cls);
770 name = Symbols::_Int16Array(); 743 RegisterPrivateClass(cls, Symbols::_Int16Array(), scalarlist_lib);
771 RegisterPrivateClass(cls, name, scalarlist_lib);
772 744
773 cls = Class::New<Uint16Array>(); 745 cls = Class::New<Uint16Array>();
774 object_store->set_uint16_array_class(cls); 746 object_store->set_uint16_array_class(cls);
775 name = Symbols::_Uint16Array(); 747 RegisterPrivateClass(cls, Symbols::_Uint16Array(), scalarlist_lib);
776 RegisterPrivateClass(cls, name, scalarlist_lib);
777 748
778 cls = Class::New<Int32Array>(); 749 cls = Class::New<Int32Array>();
779 object_store->set_int32_array_class(cls); 750 object_store->set_int32_array_class(cls);
780 name = Symbols::_Int32Array(); 751 RegisterPrivateClass(cls, Symbols::_Int32Array(), scalarlist_lib);
781 RegisterPrivateClass(cls, name, scalarlist_lib);
782 752
783 cls = Class::New<Uint32Array>(); 753 cls = Class::New<Uint32Array>();
784 object_store->set_uint32_array_class(cls); 754 object_store->set_uint32_array_class(cls);
785 name = Symbols::_Uint32Array(); 755 RegisterPrivateClass(cls, Symbols::_Uint32Array(), scalarlist_lib);
786 RegisterPrivateClass(cls, name, scalarlist_lib);
787 756
788 cls = Class::New<Int64Array>(); 757 cls = Class::New<Int64Array>();
789 object_store->set_int64_array_class(cls); 758 object_store->set_int64_array_class(cls);
790 name = Symbols::_Int64Array(); 759 RegisterPrivateClass(cls, Symbols::_Int64Array(), scalarlist_lib);
791 RegisterPrivateClass(cls, name, scalarlist_lib);
792 760
793 cls = Class::New<Uint64Array>(); 761 cls = Class::New<Uint64Array>();
794 object_store->set_uint64_array_class(cls); 762 object_store->set_uint64_array_class(cls);
795 name = Symbols::_Uint64Array(); 763 RegisterPrivateClass(cls, Symbols::_Uint64Array(), scalarlist_lib);
796 RegisterPrivateClass(cls, name, scalarlist_lib);
797 764
798 cls = Class::New<Float32Array>(); 765 cls = Class::New<Float32Array>();
799 object_store->set_float32_array_class(cls); 766 object_store->set_float32_array_class(cls);
800 name = Symbols::_Float32Array(); 767 RegisterPrivateClass(cls, Symbols::_Float32Array(), scalarlist_lib);
801 RegisterPrivateClass(cls, name, scalarlist_lib);
802 768
803 cls = Class::New<Float64Array>(); 769 cls = Class::New<Float64Array>();
804 object_store->set_float64_array_class(cls); 770 object_store->set_float64_array_class(cls);
805 name = Symbols::_Float64Array(); 771 RegisterPrivateClass(cls, Symbols::_Float64Array(), scalarlist_lib);
806 RegisterPrivateClass(cls, name, scalarlist_lib);
807 772
808 cls = Class::New<ExternalInt8Array>(); 773 cls = Class::New<ExternalInt8Array>();
809 object_store->set_external_int8_array_class(cls); 774 object_store->set_external_int8_array_class(cls);
810 name = Symbols::_ExternalInt8Array(); 775 RegisterPrivateClass(cls, Symbols::_ExternalInt8Array(), scalarlist_lib);
811 RegisterPrivateClass(cls, name, scalarlist_lib);
812 776
813 cls = Class::New<ExternalUint8Array>(); 777 cls = Class::New<ExternalUint8Array>();
814 object_store->set_external_uint8_array_class(cls); 778 object_store->set_external_uint8_array_class(cls);
815 name = Symbols::_ExternalUint8Array(); 779 RegisterPrivateClass(cls, Symbols::_ExternalUint8Array(), scalarlist_lib);
816 RegisterPrivateClass(cls, name, scalarlist_lib);
817 780
818 cls = Class::New<ExternalUint8ClampedArray>(); 781 cls = Class::New<ExternalUint8ClampedArray>();
819 object_store->set_external_uint8_clamped_array_class(cls); 782 object_store->set_external_uint8_clamped_array_class(cls);
820 name = Symbols::_ExternalUint8ClampedArray(); 783 RegisterPrivateClass(cls,
821 RegisterPrivateClass(cls, name, scalarlist_lib); 784 Symbols::_ExternalUint8ClampedArray(),
785 scalarlist_lib);
822 786
823 cls = Class::New<ExternalInt16Array>(); 787 cls = Class::New<ExternalInt16Array>();
824 object_store->set_external_int16_array_class(cls); 788 object_store->set_external_int16_array_class(cls);
825 name = Symbols::_ExternalInt16Array(); 789 RegisterPrivateClass(cls, Symbols::_ExternalInt16Array(), scalarlist_lib);
826 RegisterPrivateClass(cls, name, scalarlist_lib);
827 790
828 cls = Class::New<ExternalUint16Array>(); 791 cls = Class::New<ExternalUint16Array>();
829 object_store->set_external_uint16_array_class(cls); 792 object_store->set_external_uint16_array_class(cls);
830 name = Symbols::_ExternalUint16Array(); 793 RegisterPrivateClass(cls, Symbols::_ExternalUint16Array(), scalarlist_lib);
831 RegisterPrivateClass(cls, name, scalarlist_lib);
832 794
833 cls = Class::New<ExternalInt32Array>(); 795 cls = Class::New<ExternalInt32Array>();
834 object_store->set_external_int32_array_class(cls); 796 object_store->set_external_int32_array_class(cls);
835 name = Symbols::_ExternalInt32Array(); 797 RegisterPrivateClass(cls, Symbols::_ExternalInt32Array(), scalarlist_lib);
836 RegisterPrivateClass(cls, name, scalarlist_lib);
837 798
838 cls = Class::New<ExternalUint32Array>(); 799 cls = Class::New<ExternalUint32Array>();
839 object_store->set_external_uint32_array_class(cls); 800 object_store->set_external_uint32_array_class(cls);
840 name = Symbols::_ExternalUint32Array(); 801 RegisterPrivateClass(cls, Symbols::_ExternalUint32Array(), scalarlist_lib);
841 RegisterPrivateClass(cls, name, scalarlist_lib);
842 802
843 cls = Class::New<ExternalInt64Array>(); 803 cls = Class::New<ExternalInt64Array>();
844 object_store->set_external_int64_array_class(cls); 804 object_store->set_external_int64_array_class(cls);
845 name = Symbols::_ExternalInt64Array(); 805 RegisterPrivateClass(cls, Symbols::_ExternalInt64Array(), scalarlist_lib);
846 RegisterPrivateClass(cls, name, scalarlist_lib);
847 806
848 cls = Class::New<ExternalUint64Array>(); 807 cls = Class::New<ExternalUint64Array>();
849 object_store->set_external_uint64_array_class(cls); 808 object_store->set_external_uint64_array_class(cls);
850 name = Symbols::_ExternalUint64Array(); 809 RegisterPrivateClass(cls, Symbols::_ExternalUint64Array(), scalarlist_lib);
851 RegisterPrivateClass(cls, name, scalarlist_lib);
852 810
853 cls = Class::New<ExternalFloat32Array>(); 811 cls = Class::New<ExternalFloat32Array>();
854 object_store->set_external_float32_array_class(cls); 812 object_store->set_external_float32_array_class(cls);
855 name = Symbols::_ExternalFloat32Array(); 813 RegisterPrivateClass(cls, Symbols::_ExternalFloat32Array(), scalarlist_lib);
856 RegisterPrivateClass(cls, name, scalarlist_lib);
857 814
858 cls = Class::New<ExternalFloat64Array>(); 815 cls = Class::New<ExternalFloat64Array>();
859 object_store->set_external_float64_array_class(cls); 816 object_store->set_external_float64_array_class(cls);
860 name = Symbols::_ExternalFloat64Array(); 817 RegisterPrivateClass(cls, Symbols::_ExternalFloat64Array(), scalarlist_lib);
861 RegisterPrivateClass(cls, name, scalarlist_lib);
862 818
863 // Set the super type of class Stacktrace to Object type so that the 819 // Set the super type of class Stacktrace to Object type so that the
864 // 'toString' method is implemented. 820 // 'toString' method is implemented.
865 cls = object_store->stacktrace_class(); 821 cls = object_store->stacktrace_class();
866 cls.set_super_type(type); 822 cls.set_super_type(type);
867 823
868 // Note: The abstract class Function is represented by VM class 824 // Note: The abstract class Function is represented by VM class
869 // DartFunction, not VM class Function. 825 // DartFunction, not VM class Function.
870 name = Symbols::Function();
871 cls = Class::New<DartFunction>(); 826 cls = Class::New<DartFunction>();
872 RegisterClass(cls, name, core_lib); 827 RegisterClass(cls, Symbols::Function(), core_lib);
873 pending_classes.Add(cls, Heap::kOld); 828 pending_classes.Add(cls, Heap::kOld);
874 type = Type::NewNonParameterizedType(cls); 829 type = Type::NewNonParameterizedType(cls);
875 object_store->set_function_type(type); 830 object_store->set_function_type(type);
876 831
877 cls = Class::New<Number>(); 832 cls = Class::New<Number>();
878 name = Symbols::Number(); 833 RegisterClass(cls, Symbols::Number(), core_lib);
879 RegisterClass(cls, name, core_lib);
880 pending_classes.Add(cls, Heap::kOld); 834 pending_classes.Add(cls, Heap::kOld);
881 type = Type::NewNonParameterizedType(cls); 835 type = Type::NewNonParameterizedType(cls);
882 object_store->set_number_type(type); 836 object_store->set_number_type(type);
883 837
884 name = Symbols::New("int"); 838 cls = Class::New<Instance>(Symbols::Int(), script, Scanner::kDummyTokenIndex);
885 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 839 RegisterClass(cls, Symbols::Int(), core_lib);
886 RegisterClass(cls, name, core_lib);
887 pending_classes.Add(cls, Heap::kOld); 840 pending_classes.Add(cls, Heap::kOld);
888 type = Type::NewNonParameterizedType(cls); 841 type = Type::NewNonParameterizedType(cls);
889 object_store->set_int_type(type); 842 object_store->set_int_type(type);
890 843
891 name = Symbols::New("double"); 844 cls = Class::New<Instance>(Symbols::Double(),
892 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 845 script,
893 RegisterClass(cls, name, core_lib); 846 Scanner::kDummyTokenIndex);
847 RegisterClass(cls, Symbols::Double(), core_lib);
894 pending_classes.Add(cls, Heap::kOld); 848 pending_classes.Add(cls, Heap::kOld);
895 type = Type::NewNonParameterizedType(cls); 849 type = Type::NewNonParameterizedType(cls);
896 object_store->set_double_type(type); 850 object_store->set_double_type(type);
897 851
898 name = Symbols::New("String"); 852 name = Symbols::New("String");
899 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 853 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex);
900 RegisterClass(cls, name, core_lib); 854 RegisterClass(cls, name, core_lib);
901 pending_classes.Add(cls, Heap::kOld); 855 pending_classes.Add(cls, Heap::kOld);
902 type = Type::NewNonParameterizedType(cls); 856 type = Type::NewNonParameterizedType(cls);
903 object_store->set_string_type(type); 857 object_store->set_string_type(type);
904 858
905 name = Symbols::New("List"); 859 cls = Class::New<Instance>(Symbols::List(),
906 cls = Class::New<Instance>(name, script, Scanner::kDummyTokenIndex); 860 script,
907 RegisterClass(cls, name, core_lib); 861 Scanner::kDummyTokenIndex);
862 RegisterClass(cls, Symbols::List(), core_lib);
908 pending_classes.Add(cls, Heap::kOld); 863 pending_classes.Add(cls, Heap::kOld);
909 object_store->set_list_class(cls); 864 object_store->set_list_class(cls);
910 865
911 cls = object_store->bool_class(); 866 cls = object_store->bool_class();
912 type = Type::NewNonParameterizedType(cls); 867 type = Type::NewNonParameterizedType(cls);
913 object_store->set_bool_type(type); 868 object_store->set_bool_type(type);
914 869
915 cls = object_store->smi_class(); 870 cls = object_store->smi_class();
916 type = Type::NewNonParameterizedType(cls); 871 type = Type::NewNonParameterizedType(cls);
917 object_store->set_smi_type(type); 872 object_store->set_smi_type(type);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1243
1289 RawString* Class::UserVisibleName() const { 1244 RawString* Class::UserVisibleName() const {
1290 if (FLAG_show_internal_names) { 1245 if (FLAG_show_internal_names) {
1291 return Name(); 1246 return Name();
1292 } 1247 }
1293 switch (id()) { 1248 switch (id()) {
1294 case kIntegerCid: 1249 case kIntegerCid:
1295 case kSmiCid: 1250 case kSmiCid:
1296 case kMintCid: 1251 case kMintCid:
1297 case kBigintCid: 1252 case kBigintCid:
1298 return Symbols::New("int"); 1253 return Symbols::Int().raw();
1299 case kDoubleCid: 1254 case kDoubleCid:
1300 return Symbols::New("double"); 1255 return Symbols::Double().raw();
1301 case kOneByteStringCid: 1256 case kOneByteStringCid:
1302 case kTwoByteStringCid: 1257 case kTwoByteStringCid:
1303 case kExternalOneByteStringCid: 1258 case kExternalOneByteStringCid:
1304 case kExternalTwoByteStringCid: 1259 case kExternalTwoByteStringCid:
1305 return Symbols::New("String"); 1260 return Symbols::New("String");
1306 case kArrayCid: 1261 case kArrayCid:
1307 case kImmutableArrayCid: 1262 case kImmutableArrayCid:
1308 case kGrowableObjectArrayCid: 1263 case kGrowableObjectArrayCid:
1309 return Symbols::New("List"); 1264 return Symbols::List().raw();
1310 case kInt8ArrayCid: 1265 case kInt8ArrayCid:
1311 case kExternalInt8ArrayCid: 1266 case kExternalInt8ArrayCid:
1312 return Symbols::New("Int8List"); 1267 return Symbols::Int8List().raw();
1313 case kUint8ArrayCid: 1268 case kUint8ArrayCid:
1314 case kExternalUint8ArrayCid: 1269 case kExternalUint8ArrayCid:
1315 return Symbols::New("Uint8List"); 1270 return Symbols::Uint8List().raw();
1316 case kUint8ClampedArrayCid: 1271 case kUint8ClampedArrayCid:
1317 case kExternalUint8ClampedArrayCid: 1272 case kExternalUint8ClampedArrayCid:
1318 return Symbols::New("Uint8ClampedList"); 1273 return Symbols::Uint8ClampedList().raw();
1319 case kInt16ArrayCid: 1274 case kInt16ArrayCid:
1320 case kExternalInt16ArrayCid: 1275 case kExternalInt16ArrayCid:
1321 return Symbols::New("Int16List"); 1276 return Symbols::Int16List().raw();
1322 case kUint16ArrayCid: 1277 case kUint16ArrayCid:
1323 case kExternalUint16ArrayCid: 1278 case kExternalUint16ArrayCid:
1324 return Symbols::New("Uint16List"); 1279 return Symbols::Uint16List().raw();
1325 case kInt32ArrayCid: 1280 case kInt32ArrayCid:
1326 case kExternalInt32ArrayCid: 1281 case kExternalInt32ArrayCid:
1327 return Symbols::New("Int32List"); 1282 return Symbols::Int32List().raw();
1328 case kUint32ArrayCid: 1283 case kUint32ArrayCid:
1329 case kExternalUint32ArrayCid: 1284 case kExternalUint32ArrayCid:
1330 return Symbols::New("Uint32List"); 1285 return Symbols::Uint32List().raw();
1331 case kInt64ArrayCid: 1286 case kInt64ArrayCid:
1332 case kExternalInt64ArrayCid: 1287 case kExternalInt64ArrayCid:
1333 return Symbols::New("Int64List"); 1288 return Symbols::Int64List().raw();
1334 case kUint64ArrayCid: 1289 case kUint64ArrayCid:
1335 case kExternalUint64ArrayCid: 1290 case kExternalUint64ArrayCid:
1336 return Symbols::New("Uint64List"); 1291 return Symbols::Uint64List().raw();
1337 case kFloat32ArrayCid: 1292 case kFloat32ArrayCid:
1338 case kExternalFloat32ArrayCid: 1293 case kExternalFloat32ArrayCid:
1339 return Symbols::New("Float32List"); 1294 return Symbols::Float32List().raw();
1340 case kFloat64ArrayCid: 1295 case kFloat64ArrayCid:
1341 case kExternalFloat64ArrayCid: 1296 case kExternalFloat64ArrayCid:
1342 return Symbols::New("Float64List"); 1297 return Symbols::Float64List().raw();
1343 default: 1298 default:
1344 if (!IsSignatureClass()) { 1299 if (!IsSignatureClass()) {
1345 const String& name = String::Handle(Name()); 1300 const String& name = String::Handle(Name());
1346 return IdentifierPrettyName(name); 1301 return IdentifierPrettyName(name);
1347 } else { 1302 } else {
1348 return Name(); 1303 return Name();
1349 } 1304 }
1350 } 1305 }
1351 UNREACHABLE(); 1306 UNREACHABLE();
1352 } 1307 }
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 } 2074 }
2120 // Check for two function types. 2075 // Check for two function types.
2121 const Function& fun = Function::Handle(signature_function()); 2076 const Function& fun = Function::Handle(signature_function());
2122 return fun.TypeTest(test_kind, 2077 return fun.TypeTest(test_kind,
2123 type_arguments, 2078 type_arguments,
2124 other_fun, 2079 other_fun,
2125 other_type_arguments, 2080 other_type_arguments,
2126 malformed_error); 2081 malformed_error);
2127 } 2082 }
2128 // Check if type S has a call() method of function type T. 2083 // Check if type S has a call() method of function type T.
2129 const String& function_name = String::Handle(Symbols::Call()); 2084 Function& function =
2130 Function& function = Function::Handle(LookupDynamicFunction(function_name)); 2085 Function::Handle(LookupDynamicFunction(Symbols::Call()));
2131 if (function.IsNull()) { 2086 if (function.IsNull()) {
2132 // Walk up the super_class chain. 2087 // Walk up the super_class chain.
2133 Class& cls = Class::Handle(SuperClass()); 2088 Class& cls = Class::Handle(SuperClass());
2134 while (!cls.IsNull() && function.IsNull()) { 2089 while (!cls.IsNull() && function.IsNull()) {
2135 function = cls.LookupDynamicFunction(function_name); 2090 function = cls.LookupDynamicFunction(Symbols::Call());
2136 cls = cls.SuperClass(); 2091 cls = cls.SuperClass();
2137 } 2092 }
2138 } 2093 }
2139 if (!function.IsNull()) { 2094 if (!function.IsNull()) {
2140 if (other_is_function_class || 2095 if (other_is_function_class ||
2141 function.TypeTest(test_kind, 2096 function.TypeTest(test_kind,
2142 type_arguments, 2097 type_arguments,
2143 other_fun, 2098 other_fun,
2144 other_type_arguments, 2099 other_type_arguments,
2145 malformed_error)) { 2100 malformed_error)) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 void UnresolvedClass::set_library_prefix( 2428 void UnresolvedClass::set_library_prefix(
2474 const LibraryPrefix& library_prefix) const { 2429 const LibraryPrefix& library_prefix) const {
2475 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw()); 2430 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw());
2476 } 2431 }
2477 2432
2478 2433
2479 RawString* UnresolvedClass::Name() const { 2434 RawString* UnresolvedClass::Name() const {
2480 if (library_prefix() != LibraryPrefix::null()) { 2435 if (library_prefix() != LibraryPrefix::null()) {
2481 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix()); 2436 const LibraryPrefix& lib_prefix = LibraryPrefix::Handle(library_prefix());
2482 String& name = String::Handle(); 2437 String& name = String::Handle();
2483 String& str = String::Handle();
2484 name = lib_prefix.name(); // Qualifier. 2438 name = lib_prefix.name(); // Qualifier.
2485 str = Symbols::Dot(); 2439 name = String::Concat(name, Symbols::Dot());
2486 name = String::Concat(name, str); 2440 const String& str = String::Handle(ident());
2487 str = ident();
2488 name = String::Concat(name, str); 2441 name = String::Concat(name, str);
2489 return name.raw(); 2442 return name.raw();
2490 } else { 2443 } else {
2491 return ident(); 2444 return ident();
2492 } 2445 }
2493 } 2446 }
2494 2447
2495 2448
2496 const char* UnresolvedClass::ToCString() const { 2449 const char* UnresolvedClass::ToCString() const {
2497 const char* format = "unresolved class '%s'"; 2450 const char* format = "unresolved class '%s'";
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 2523
2571 RawString* AbstractTypeArguments::SubvectorName( 2524 RawString* AbstractTypeArguments::SubvectorName(
2572 intptr_t from_index, 2525 intptr_t from_index,
2573 intptr_t len, 2526 intptr_t len,
2574 NameVisibility name_visibility) const { 2527 NameVisibility name_visibility) const {
2575 ASSERT(from_index + len <= Length()); 2528 ASSERT(from_index + len <= Length());
2576 String& name = String::Handle(); 2529 String& name = String::Handle();
2577 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">". 2530 const intptr_t num_strings = 2*len + 1; // "<""T"", ""T"">".
2578 const Array& strings = Array::Handle(Array::New(num_strings)); 2531 const Array& strings = Array::Handle(Array::New(num_strings));
2579 intptr_t s = 0; 2532 intptr_t s = 0;
2580 strings.SetAt(s++, String::Handle(Symbols::New("<"))); 2533 strings.SetAt(s++, Symbols::LAngleBracket());
2581 const String& kCommaSpace = String::Handle(Symbols::New(", "));
2582 AbstractType& type = AbstractType::Handle(); 2534 AbstractType& type = AbstractType::Handle();
2583 for (intptr_t i = 0; i < len; i++) { 2535 for (intptr_t i = 0; i < len; i++) {
2584 type = TypeAt(from_index + i); 2536 type = TypeAt(from_index + i);
2585 name = type.BuildName(name_visibility); 2537 name = type.BuildName(name_visibility);
2586 strings.SetAt(s++, name); 2538 strings.SetAt(s++, name);
2587 if (i < len - 1) { 2539 if (i < len - 1) {
2588 strings.SetAt(s++, kCommaSpace); 2540 strings.SetAt(s++, Symbols::CommaSpace());
2589 } 2541 }
2590 } 2542 }
2591 strings.SetAt(s++, String::Handle(Symbols::New(">"))); 2543 strings.SetAt(s++, Symbols::RAngleBracket());
2592 ASSERT(s == num_strings); 2544 ASSERT(s == num_strings);
2593 name = String::ConcatAll(strings); 2545 name = String::ConcatAll(strings);
2594 return Symbols::New(name); 2546 return Symbols::New(name);
2595 } 2547 }
2596 2548
2597 2549
2598 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const { 2550 bool AbstractTypeArguments::Equals(const AbstractTypeArguments& other) const {
2599 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual(). 2551 ASSERT(!IsNull()); // Use AbstractTypeArguments::AreEqual().
2600 if (this->raw() == other.raw()) { 2552 if (this->raw() == other.raw()) {
2601 return true; 2553 return true;
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 3482
3531 void Function::set_is_inlinable(bool value) const { 3483 void Function::set_is_inlinable(bool value) const {
3532 set_kind_tag(InlinableBit::update(value, raw_ptr()->kind_tag_)); 3484 set_kind_tag(InlinableBit::update(value, raw_ptr()->kind_tag_));
3533 } 3485 }
3534 3486
3535 3487
3536 bool Function::IsInlineable() const { 3488 bool Function::IsInlineable() const {
3537 // '==' call is handled specially. 3489 // '==' call is handled specially.
3538 return InlinableBit::decode(raw_ptr()->kind_tag_) && 3490 return InlinableBit::decode(raw_ptr()->kind_tag_) &&
3539 HasCode() && 3491 HasCode() &&
3540 name() != Symbols::EqualOperator(); 3492 name() != Symbols::EqualOperator().raw();
3541 } 3493 }
3542 3494
3543 3495
3544 intptr_t Function::NumParameters() const { 3496 intptr_t Function::NumParameters() const {
3545 return num_fixed_parameters() + NumOptionalParameters(); 3497 return num_fixed_parameters() + NumOptionalParameters();
3546 } 3498 }
3547 3499
3548 3500
3549 intptr_t Function::NumImplicitParameters() const { 3501 intptr_t Function::NumImplicitParameters() const {
3550 if (kind() == RawFunction::kConstructor) { 3502 if (kind() == RawFunction::kConstructor) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 closure_function.SetNumOptionalParameters(num_opt_params, has_opt_pos_params); 3983 closure_function.SetNumOptionalParameters(num_opt_params, has_opt_pos_params);
4032 closure_function.set_parameter_types(Array::Handle(Array::New(num_params, 3984 closure_function.set_parameter_types(Array::Handle(Array::New(num_params,
4033 Heap::kOld))); 3985 Heap::kOld)));
4034 closure_function.set_parameter_names(Array::Handle(Array::New(num_params, 3986 closure_function.set_parameter_names(Array::Handle(Array::New(num_params,
4035 Heap::kOld))); 3987 Heap::kOld)));
4036 AbstractType& param_type = AbstractType::Handle(); 3988 AbstractType& param_type = AbstractType::Handle();
4037 String& param_name = String::Handle(); 3989 String& param_name = String::Handle();
4038 // Add implicit closure object parameter. 3990 // Add implicit closure object parameter.
4039 param_type = Type::DynamicType(); 3991 param_type = Type::DynamicType();
4040 closure_function.SetParameterTypeAt(0, param_type); 3992 closure_function.SetParameterTypeAt(0, param_type);
4041 param_name = Symbols::ClosureParameter(); 3993 closure_function.SetParameterNameAt(0, Symbols::ClosureParameter());
4042 closure_function.SetParameterNameAt(0, param_name);
4043 for (int i = kClosure; i < num_params; i++) { 3994 for (int i = kClosure; i < num_params; i++) {
4044 param_type = ParameterTypeAt(has_receiver - kClosure + i); 3995 param_type = ParameterTypeAt(has_receiver - kClosure + i);
4045 closure_function.SetParameterTypeAt(i, param_type); 3996 closure_function.SetParameterTypeAt(i, param_type);
4046 param_name = ParameterNameAt(has_receiver - kClosure + i); 3997 param_name = ParameterNameAt(has_receiver - kClosure + i);
4047 closure_function.SetParameterNameAt(i, param_name); 3998 closure_function.SetParameterNameAt(i, param_name);
4048 } 3999 }
4049 4000
4050 // Lookup or create a new signature class for the closure function in the 4001 // Lookup or create a new signature class for the closure function in the
4051 // library of the owner class. 4002 // library of the owner class.
4052 const Class& owner_class = Class::Handle(Owner()); 4003 const Class& owner_class = Class::Handle(Owner());
(...skipping 23 matching lines...) Expand all
4076 return closure_function.raw(); 4027 return closure_function.raw();
4077 } 4028 }
4078 4029
4079 4030
4080 RawString* Function::BuildSignature( 4031 RawString* Function::BuildSignature(
4081 bool instantiate, 4032 bool instantiate,
4082 NameVisibility name_visibility, 4033 NameVisibility name_visibility,
4083 const AbstractTypeArguments& instantiator) const { 4034 const AbstractTypeArguments& instantiator) const {
4084 const GrowableObjectArray& pieces = 4035 const GrowableObjectArray& pieces =
4085 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4036 GrowableObjectArray::Handle(GrowableObjectArray::New());
4086 const String& kCommaSpace = String::Handle(Symbols::New(", "));
4087 const String& kColonSpace = String::Handle(Symbols::New(": "));
4088 const String& kLParen = String::Handle(Symbols::New("("));
4089 const String& kRParenArrow = String::Handle(Symbols::New(") => "));
4090 const String& kLBracket = String::Handle(Symbols::New("["));
4091 const String& kRBracket = String::Handle(Symbols::New("]"));
4092 const String& kLBrace = String::Handle(Symbols::New("{"));
4093 const String& kRBrace = String::Handle(Symbols::New("}"));
4094 String& name = String::Handle(); 4037 String& name = String::Handle();
4095 if (!instantiate && !is_static() && (name_visibility == kInternalName)) { 4038 if (!instantiate && !is_static() && (name_visibility == kInternalName)) {
4096 // Prefix the signature with its class and type parameters, if any (e.g. 4039 // Prefix the signature with its class and type parameters, if any (e.g.
4097 // "Map<K, V>(K) => bool"). 4040 // "Map<K, V>(K) => bool").
4098 // The signature of static functions cannot be type parameterized. 4041 // The signature of static functions cannot be type parameterized.
4099 const String& kSpaceExtendsSpace =
4100 String::Handle(Symbols::New(" extends "));
4101 const String& kLAngleBracket = String::Handle(Symbols::New("<"));
4102 const String& kRAngleBracket = String::Handle(Symbols::New(">"));
4103 const Class& function_class = Class::Handle(Owner()); 4042 const Class& function_class = Class::Handle(Owner());
4104 ASSERT(!function_class.IsNull()); 4043 ASSERT(!function_class.IsNull());
4105 const TypeArguments& type_parameters = TypeArguments::Handle( 4044 const TypeArguments& type_parameters = TypeArguments::Handle(
4106 function_class.type_parameters()); 4045 function_class.type_parameters());
4107 if (!type_parameters.IsNull()) { 4046 if (!type_parameters.IsNull()) {
4108 const String& function_class_name = String::Handle(function_class.Name()); 4047 const String& function_class_name = String::Handle(function_class.Name());
4109 pieces.Add(function_class_name); 4048 pieces.Add(function_class_name);
4110 intptr_t num_type_parameters = type_parameters.Length(); 4049 intptr_t num_type_parameters = type_parameters.Length();
4111 pieces.Add(kLAngleBracket); 4050 pieces.Add(Symbols::LAngleBracket());
4112 TypeParameter& type_parameter = TypeParameter::Handle(); 4051 TypeParameter& type_parameter = TypeParameter::Handle();
4113 AbstractType& bound = AbstractType::Handle(); 4052 AbstractType& bound = AbstractType::Handle();
4114 for (intptr_t i = 0; i < num_type_parameters; i++) { 4053 for (intptr_t i = 0; i < num_type_parameters; i++) {
4115 type_parameter ^= type_parameters.TypeAt(i); 4054 type_parameter ^= type_parameters.TypeAt(i);
4116 name = type_parameter.name(); 4055 name = type_parameter.name();
4117 pieces.Add(name); 4056 pieces.Add(name);
4118 bound = type_parameter.bound(); 4057 bound = type_parameter.bound();
4119 if (!bound.IsNull() && !bound.IsObjectType()) { 4058 if (!bound.IsNull() && !bound.IsObjectType()) {
4120 pieces.Add(kSpaceExtendsSpace); 4059 pieces.Add(Symbols::SpaceExtendsSpace());
4121 name = bound.BuildName(name_visibility); 4060 name = bound.BuildName(name_visibility);
4122 pieces.Add(name); 4061 pieces.Add(name);
4123 } 4062 }
4124 if (i < num_type_parameters - 1) { 4063 if (i < num_type_parameters - 1) {
4125 pieces.Add(kCommaSpace); 4064 pieces.Add(Symbols::CommaSpace());
4126 } 4065 }
4127 } 4066 }
4128 pieces.Add(kRAngleBracket); 4067 pieces.Add(Symbols::RAngleBracket());
4129 } 4068 }
4130 } 4069 }
4131 AbstractType& param_type = AbstractType::Handle(); 4070 AbstractType& param_type = AbstractType::Handle();
4132 const intptr_t num_params = NumParameters(); 4071 const intptr_t num_params = NumParameters();
4133 const intptr_t num_fixed_params = num_fixed_parameters(); 4072 const intptr_t num_fixed_params = num_fixed_parameters();
4134 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters(); 4073 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
4135 const intptr_t num_opt_named_params = NumOptionalNamedParameters(); 4074 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
4136 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params; 4075 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
4137 ASSERT((num_fixed_params + num_opt_params) == num_params); 4076 ASSERT((num_fixed_params + num_opt_params) == num_params);
4138 pieces.Add(kLParen); 4077 pieces.Add(Symbols::LParen());
4139 intptr_t i = 0; 4078 intptr_t i = 0;
4140 if (name_visibility == kUserVisibleName) { 4079 if (name_visibility == kUserVisibleName) {
4141 // Hide implicit parameters. 4080 // Hide implicit parameters.
4142 i = NumImplicitParameters(); 4081 i = NumImplicitParameters();
4143 } 4082 }
4144 while (i < num_fixed_params) { 4083 while (i < num_fixed_params) {
4145 param_type = ParameterTypeAt(i); 4084 param_type = ParameterTypeAt(i);
4146 ASSERT(!param_type.IsNull()); 4085 ASSERT(!param_type.IsNull());
4147 if (instantiate && !param_type.IsInstantiated()) { 4086 if (instantiate && !param_type.IsInstantiated()) {
4148 param_type = param_type.InstantiateFrom(instantiator); 4087 param_type = param_type.InstantiateFrom(instantiator);
4149 } 4088 }
4150 name = param_type.BuildName(name_visibility); 4089 name = param_type.BuildName(name_visibility);
4151 pieces.Add(name); 4090 pieces.Add(name);
4152 if (i != (num_params - 1)) { 4091 if (i != (num_params - 1)) {
4153 pieces.Add(kCommaSpace); 4092 pieces.Add(Symbols::CommaSpace());
4154 } 4093 }
4155 i++; 4094 i++;
4156 } 4095 }
4157 if (num_opt_params > 0) { 4096 if (num_opt_params > 0) {
4158 if (num_opt_pos_params > 0) { 4097 if (num_opt_pos_params > 0) {
4159 pieces.Add(kLBracket); 4098 pieces.Add(Symbols::LBracket());
4160 } else { 4099 } else {
4161 pieces.Add(kLBrace); 4100 pieces.Add(Symbols::LBrace());
4162 } 4101 }
4163 for (intptr_t i = num_fixed_params; i < num_params; i++) { 4102 for (intptr_t i = num_fixed_params; i < num_params; i++) {
4164 // The parameter name of an optional positional parameter does not need 4103 // The parameter name of an optional positional parameter does not need
4165 // to be part of the signature, since it is not used. 4104 // to be part of the signature, since it is not used.
4166 if (num_opt_named_params > 0) { 4105 if (num_opt_named_params > 0) {
4167 name = ParameterNameAt(i); 4106 name = ParameterNameAt(i);
4168 pieces.Add(name); 4107 pieces.Add(name);
4169 pieces.Add(kColonSpace); 4108 pieces.Add(Symbols::ColonSpace());
4170 } 4109 }
4171 param_type = ParameterTypeAt(i); 4110 param_type = ParameterTypeAt(i);
4172 if (instantiate && !param_type.IsInstantiated()) { 4111 if (instantiate && !param_type.IsInstantiated()) {
4173 param_type = param_type.InstantiateFrom(instantiator); 4112 param_type = param_type.InstantiateFrom(instantiator);
4174 } 4113 }
4175 ASSERT(!param_type.IsNull()); 4114 ASSERT(!param_type.IsNull());
4176 name = param_type.BuildName(name_visibility); 4115 name = param_type.BuildName(name_visibility);
4177 pieces.Add(name); 4116 pieces.Add(name);
4178 if (i != (num_params - 1)) { 4117 if (i != (num_params - 1)) {
4179 pieces.Add(kCommaSpace); 4118 pieces.Add(Symbols::CommaSpace());
4180 } 4119 }
4181 } 4120 }
4182 if (num_opt_pos_params > 0) { 4121 if (num_opt_pos_params > 0) {
4183 pieces.Add(kRBracket); 4122 pieces.Add(Symbols::RBracket());
4184 } else { 4123 } else {
4185 pieces.Add(kRBrace); 4124 pieces.Add(Symbols::RBrace());
4186 } 4125 }
4187 } 4126 }
4188 pieces.Add(kRParenArrow); 4127 pieces.Add(Symbols::RParenArrow());
4189 AbstractType& res_type = AbstractType::Handle(result_type()); 4128 AbstractType& res_type = AbstractType::Handle(result_type());
4190 if (instantiate && !res_type.IsInstantiated()) { 4129 if (instantiate && !res_type.IsInstantiated()) {
4191 res_type = res_type.InstantiateFrom(instantiator); 4130 res_type = res_type.InstantiateFrom(instantiator);
4192 } 4131 }
4193 name = res_type.BuildName(name_visibility); 4132 name = res_type.BuildName(name_visibility);
4194 pieces.Add(name); 4133 pieces.Add(name);
4195 const Array& strings = Array::Handle(Array::MakeArray(pieces)); 4134 const Array& strings = Array::Handle(Array::MakeArray(pieces));
4196 return Symbols::New(String::Handle(String::ConcatAll(strings))); 4135 return Symbols::New(String::Handle(String::ConcatAll(strings)));
4197 } 4136 }
4198 4137
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4239 4178
4240 4179
4241 RawString* Function::UserVisibleName() const { 4180 RawString* Function::UserVisibleName() const {
4242 const String& str = String::Handle(name()); 4181 const String& str = String::Handle(name());
4243 return IdentifierPrettyName(str); 4182 return IdentifierPrettyName(str);
4244 } 4183 }
4245 4184
4246 4185
4247 RawString* Function::QualifiedUserVisibleName() const { 4186 RawString* Function::QualifiedUserVisibleName() const {
4248 String& tmp = String::Handle(); 4187 String& tmp = String::Handle();
4249 String& suffix = String::Handle();
4250 const Class& cls = Class::Handle(Owner()); 4188 const Class& cls = Class::Handle(Owner());
4251 4189
4252 if (IsClosureFunction()) { 4190 if (IsClosureFunction()) {
4253 if (IsLocalFunction()) { 4191 if (IsLocalFunction()) {
4254 const Function& parent = Function::Handle(parent_function()); 4192 const Function& parent = Function::Handle(parent_function());
4255 tmp = parent.QualifiedUserVisibleName(); 4193 tmp = parent.QualifiedUserVisibleName();
4256 } else { 4194 } else {
4257 return UserVisibleName(); 4195 return UserVisibleName();
4258 } 4196 }
4259 } else { 4197 } else {
4260 if (cls.IsTopLevel()) { 4198 if (cls.IsTopLevel()) {
4261 return UserVisibleName(); 4199 return UserVisibleName();
4262 } else { 4200 } else {
4263 tmp = cls.UserVisibleName(); 4201 tmp = cls.UserVisibleName();
4264 } 4202 }
4265 } 4203 }
4266 suffix = Symbols::Dot(); 4204 tmp = String::Concat(tmp, Symbols::Dot());
4267 tmp = String::Concat(tmp, suffix); 4205 const String& suffix = String::Handle(UserVisibleName());
4268 suffix = UserVisibleName();
4269 return String::Concat(tmp, suffix); 4206 return String::Concat(tmp, suffix);
4270 } 4207 }
4271 4208
4272 4209
4273 // Construct fingerprint from token stream. The token stream contains also 4210 // Construct fingerprint from token stream. The token stream contains also
4274 // arguments. 4211 // arguments.
4275 int32_t Function::SourceFingerprint() const { 4212 int32_t Function::SourceFingerprint() const {
4276 uint32_t result = String::Handle(Signature()).Hash(); 4213 uint32_t result = String::Handle(Signature()).Hash();
4277 TokenStream::Iterator tokens_iterator(TokenStream::Handle( 4214 TokenStream::Iterator tokens_iterator(TokenStream::Handle(
4278 Script::Handle(script()).tokens()), token_pos()); 4215 Script::Handle(script()).tokens()), token_pos());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4425 4362
4426 RawString* Field::GetterName(const String& field_name) { 4363 RawString* Field::GetterName(const String& field_name) {
4427 String& str = String::Handle(); 4364 String& str = String::Handle();
4428 str = String::New(kGetterPrefix); 4365 str = String::New(kGetterPrefix);
4429 str = String::Concat(str, field_name); 4366 str = String::Concat(str, field_name);
4430 return str.raw(); 4367 return str.raw();
4431 } 4368 }
4432 4369
4433 4370
4434 RawString* Field::GetterSymbol(const String& field_name) { 4371 RawString* Field::GetterSymbol(const String& field_name) {
4435 String& str = String::Handle(); 4372 const String& str = String::Handle(Field::GetterName(field_name));
4436 str = Field::GetterName(field_name);
4437 return Symbols::New(str); 4373 return Symbols::New(str);
4438 } 4374 }
4439 4375
4440 4376
4441 RawString* Field::SetterName(const String& field_name) { 4377 RawString* Field::SetterName(const String& field_name) {
4442 String& str = String::Handle(); 4378 String& str = String::Handle();
4443 str = String::New(kSetterPrefix); 4379 str = String::New(kSetterPrefix);
4444 str = String::Concat(str, field_name); 4380 str = String::Concat(str, field_name);
4445 return str.raw(); 4381 return str.raw();
4446 } 4382 }
4447 4383
4448 4384
4449 RawString* Field::SetterSymbol(const String& field_name) { 4385 RawString* Field::SetterSymbol(const String& field_name) {
4450 String& str = String::Handle(); 4386 const String& str = String::Handle(Field::SetterName(field_name));
4451 str = Field::SetterName(field_name);
4452 return Symbols::New(str); 4387 return Symbols::New(str);
4453 } 4388 }
4454 4389
4455 4390
4456 RawString* Field::NameFromGetter(const String& getter_name) { 4391 RawString* Field::NameFromGetter(const String& getter_name) {
4457 String& str = String::Handle(); 4392 String& str = String::Handle();
4458 str = String::SubString(getter_name, strlen(kGetterPrefix)); 4393 str = String::SubString(getter_name, strlen(kGetterPrefix));
4459 return str.raw(); 4394 return str.raw();
4460 } 4395 }
4461 4396
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
4638 4573
4639 4574
4640 RawString* TokenStream::GenerateSource() const { 4575 RawString* TokenStream::GenerateSource() const {
4641 Iterator iterator(*this, 0); 4576 Iterator iterator(*this, 0);
4642 const ExternalUint8Array& data = ExternalUint8Array::Handle(GetStream()); 4577 const ExternalUint8Array& data = ExternalUint8Array::Handle(GetStream());
4643 const GrowableObjectArray& literals = 4578 const GrowableObjectArray& literals =
4644 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length())); 4579 GrowableObjectArray::Handle(GrowableObjectArray::New(data.Length()));
4645 const String& private_key = String::Handle(PrivateKey()); 4580 const String& private_key = String::Handle(PrivateKey());
4646 intptr_t private_len = private_key.Length(); 4581 intptr_t private_len = private_key.Length();
4647 4582
4648 String& blank = String::Handle(String::New(" "));
4649 String& newline = String::Handle(String::New("\n"));
4650 String& two_newlines = String::Handle(String::New("\n\n"));
4651 String& double_quotes = String::Handle(String::New("\""));
4652 String& dollar = String::Handle(String::New("$"));
4653 String& two_spaces = String::Handle(String::New(" "));
4654 String& raw_string = String::Handle(String::New("r"));
4655
4656 Token::Kind curr = iterator.CurrentTokenKind(); 4583 Token::Kind curr = iterator.CurrentTokenKind();
4657 Token::Kind prev = Token::kILLEGAL; 4584 Token::Kind prev = Token::kILLEGAL;
4658 // Handles used in the loop. 4585 // Handles used in the loop.
4659 Object& obj = Object::Handle(); 4586 Object& obj = Object::Handle();
4660 String& literal = String::Handle(); 4587 String& literal = String::Handle();
4661 // Current indentation level. 4588 // Current indentation level.
4662 int indent = 0; 4589 int indent = 0;
4663 4590
4664 while (curr != Token::kEOS) { 4591 while (curr != Token::kEOS) {
4665 // Remember current values for this token. 4592 // Remember current values for this token.
(...skipping 20 matching lines...) Expand all
4686 (prev != Token::kINTERPOL_VAR) && 4613 (prev != Token::kINTERPOL_VAR) &&
4687 (prev != Token::kINTERPOL_END)) { 4614 (prev != Token::kINTERPOL_END)) {
4688 is_raw_string = true; 4615 is_raw_string = true;
4689 } else { 4616 } else {
4690 escape_characters = true; 4617 escape_characters = true;
4691 } 4618 }
4692 } 4619 }
4693 } 4620 }
4694 if ((prev != Token::kINTERPOL_VAR) && (prev != Token::kINTERPOL_END)) { 4621 if ((prev != Token::kINTERPOL_VAR) && (prev != Token::kINTERPOL_END)) {
4695 if (is_raw_string) { 4622 if (is_raw_string) {
4696 literals.Add(raw_string); 4623 literals.Add(Symbols::LowercaseR());
4697 } 4624 }
4698 literals.Add(double_quotes); 4625 literals.Add(Symbols::DoubleQuotes());
4699 } 4626 }
4700 if (escape_characters) { 4627 if (escape_characters) {
4701 literal = String::EscapeSpecialCharacters(literal, is_raw_string); 4628 literal = String::EscapeSpecialCharacters(literal, is_raw_string);
4702 literals.Add(literal); 4629 literals.Add(literal);
4703 } else { 4630 } else {
4704 literals.Add(literal); 4631 literals.Add(literal);
4705 } 4632 }
4706 if ((next != Token::kINTERPOL_VAR) && (next != Token::kINTERPOL_START)) { 4633 if ((next != Token::kINTERPOL_VAR) && (next != Token::kINTERPOL_START)) {
4707 literals.Add(double_quotes); 4634 literals.Add(Symbols::DoubleQuotes());
4708 } 4635 }
4709 } else if (curr == Token::kINTERPOL_VAR) { 4636 } else if (curr == Token::kINTERPOL_VAR) {
4710 literals.Add(dollar); 4637 literals.Add(Symbols::Dollar());
4711 if (literal.CharAt(0) == Scanner::kPrivateIdentifierStart) { 4638 if (literal.CharAt(0) == Scanner::kPrivateIdentifierStart) {
4712 literal = String::SubString(literal, 0, literal.Length() - private_len); 4639 literal = String::SubString(literal, 0, literal.Length() - private_len);
4713 } 4640 }
4714 literals.Add(literal); 4641 literals.Add(literal);
4715 } else if (curr == Token::kIDENT) { 4642 } else if (curr == Token::kIDENT) {
4716 if (literal.CharAt(0) == Scanner::kPrivateIdentifierStart) { 4643 if (literal.CharAt(0) == Scanner::kPrivateIdentifierStart) {
4717 literal = String::SubString(literal, 0, literal.Length() - private_len); 4644 literal = String::SubString(literal, 0, literal.Length() - private_len);
4718 } 4645 }
4719 literals.Add(literal); 4646 literals.Add(literal);
4720 } else { 4647 } else {
4721 literals.Add(literal); 4648 literals.Add(literal);
4722 } 4649 }
4723 // Determine the separation text based on this current token. 4650 // Determine the separation text based on this current token.
4724 const String* separator = NULL; 4651 const String* separator = NULL;
4725 switch (curr) { 4652 switch (curr) {
4726 case Token::kLBRACE: 4653 case Token::kLBRACE:
4727 indent++; 4654 indent++;
4728 separator = &newline; 4655 separator = &Symbols::NewLine();
4729 break; 4656 break;
4730 case Token::kRBRACE: 4657 case Token::kRBRACE:
4731 if (indent == 0) { 4658 if (indent == 0) {
4732 separator = &two_newlines; 4659 separator = &Symbols::TwoNewlines();
4733 } else { 4660 } else {
4734 separator = &newline; 4661 separator = &Symbols::NewLine();
4735 } 4662 }
4736 break; 4663 break;
4737 case Token::kSEMICOLON: 4664 case Token::kSEMICOLON:
4738 separator = &newline; 4665 separator = &Symbols::NewLine();
4739 break; 4666 break;
4740 case Token::kPERIOD: 4667 case Token::kPERIOD:
4741 case Token::kLPAREN: 4668 case Token::kLPAREN:
4742 case Token::kLBRACK: 4669 case Token::kLBRACK:
4743 case Token::kTIGHTADD: 4670 case Token::kTIGHTADD:
4744 case Token::kINTERPOL_VAR: 4671 case Token::kINTERPOL_VAR:
4745 case Token::kINTERPOL_START: 4672 case Token::kINTERPOL_START:
4746 case Token::kINTERPOL_END: 4673 case Token::kINTERPOL_END:
4747 break; 4674 break;
4748 default: 4675 default:
4749 separator = &blank; 4676 separator = &Symbols::Blank();
4750 break; 4677 break;
4751 } 4678 }
4752 // Determine whether the separation text needs to be updated based on the 4679 // Determine whether the separation text needs to be updated based on the
4753 // next token. 4680 // next token.
4754 switch (next) { 4681 switch (next) {
4755 case Token::kRBRACE: 4682 case Token::kRBRACE:
4756 indent--; 4683 indent--;
4757 break; 4684 break;
4758 case Token::kSEMICOLON: 4685 case Token::kSEMICOLON:
4759 case Token::kPERIOD: 4686 case Token::kPERIOD:
4760 case Token::kCOMMA: 4687 case Token::kCOMMA:
4761 case Token::kLPAREN: 4688 case Token::kLPAREN:
4762 case Token::kRPAREN: 4689 case Token::kRPAREN:
4763 case Token::kLBRACK: 4690 case Token::kLBRACK:
4764 case Token::kRBRACK: 4691 case Token::kRBRACK:
4765 case Token::kINTERPOL_VAR: 4692 case Token::kINTERPOL_VAR:
4766 case Token::kINTERPOL_START: 4693 case Token::kINTERPOL_START:
4767 case Token::kINTERPOL_END: 4694 case Token::kINTERPOL_END:
4768 separator = NULL; 4695 separator = NULL;
4769 break; 4696 break;
4770 case Token::kELSE: 4697 case Token::kELSE:
4771 separator = &blank; 4698 separator = &Symbols::Blank();
4772 default: 4699 default:
4773 // Do nothing. 4700 // Do nothing.
4774 break; 4701 break;
4775 } 4702 }
4776 // Update the few cases where both tokens need to be taken into account. 4703 // Update the few cases where both tokens need to be taken into account.
4777 if (((curr == Token::kIF) || (curr == Token::kFOR)) && 4704 if (((curr == Token::kIF) || (curr == Token::kFOR)) &&
4778 (next == Token::kLPAREN)) { 4705 (next == Token::kLPAREN)) {
4779 separator = &blank; 4706 separator = &Symbols::Blank();
4780 } else if ((curr == Token::kASSIGN) && (next == Token::kLPAREN)) { 4707 } else if ((curr == Token::kASSIGN) && (next == Token::kLPAREN)) {
4781 separator = & blank; 4708 separator = &Symbols::Blank();
4782 } else if ((curr == Token::kLBRACE) && (next == Token::kRBRACE)) { 4709 } else if ((curr == Token::kLBRACE) && (next == Token::kRBRACE)) {
4783 separator = NULL; 4710 separator = NULL;
4784 } 4711 }
4785 if (separator != NULL) { 4712 if (separator != NULL) {
4786 literals.Add(*separator); 4713 literals.Add(*separator);
4787 if (separator == &newline) { 4714 if (separator == &Symbols::NewLine()) {
4788 for (int i = 0; i < indent; i++) { 4715 for (int i = 0; i < indent; i++) {
4789 literals.Add(two_spaces); 4716 literals.Add(Symbols::TwoSpaces());
4790 } 4717 }
4791 } 4718 }
4792 } 4719 }
4793 // Setup for next iteration. 4720 // Setup for next iteration.
4794 prev = curr; 4721 prev = curr;
4795 curr = next; 4722 curr = next;
4796 } 4723 }
4797 const Array& source = Array::Handle(Array::MakeArray(literals)); 4724 const Array& source = Array::Handle(Array::MakeArray(literals));
4798 return String::ConcatAll(source); 4725 return String::ConcatAll(source);
4799 } 4726 }
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
5212 if (FLAG_compiler_stats) { 5139 if (FLAG_compiler_stats) {
5213 CompilerStats::src_length += src.Length(); 5140 CompilerStats::src_length += src.Length();
5214 } 5141 }
5215 } 5142 }
5216 5143
5217 5144
5218 void Script::GetTokenLocation(intptr_t token_pos, 5145 void Script::GetTokenLocation(intptr_t token_pos,
5219 intptr_t* line, 5146 intptr_t* line,
5220 intptr_t* column) const { 5147 intptr_t* column) const {
5221 const String& src = String::Handle(Source()); 5148 const String& src = String::Handle(Source());
5222 const String& dummy_key = String::Handle(Symbols::Empty());
5223 const TokenStream& tkns = TokenStream::Handle(tokens()); 5149 const TokenStream& tkns = TokenStream::Handle(tokens());
5224 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos); 5150 intptr_t src_pos = tkns.ComputeSourcePosition(token_pos);
5225 Scanner scanner(src, dummy_key); 5151 Scanner scanner(src, Symbols::Empty());
5226 scanner.ScanTo(src_pos); 5152 scanner.ScanTo(src_pos);
5227 *line = scanner.CurrentPosition().line; 5153 *line = scanner.CurrentPosition().line;
5228 *column = scanner.CurrentPosition().column; 5154 *column = scanner.CurrentPosition().column;
5229 } 5155 }
5230 5156
5231 5157
5232 void Script::TokenRangeAtLine(intptr_t line_number, 5158 void Script::TokenRangeAtLine(intptr_t line_number,
5233 intptr_t* first_token_index, 5159 intptr_t* first_token_index,
5234 intptr_t* last_token_index) const { 5160 intptr_t* last_token_index) const {
5235 const String& src = String::Handle(Source()); 5161 const String& src = String::Handle(Source());
5236 const String& dummy_key = String::Handle(Symbols::Empty());
5237 const TokenStream& tkns = TokenStream::Handle(tokens()); 5162 const TokenStream& tkns = TokenStream::Handle(tokens());
5238 Scanner scanner(src, dummy_key); 5163 Scanner scanner(src, Symbols::Empty());
5239 scanner.TokenRangeAtLine(line_number, first_token_index, last_token_index); 5164 scanner.TokenRangeAtLine(line_number, first_token_index, last_token_index);
5240 if (*first_token_index >= 0) { 5165 if (*first_token_index >= 0) {
5241 *first_token_index = tkns.ComputeTokenPosition(*first_token_index); 5166 *first_token_index = tkns.ComputeTokenPosition(*first_token_index);
5242 } 5167 }
5243 if (*last_token_index >= 0) { 5168 if (*last_token_index >= 0) {
5244 *last_token_index = tkns.ComputeTokenPosition(*last_token_index); 5169 *last_token_index = tkns.ComputeTokenPosition(*last_token_index);
5245 } 5170 }
5246 } 5171 }
5247 5172
5248 5173
(...skipping 12 matching lines...) Expand all
5261 current_line++; 5186 current_line++;
5262 } else if (src.CharAt(ix) == '\r') { 5187 } else if (src.CharAt(ix) == '\r') {
5263 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) { 5188 if ((ix + 1 != src.Length()) && (src.CharAt(ix + 1) != '\n')) {
5264 current_line++; 5189 current_line++;
5265 } 5190 }
5266 } else { 5191 } else {
5267 last_char = ix; 5192 last_char = ix;
5268 } 5193 }
5269 } 5194 }
5270 // Guarantee that returned string is never NULL. 5195 // Guarantee that returned string is never NULL.
5271 String& line = String::Handle(Symbols::Empty());
5272 if (line_start >= 0) { 5196 if (line_start >= 0) {
5273 line = String::SubString(src, line_start, last_char - line_start + 1); 5197 const String& line = String::Handle(
5198 String::SubString(src, line_start, last_char - line_start + 1));
5199 return line.raw();
5200 } else {
5201 return Symbols::Empty().raw();
5274 } 5202 }
5275 return line.raw();
5276 } 5203 }
5277 5204
5278 5205
5279 RawString* Script::GetSnippet(intptr_t from_line, 5206 RawString* Script::GetSnippet(intptr_t from_line,
5280 intptr_t from_column, 5207 intptr_t from_column,
5281 intptr_t to_line, 5208 intptr_t to_line,
5282 intptr_t to_column) const { 5209 intptr_t to_column) const {
5283 const String& src = String::Handle(Source()); 5210 const String& src = String::Handle(Source());
5284 intptr_t length = src.Length(); 5211 intptr_t length = src.Length();
5285 intptr_t line = 1; 5212 intptr_t line = 1;
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after
8535 if (cls.IsSignatureClass()) { 8462 if (cls.IsSignatureClass()) {
8536 if (function != NULL) { 8463 if (function != NULL) {
8537 *function = Closure::function(*this); 8464 *function = Closure::function(*this);
8538 } 8465 }
8539 if (context != NULL) { 8466 if (context != NULL) {
8540 *context = Closure::context(*this); 8467 *context = Closure::context(*this);
8541 } 8468 }
8542 return true; 8469 return true;
8543 } 8470 }
8544 // Try to resolve a "call" method. 8471 // Try to resolve a "call" method.
8545 const String& call_symbol = String::Handle(Symbols::Call());
8546 Function& call_function = Function::Handle(); 8472 Function& call_function = Function::Handle();
8547 do { 8473 do {
8548 call_function = cls.LookupDynamicFunction(call_symbol); 8474 call_function = cls.LookupDynamicFunction(Symbols::Call());
8549 if (!call_function.IsNull()) { 8475 if (!call_function.IsNull()) {
8550 if (function != NULL) { 8476 if (function != NULL) {
8551 *function = call_function.raw(); 8477 *function = call_function.raw();
8552 } 8478 }
8553 if (context != NULL) { 8479 if (context != NULL) {
8554 *context = Isolate::Current()->object_store()->empty_context(); 8480 *context = Isolate::Current()->object_store()->empty_context();
8555 } 8481 }
8556 return true; 8482 return true;
8557 } 8483 }
8558 cls = cls.SuperClass(); 8484 cls = cls.SuperClass();
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
10683 10609
10684 10610
10685 RawString* String::SubString(const String& str, 10611 RawString* String::SubString(const String& str,
10686 intptr_t begin_index, 10612 intptr_t begin_index,
10687 intptr_t length, 10613 intptr_t length,
10688 Heap::Space space) { 10614 Heap::Space space) {
10689 ASSERT(!str.IsNull()); 10615 ASSERT(!str.IsNull());
10690 ASSERT(begin_index >= 0); 10616 ASSERT(begin_index >= 0);
10691 ASSERT(length >= 0); 10617 ASSERT(length >= 0);
10692 if (begin_index <= str.Length() && length == 0) { 10618 if (begin_index <= str.Length() && length == 0) {
10693 return Symbols::Empty(); 10619 return Symbols::Empty().raw();
10694 } 10620 }
10695 if (begin_index > str.Length()) { 10621 if (begin_index > str.Length()) {
10696 return String::null(); 10622 return String::null();
10697 } 10623 }
10698 String& result = String::Handle(); 10624 String& result = String::Handle();
10699 bool is_one_byte_string = true; 10625 bool is_one_byte_string = true;
10700 intptr_t char_size = str.CharSize(); 10626 intptr_t char_size = str.CharSize();
10701 if (char_size == kTwoByteChar) { 10627 if (char_size == kTwoByteChar) {
10702 for (intptr_t i = begin_index; i < begin_index + length; ++i) { 10628 for (intptr_t i = begin_index; i < begin_index + length; ++i) {
10703 if (!Utf::IsLatin1(str.CharAt(i))) { 10629 if (!Utf::IsLatin1(str.CharAt(i))) {
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
11096 11022
11097 11023
11098 RawOneByteString* OneByteString::SubStringUnchecked(const String& str, 11024 RawOneByteString* OneByteString::SubStringUnchecked(const String& str,
11099 intptr_t begin_index, 11025 intptr_t begin_index,
11100 intptr_t length, 11026 intptr_t length,
11101 Heap::Space space) { 11027 Heap::Space space) {
11102 ASSERT(!str.IsNull() && str.IsOneByteString()); 11028 ASSERT(!str.IsNull() && str.IsOneByteString());
11103 ASSERT(begin_index >= 0); 11029 ASSERT(begin_index >= 0);
11104 ASSERT(length >= 0); 11030 ASSERT(length >= 0);
11105 if (begin_index <= str.Length() && length == 0) { 11031 if (begin_index <= str.Length() && length == 0) {
11106 return OneByteString::raw(String::Handle(Symbols::Empty())); 11032 return OneByteString::raw(Symbols::Empty());
11107 } 11033 }
11108 ASSERT(begin_index < str.Length()); 11034 ASSERT(begin_index < str.Length());
11109 RawOneByteString* result = OneByteString::New(length, space); 11035 RawOneByteString* result = OneByteString::New(length, space);
11110 NoGCScope no_gc; 11036 NoGCScope no_gc;
11111 if (length > 0) { 11037 if (length > 0) {
11112 uint8_t* dest = &result->ptr()->data_[0]; 11038 uint8_t* dest = &result->ptr()->data_[0];
11113 uint8_t* src = &raw_ptr(str)->data_[begin_index]; 11039 uint8_t* src = &raw_ptr(str)->data_[begin_index];
11114 memmove(dest, src, length); 11040 memmove(dest, src, length);
11115 } 11041 }
11116 return result; 11042 return result;
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
12503 } 12429 }
12504 return result.raw(); 12430 return result.raw();
12505 } 12431 }
12506 12432
12507 12433
12508 const char* WeakProperty::ToCString() const { 12434 const char* WeakProperty::ToCString() const {
12509 return "_WeakProperty"; 12435 return "_WeakProperty";
12510 } 12436 }
12511 12437
12512 } // namespace dart 12438 } // namespace dart
OLDNEW
« no previous file with comments | « vm/megamorphic_cache_table.cc ('k') | vm/object_test.cc » ('j') | vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698