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

Side by Side Diff: runtime/vm/object.cc

Issue 144343002: Rename kDummyTokenIndex to kNoSourcePos (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 // Now that the symbol table is initialized and that the core dictionary as 960 // Now that the symbol table is initialized and that the core dictionary as
961 // well as the core implementation dictionary have been setup, preallocate 961 // well as the core implementation dictionary have been setup, preallocate
962 // remaining classes and register them by name in the dictionaries. 962 // remaining classes and register them by name in the dictionaries.
963 String& name = String::Handle(); 963 String& name = String::Handle();
964 cls = object_store->array_class(); // Was allocated above. 964 cls = object_store->array_class(); // Was allocated above.
965 RegisterPrivateClass(cls, Symbols::_List(), core_lib); 965 RegisterPrivateClass(cls, Symbols::_List(), core_lib);
966 pending_classes.Add(cls); 966 pending_classes.Add(cls);
967 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 967 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
968 type ^= Type::New(Object::Handle(cls.raw()), 968 type ^= Type::New(Object::Handle(cls.raw()),
969 TypeArguments::Handle(), 969 TypeArguments::Handle(),
970 Scanner::kDummyTokenIndex); 970 Scanner::kNoSourcePos);
971 type.SetIsFinalized(); 971 type.SetIsFinalized();
972 type ^= type.Canonicalize(); 972 type ^= type.Canonicalize();
973 object_store->set_array_type(type); 973 object_store->set_array_type(type);
974 974
975 cls = object_store->growable_object_array_class(); // Was allocated above. 975 cls = object_store->growable_object_array_class(); // Was allocated above.
976 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); 976 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib);
977 pending_classes.Add(cls); 977 pending_classes.Add(cls);
978 978
979 cls = Class::New<Array>(kImmutableArrayCid); 979 cls = Class::New<Array>(kImmutableArrayCid);
980 object_store->set_immutable_array_class(cls); 980 object_store->set_immutable_array_class(cls);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 // Return the still unfinalized signature type. 1655 // Return the still unfinalized signature type.
1656 ASSERT(!signature_type.IsFinalized()); 1656 ASSERT(!signature_type.IsFinalized());
1657 return signature_type.raw(); 1657 return signature_type.raw();
1658 } 1658 }
1659 1659
1660 1660
1661 RawAbstractType* Class::RareType() const { 1661 RawAbstractType* Class::RareType() const {
1662 const Type& type = Type::Handle(Type::New( 1662 const Type& type = Type::Handle(Type::New(
1663 *this, 1663 *this,
1664 Object::null_abstract_type_arguments(), 1664 Object::null_abstract_type_arguments(),
1665 Scanner::kDummyTokenIndex)); 1665 Scanner::kNoSourcePos));
1666 return ClassFinalizer::FinalizeType(*this, 1666 return ClassFinalizer::FinalizeType(*this,
1667 type, 1667 type,
1668 ClassFinalizer::kCanonicalize); 1668 ClassFinalizer::kCanonicalize);
1669 } 1669 }
1670 1670
1671 1671
1672 RawAbstractType* Class::DeclarationType() const { 1672 RawAbstractType* Class::DeclarationType() const {
1673 const TypeArguments& args = TypeArguments::Handle(type_parameters()); 1673 const TypeArguments& args = TypeArguments::Handle(type_parameters());
1674 const Type& type = Type::Handle(Type::New( 1674 const Type& type = Type::Handle(Type::New(
1675 *this, 1675 *this,
1676 args, 1676 args,
1677 Scanner::kDummyTokenIndex)); 1677 Scanner::kNoSourcePos));
1678 return ClassFinalizer::FinalizeType(*this, 1678 return ClassFinalizer::FinalizeType(*this,
1679 type, 1679 type,
1680 ClassFinalizer::kCanonicalize); 1680 ClassFinalizer::kCanonicalize);
1681 } 1681 }
1682 1682
1683 1683
1684 template <class FakeObject> 1684 template <class FakeObject>
1685 RawClass* Class::New() { 1685 RawClass* Class::New() {
1686 ASSERT(Object::class_class() != Class::null()); 1686 ASSERT(Object::class_class() != Class::null());
1687 Class& result = Class::Handle(); 1687 Class& result = Class::Handle();
(...skipping 11 matching lines...) Expand all
1699 ASSERT((FakeObject::kClassId != kInstanceCid)); 1699 ASSERT((FakeObject::kClassId != kInstanceCid));
1700 result.set_id(FakeObject::kClassId); 1700 result.set_id(FakeObject::kClassId);
1701 result.set_state_bits(0); 1701 result.set_state_bits(0);
1702 // VM backed classes are almost ready: run checks and resolve class 1702 // VM backed classes are almost ready: run checks and resolve class
1703 // references, but do not recompute size. 1703 // references, but do not recompute size.
1704 result.set_is_prefinalized(); 1704 result.set_is_prefinalized();
1705 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 1705 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
1706 result.set_num_type_arguments(0); 1706 result.set_num_type_arguments(0);
1707 result.set_num_own_type_arguments(0); 1707 result.set_num_own_type_arguments(0);
1708 result.set_num_native_fields(0); 1708 result.set_num_native_fields(0);
1709 result.set_token_pos(Scanner::kDummyTokenIndex); 1709 result.set_token_pos(Scanner::kNoSourcePos);
1710 result.InitEmptyFields(); 1710 result.InitEmptyFields();
1711 Isolate::Current()->RegisterClass(result); 1711 Isolate::Current()->RegisterClass(result);
1712 return result.raw(); 1712 return result.raw();
1713 } 1713 }
1714 1714
1715 1715
1716 1716
1717 static void ReportTooManyTypeArguments(const Class& cls) { 1717 static void ReportTooManyTypeArguments(const Class& cls) {
1718 const Error& error = Error::Handle( 1718 const Error& error = Error::Handle(
1719 LanguageError::NewFormatted( 1719 LanguageError::NewFormatted(
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 // In order to tokenize the source, we need to get the key to mangle 2495 // In order to tokenize the source, we need to get the key to mangle
2496 // private names from the library from which the object's class 2496 // private names from the library from which the object's class
2497 // originates. 2497 // originates.
2498 const Library& lib = Library::Handle(cls.library()); 2498 const Library& lib = Library::Handle(cls.library());
2499 ASSERT(!lib.IsNull()); 2499 ASSERT(!lib.IsNull());
2500 const String& lib_key = String::Handle(lib.private_key()); 2500 const String& lib_key = String::Handle(lib.private_key());
2501 script.Tokenize(lib_key); 2501 script.Tokenize(lib_key);
2502 2502
2503 const String& src_class_name = String::Handle(Symbols::New(":internal")); 2503 const String& src_class_name = String::Handle(Symbols::New(":internal"));
2504 const Class& src_class = Class::Handle( 2504 const Class& src_class = Class::Handle(
2505 Class::New(src_class_name, script, Scanner::kDummyTokenIndex)); 2505 Class::New(src_class_name, script, Scanner::kNoSourcePos));
2506 src_class.set_is_finalized(); 2506 src_class.set_is_finalized();
2507 src_class.set_library(lib); 2507 src_class.set_library(lib);
2508 return PatchClass::New(cls, src_class); 2508 return PatchClass::New(cls, src_class);
2509 } 2509 }
2510 2510
2511 2511
2512 RawObject* Class::Evaluate(const String& expr) const { 2512 RawObject* Class::Evaluate(const String& expr) const {
2513 const PatchClass& temp_class = 2513 const PatchClass& temp_class =
2514 PatchClass::Handle(MakeTempPatchClass(*this, expr)); 2514 PatchClass::Handle(MakeTempPatchClass(*this, expr));
2515 const String& eval_func_name = String::Handle(Symbols::New(":eval")); 2515 const String& eval_func_name = String::Handle(Symbols::New(":eval"));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 ASSERT(fake.IsInstance()); 2620 ASSERT(fake.IsInstance());
2621 result.set_handle_vtable(fake.vtable()); 2621 result.set_handle_vtable(fake.vtable());
2622 result.set_instance_size(FakeInstance::InstanceSize()); 2622 result.set_instance_size(FakeInstance::InstanceSize());
2623 result.set_next_field_offset(FakeInstance::NextFieldOffset()); 2623 result.set_next_field_offset(FakeInstance::NextFieldOffset());
2624 result.set_id(index); 2624 result.set_id(index);
2625 result.set_state_bits(0); 2625 result.set_state_bits(0);
2626 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 2626 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
2627 result.set_num_type_arguments(kUnknownNumTypeArguments); 2627 result.set_num_type_arguments(kUnknownNumTypeArguments);
2628 result.set_num_own_type_arguments(kUnknownNumTypeArguments); 2628 result.set_num_own_type_arguments(kUnknownNumTypeArguments);
2629 result.set_num_native_fields(0); 2629 result.set_num_native_fields(0);
2630 result.set_token_pos(Scanner::kDummyTokenIndex); 2630 result.set_token_pos(Scanner::kNoSourcePos);
2631 result.InitEmptyFields(); 2631 result.InitEmptyFields();
2632 Isolate::Current()->RegisterClass(result); 2632 Isolate::Current()->RegisterClass(result);
2633 return result.raw(); 2633 return result.raw();
2634 } 2634 }
2635 2635
2636 2636
2637 RawClass* Class::New(const String& name, 2637 RawClass* Class::New(const String& name,
2638 const Script& script, 2638 const Script& script,
2639 intptr_t token_pos) { 2639 intptr_t token_pos) {
2640 Class& result = Class::Handle(New<Instance>(kIllegalCid)); 2640 Class& result = Class::Handle(New<Instance>(kIllegalCid));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 } 2710 }
2711 set_is_prefinalized(); 2711 set_is_prefinalized();
2712 } 2712 }
2713 2713
2714 2714
2715 RawClass* Class::NewNativeWrapper(const Library& library, 2715 RawClass* Class::NewNativeWrapper(const Library& library,
2716 const String& name, 2716 const String& name,
2717 int field_count) { 2717 int field_count) {
2718 Class& cls = Class::Handle(library.LookupClass(name)); 2718 Class& cls = Class::Handle(library.LookupClass(name));
2719 if (cls.IsNull()) { 2719 if (cls.IsNull()) {
2720 cls = New(name, Script::Handle(), Scanner::kDummyTokenIndex); 2720 cls = New(name, Script::Handle(), Scanner::kNoSourcePos);
2721 cls.SetFields(Object::empty_array()); 2721 cls.SetFields(Object::empty_array());
2722 cls.SetFunctions(Object::empty_array()); 2722 cls.SetFunctions(Object::empty_array());
2723 // Set super class to Object. 2723 // Set super class to Object.
2724 cls.set_super_type(Type::Handle(Type::ObjectType())); 2724 cls.set_super_type(Type::Handle(Type::ObjectType()));
2725 // Compute instance size. First word contains a pointer to a properly 2725 // Compute instance size. First word contains a pointer to a properly
2726 // sized typed array once the first native field has been set. 2726 // sized typed array once the first native field has been set.
2727 intptr_t instance_size = sizeof(RawInstance) + kWordSize; 2727 intptr_t instance_size = sizeof(RawInstance) + kWordSize;
2728 cls.set_instance_size(RoundedAllocationSize(instance_size)); 2728 cls.set_instance_size(RoundedAllocationSize(instance_size));
2729 cls.set_next_field_offset(instance_size); 2729 cls.set_next_field_offset(instance_size);
2730 cls.set_num_native_fields(field_count); 2730 cls.set_num_native_fields(field_count);
(...skipping 8807 matching lines...) Expand 10 before | Expand all | Expand 10 after
11538 if (IsNull()) { 11538 if (IsNull()) {
11539 return Type::NullType(); 11539 return Type::NullType();
11540 } 11540 }
11541 const Class& cls = Class::Handle(clazz()); 11541 const Class& cls = Class::Handle(clazz());
11542 Type& type = Type::Handle(cls.CanonicalType()); 11542 Type& type = Type::Handle(cls.CanonicalType());
11543 if (type.IsNull()) { 11543 if (type.IsNull()) {
11544 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 11544 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
11545 if (cls.NumTypeArguments() > 0) { 11545 if (cls.NumTypeArguments() > 0) {
11546 type_arguments = GetTypeArguments(); 11546 type_arguments = GetTypeArguments();
11547 } 11547 }
11548 type = Type::New(cls, type_arguments, Scanner::kDummyTokenIndex); 11548 type = Type::New(cls, type_arguments, Scanner::kNoSourcePos);
11549 type.SetIsFinalized(); 11549 type.SetIsFinalized();
11550 type ^= type.Canonicalize(); 11550 type ^= type.Canonicalize();
11551 } 11551 }
11552 return type.raw(); 11552 return type.raw();
11553 } 11553 }
11554 11554
11555 11555
11556 RawAbstractTypeArguments* Instance::GetTypeArguments() const { 11556 RawAbstractTypeArguments* Instance::GetTypeArguments() const {
11557 const Class& cls = Class::Handle(clazz()); 11557 const Class& cls = Class::Handle(clazz());
11558 intptr_t field_offset = cls.type_arguments_field_offset(); 11558 intptr_t field_offset = cls.type_arguments_field_offset();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
11730 return Closure::ToCString(*this); 11730 return Closure::ToCString(*this);
11731 } 11731 }
11732 const char* kFormat = "Instance of '%s'"; 11732 const char* kFormat = "Instance of '%s'";
11733 const Class& cls = Class::Handle(clazz()); 11733 const Class& cls = Class::Handle(clazz());
11734 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 11734 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
11735 const intptr_t num_type_arguments = cls.NumTypeArguments(); 11735 const intptr_t num_type_arguments = cls.NumTypeArguments();
11736 if (num_type_arguments > 0) { 11736 if (num_type_arguments > 0) {
11737 type_arguments = GetTypeArguments(); 11737 type_arguments = GetTypeArguments();
11738 } 11738 }
11739 const Type& type = 11739 const Type& type =
11740 Type::Handle(Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); 11740 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos));
11741 const String& type_name = String::Handle(type.UserVisibleName()); 11741 const String& type_name = String::Handle(type.UserVisibleName());
11742 // Calculate the size of the string. 11742 // Calculate the size of the string.
11743 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 11743 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
11744 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 11744 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
11745 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); 11745 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
11746 return chars; 11746 return chars;
11747 } 11747 }
11748 } 11748 }
11749 11749
11750 11750
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
12280 if (Object::dynamic_type() != reinterpret_cast<RawType*>(RAW_NULL)) { 12280 if (Object::dynamic_type() != reinterpret_cast<RawType*>(RAW_NULL)) {
12281 return Object::dynamic_type(); 12281 return Object::dynamic_type();
12282 } 12282 }
12283 ASSERT(Isolate::Current() == Dart::vm_isolate()); 12283 ASSERT(Isolate::Current() == Dart::vm_isolate());
12284 } 12284 }
12285 Type& type = Type::Handle(type_class.CanonicalType()); 12285 Type& type = Type::Handle(type_class.CanonicalType());
12286 if (type.IsNull()) { 12286 if (type.IsNull()) {
12287 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 12287 const TypeArguments& no_type_arguments = TypeArguments::Handle();
12288 type ^= Type::New(Object::Handle(type_class.raw()), 12288 type ^= Type::New(Object::Handle(type_class.raw()),
12289 no_type_arguments, 12289 no_type_arguments,
12290 Scanner::kDummyTokenIndex); 12290 Scanner::kNoSourcePos);
12291 type.SetIsFinalized(); 12291 type.SetIsFinalized();
12292 type ^= type.Canonicalize(); 12292 type ^= type.Canonicalize();
12293 } 12293 }
12294 return type.raw(); 12294 return type.raw();
12295 } 12295 }
12296 12296
12297 12297
12298 void Type::SetIsFinalized() const { 12298 void Type::SetIsFinalized() const {
12299 ASSERT(!IsFinalized()); 12299 ASSERT(!IsFinalized());
12300 if (IsInstantiated()) { 12300 if (IsInstantiated()) {
(...skipping 4690 matching lines...) Expand 10 before | Expand all | Expand 10 after
16991 return "_MirrorReference"; 16991 return "_MirrorReference";
16992 } 16992 }
16993 16993
16994 16994
16995 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 16995 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
16996 Instance::PrintToJSONStream(stream, ref); 16996 Instance::PrintToJSONStream(stream, ref);
16997 } 16997 }
16998 16998
16999 16999
17000 } // namespace dart 17000 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698