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

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

Issue 1723733002: Simplify various name flavors in VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 9 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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // The trailing . on the default constructor name is dropped: 209 // The trailing . on the default constructor name is dropped:
210 // 210 //
211 // List. -> List 211 // List. -> List
212 // 212 //
213 // And so forth: 213 // And so forth:
214 // 214 //
215 // get:foo@6328321 -> foo 215 // get:foo@6328321 -> foo
216 // _MyClass@6328321. -> _MyClass 216 // _MyClass@6328321. -> _MyClass
217 // _MyClass@6328321.named -> _MyClass.named 217 // _MyClass@6328321.named -> _MyClass.named
218 // 218 //
219 RawString* String::IdentifierPrettyName(const String& name) { 219 RawString* String::ScrubName(const String& name) {
220 Zone* zone = Thread::Current()->zone(); 220 Zone* zone = Thread::Current()->zone();
221
222 NOT_IN_PRODUCT(
221 if (name.Equals(Symbols::TopLevel())) { 223 if (name.Equals(Symbols::TopLevel())) {
222 // Name of invisible top-level class. 224 // Name of invisible top-level class.
223 return Symbols::Empty().raw(); 225 return Symbols::Empty().raw();
224 } 226 }
227 )
225 228
226 const char* cname = name.ToCString(); 229 const char* cname = name.ToCString();
227 ASSERT(strlen(cname) == static_cast<size_t>(name.Length())); 230 ASSERT(strlen(cname) == static_cast<size_t>(name.Length()));
228 const intptr_t name_len = name.Length(); 231 const intptr_t name_len = name.Length();
229 // First remove all private name mangling. 232 // First remove all private name mangling.
230 intptr_t start_pos = 0; 233 intptr_t start_pos = 0;
231 GrowableArray<const char*> unmangled_segments; 234 GrowableArray<const char*> unmangled_segments;
232 intptr_t sum_segment_len = 0; 235 intptr_t sum_segment_len = 0;
233 for (intptr_t i = 0; i < name_len; i++) { 236 for (intptr_t i = 0; i < name_len; i++) {
234 if ((cname[i] == '@') && ((i + 1) < name_len) && 237 if ((cname[i] == '@') && ((i + 1) < name_len) &&
(...skipping 24 matching lines...) Expand all
259 // Append the last segment. 262 // Append the last segment.
260 const intptr_t segment_len = name.Length() - start_pos; 263 const intptr_t segment_len = name.Length() - start_pos;
261 sum_segment_len += segment_len; 264 sum_segment_len += segment_len;
262 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len); 265 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len);
263 } 266 }
264 if (unmangled_name == NULL) { 267 if (unmangled_name == NULL) {
265 // Merge unmangled_segments. 268 // Merge unmangled_segments.
266 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len); 269 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len);
267 } 270 }
268 271
272 NOT_IN_PRODUCT(
269 intptr_t len = sum_segment_len; 273 intptr_t len = sum_segment_len;
270 intptr_t start = 0; 274 intptr_t start = 0;
271 intptr_t dot_pos = -1; // Position of '.' in the name, if any. 275 intptr_t dot_pos = -1; // Position of '.' in the name, if any.
272 bool is_setter = false; 276 bool is_setter = false;
273 for (intptr_t i = start; i < len; i++) { 277 for (intptr_t i = start; i < len; i++) {
274 if (unmangled_name[i] == ':') { 278 if (unmangled_name[i] == ':') {
275 if (start != 0) { 279 if (start != 0) {
276 // Reset and break. 280 // Reset and break.
277 start = 0; 281 start = 0;
278 dot_pos = -1; 282 dot_pos = -1;
(...skipping 28 matching lines...) Expand all
307 intptr_t final_len = end - start; 311 intptr_t final_len = end - start;
308 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len); 312 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len);
309 if (is_setter) { 313 if (is_setter) {
310 const char* equals = Symbols::Equals().ToCString(); 314 const char* equals = Symbols::Equals().ToCString();
311 const intptr_t equals_len = strlen(equals); 315 const intptr_t equals_len = strlen(equals);
312 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len); 316 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len);
313 final_len += equals_len; 317 final_len += equals_len;
314 } 318 }
315 319
316 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len); 320 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len);
321 )
317 322
318 return Symbols::New(unmangled_name); 323 return Symbols::New(unmangled_name);
319 } 324 }
320 325
321 326
322 RawString* String::IdentifierPrettyNameRetainPrivate(const String& name) { 327 RawString* String::ScrubNameRetainPrivate(const String& name) {
328 NOT_IN_PRODUCT(
323 intptr_t len = name.Length(); 329 intptr_t len = name.Length();
324 intptr_t start = 0; 330 intptr_t start = 0;
325 intptr_t at_pos = -1; // Position of '@' in the name, if any. 331 intptr_t at_pos = -1; // Position of '@' in the name, if any.
326 bool is_setter = false; 332 bool is_setter = false;
327 333
328 for (intptr_t i = start; i < len; i++) { 334 for (intptr_t i = start; i < len; i++) {
329 if (name.CharAt(i) == ':') { 335 if (name.CharAt(i) == ':') {
330 ASSERT(start == 0); // Only one : is possible in getters or setters. 336 ASSERT(start == 0); // Only one : is possible in getters or setters.
331 if (name.CharAt(0) == 's') { 337 if (name.CharAt(0) == 's') {
332 is_setter = true; 338 is_setter = true;
(...skipping 22 matching lines...) Expand all
355 const String& pre_at = 361 const String& pre_at =
356 String::Handle(String::SubString(result, 0, at_pos - 4)); 362 String::Handle(String::SubString(result, 0, at_pos - 4));
357 const String& post_at = 363 const String& post_at =
358 String::Handle(String::SubString(name, at_pos, len - at_pos)); 364 String::Handle(String::SubString(name, at_pos, len - at_pos));
359 result = String::Concat(pre_at, Symbols::Equals()); 365 result = String::Concat(pre_at, Symbols::Equals());
360 result = String::Concat(result, post_at); 366 result = String::Concat(result, post_at);
361 } 367 }
362 } 368 }
363 369
364 return result.raw(); 370 return result.raw();
371 )
372 return name.raw(); // In PRODUCT, return argument unchanged.
365 } 373 }
366 374
367 375
368 template<typename type> 376 template<typename type>
369 static bool IsSpecialCharacter(type value) { 377 static bool IsSpecialCharacter(type value) {
370 return ((value == '"') || 378 return ((value == '"') ||
371 (value == '\n') || 379 (value == '\n') ||
372 (value == '\f') || 380 (value == '\f') ||
373 (value == '\b') || 381 (value == '\b') ||
374 (value == '\t') || 382 (value == '\t') ||
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 str = lib.PrivateName(public_class_name); 1098 str = lib.PrivateName(public_class_name);
1091 cls.set_name(str); 1099 cls.set_name(str);
1092 lib.AddClass(cls); 1100 lib.AddClass(cls);
1093 } 1101 }
1094 1102
1095 1103
1096 RawError* Object::Init(Isolate* isolate) { 1104 RawError* Object::Init(Isolate* isolate) {
1097 Thread* thread = Thread::Current(); 1105 Thread* thread = Thread::Current();
1098 Zone* zone = thread->zone(); 1106 Zone* zone = thread->zone();
1099 ASSERT(isolate == thread->isolate()); 1107 ASSERT(isolate == thread->isolate());
1100 #ifndef PRODUCT 1108 NOT_IN_PRODUCT(
1101 TimelineDurationScope tds(thread, 1109 TimelineDurationScope tds(thread,
1102 isolate->GetIsolateStream(), 1110 isolate->GetIsolateStream(),
1103 "Object::Init"); 1111 "Object::Init");
1104 #endif 1112 )
1105 1113
1106 #if defined(DART_NO_SNAPSHOT) 1114 #if defined(DART_NO_SNAPSHOT)
1107 // Object::Init version when we are running in a version of dart that does 1115 // Object::Init version when we are running in a version of dart that does
1108 // not have a full snapshot linked in. 1116 // not have a full snapshot linked in.
1109 ObjectStore* object_store = isolate->object_store(); 1117 ObjectStore* object_store = isolate->object_store();
1110 1118
1111 Class& cls = Class::Handle(zone); 1119 Class& cls = Class::Handle(zone);
1112 Type& type = Type::Handle(zone); 1120 Type& type = Type::Handle(zone);
1113 Array& array = Array::Handle(zone); 1121 Array& array = Array::Handle(zone);
1114 Library& lib = Library::Handle(zone); 1122 Library& lib = Library::Handle(zone);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 if (lib.IsNull()) { 1376 if (lib.IsNull()) {
1369 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); 1377 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true);
1370 lib.SetLoadRequested(); 1378 lib.SetLoadRequested();
1371 lib.Register(); 1379 lib.Register();
1372 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib); 1380 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib);
1373 } 1381 }
1374 ASSERT(!lib.IsNull()); 1382 ASSERT(!lib.IsNull());
1375 ASSERT(lib.raw() == Library::MirrorsLibrary()); 1383 ASSERT(lib.raw() == Library::MirrorsLibrary());
1376 1384
1377 cls = Class::New<MirrorReference>(); 1385 cls = Class::New<MirrorReference>();
1378 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib)); 1386 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib);
1387 )
1379 1388
1380 // Pre-register the collection library so we can place the vm class 1389 // Pre-register the collection library so we can place the vm class
1381 // LinkedHashMap there rather than the core library. 1390 // LinkedHashMap there rather than the core library.
1382 lib = Library::LookupLibrary(Symbols::DartCollection()); 1391 lib = Library::LookupLibrary(Symbols::DartCollection());
1383 if (lib.IsNull()) { 1392 if (lib.IsNull()) {
1384 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true); 1393 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true);
1385 lib.SetLoadRequested(); 1394 lib.SetLoadRequested();
1386 lib.Register(); 1395 lib.Register();
1387 object_store->set_bootstrap_library(ObjectStore::kCollection, lib); 1396 object_store->set_bootstrap_library(ObjectStore::kCollection, lib);
1388 } 1397 }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 1919
1911 1920
1912 RawString* Class::Name() const { 1921 RawString* Class::Name() const {
1913 // TODO(turnidge): This assert fails for the fake kFreeListElement class. 1922 // TODO(turnidge): This assert fails for the fake kFreeListElement class.
1914 // Fix this. 1923 // Fix this.
1915 ASSERT(raw_ptr()->name_ != String::null()); 1924 ASSERT(raw_ptr()->name_ != String::null());
1916 return raw_ptr()->name_; 1925 return raw_ptr()->name_;
1917 } 1926 }
1918 1927
1919 1928
1920 RawString* Class::PrettyName() const { 1929 RawString* Class::ScrubbedName() const {
1921 return GeneratePrettyName(); 1930 return String::ScrubName(String::Handle(Name()));
1922 } 1931 }
1923 1932
1924 1933
1925 RawString* Class::UserVisibleName() const { 1934 RawString* Class::UserVisibleName() const {
1926 #if defined(PRODUCT) 1935 NOT_IN_PRODUCT(
1927 return raw_ptr()->name_;
1928 #else // defined(PRODUCT)
1929 ASSERT(raw_ptr()->user_name_ != String::null()); 1936 ASSERT(raw_ptr()->user_name_ != String::null());
1930 return raw_ptr()->user_name_; 1937 return raw_ptr()->user_name_;
1931 #endif // defined(PRODUCT) 1938 )
1939 return GenerateUserVisibleName(); // No caching in PRODUCT, regenerate.
1932 } 1940 }
1933 1941
1934 1942
1935 bool Class::IsInFullSnapshot() const { 1943 bool Class::IsInFullSnapshot() const {
1936 NoSafepointScope no_safepoint; 1944 NoSafepointScope no_safepoint;
1937 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; 1945 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_;
1938 } 1946 }
1939 1947
1940 1948
1941 RawAbstractType* Class::RareType() const { 1949 RawAbstractType* Class::RareType() const {
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 intptr_t instance_size = ExternalTypedData::InstanceSize(); 3162 intptr_t instance_size = ExternalTypedData::InstanceSize();
3155 Class& result = Class::Handle(New<ExternalTypedData>(class_id)); 3163 Class& result = Class::Handle(New<ExternalTypedData>(class_id));
3156 result.set_instance_size(instance_size); 3164 result.set_instance_size(instance_size);
3157 result.set_next_field_offset(ExternalTypedData::NextFieldOffset()); 3165 result.set_next_field_offset(ExternalTypedData::NextFieldOffset());
3158 result.set_is_prefinalized(); 3166 result.set_is_prefinalized();
3159 return result.raw(); 3167 return result.raw();
3160 } 3168 }
3161 3169
3162 3170
3163 void Class::set_name(const String& value) const { 3171 void Class::set_name(const String& value) const {
3172 ASSERT(raw_ptr()->name_ == String::null());
3164 ASSERT(value.IsSymbol()); 3173 ASSERT(value.IsSymbol());
3165 StorePointer(&raw_ptr()->name_, value.raw()); 3174 StorePointer(&raw_ptr()->name_, value.raw());
3166 NOT_IN_PRODUCT( 3175 NOT_IN_PRODUCT(
3167 if (raw_ptr()->user_name_ == String::null()) { 3176 if (raw_ptr()->user_name_ == String::null()) {
3168 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes, 3177 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes,
3169 // lazily set user name for the other classes. 3178 // lazily set user name for the other classes.
3170 // Generate and set user_name. 3179 // Generate and set user_name.
3171 const String& user_name = String::Handle(GenerateUserVisibleName()); 3180 const String& user_name = String::Handle(GenerateUserVisibleName());
3172 set_user_name(user_name); 3181 set_user_name(user_name);
3173 } 3182 }
3174 ) 3183 )
3175 } 3184 }
3176 3185
3177 3186
3178 NOT_IN_PRODUCT( 3187 NOT_IN_PRODUCT(
3179 void Class::set_user_name(const String& value) const { 3188 void Class::set_user_name(const String& value) const {
3180 StorePointer(&raw_ptr()->user_name_, value.raw()); 3189 StorePointer(&raw_ptr()->user_name_, value.raw());
3181 } 3190 }
3182 ) 3191 )
3183 3192
3184 3193
3185 RawString* Class::GeneratePrettyName() const {
3186 const String& name = String::Handle(Name());
3187 return String::IdentifierPrettyName(name);
3188 }
3189
3190
3191 RawString* Class::GenerateUserVisibleName() const { 3194 RawString* Class::GenerateUserVisibleName() const {
3192 if (FLAG_show_internal_names) { 3195 if (FLAG_show_internal_names) {
3193 return Name(); 3196 return Name();
3194 } 3197 }
3198 NOT_IN_PRODUCT(
3195 switch (id()) { 3199 switch (id()) {
3196 case kNullCid: 3200 case kNullCid:
3197 return Symbols::Null().raw(); 3201 return Symbols::Null().raw();
3198 case kDynamicCid: 3202 case kDynamicCid:
3199 return Symbols::Dynamic().raw(); 3203 return Symbols::Dynamic().raw();
3200 case kVoidCid: 3204 case kVoidCid:
3201 return Symbols::Void().raw(); 3205 return Symbols::Void().raw();
3202 case kClassCid: 3206 case kClassCid:
3203 return Symbols::Class().raw(); 3207 return Symbols::Class().raw();
3204 case kUnresolvedClassCid: 3208 case kUnresolvedClassCid:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 return Symbols::Float32x4List().raw(); 3320 return Symbols::Float32x4List().raw();
3317 case kTypedDataFloat64x2ArrayCid: 3321 case kTypedDataFloat64x2ArrayCid:
3318 case kExternalTypedDataFloat64x2ArrayCid: 3322 case kExternalTypedDataFloat64x2ArrayCid:
3319 return Symbols::Float64x2List().raw(); 3323 return Symbols::Float64x2List().raw();
3320 case kTypedDataFloat32ArrayCid: 3324 case kTypedDataFloat32ArrayCid:
3321 case kExternalTypedDataFloat32ArrayCid: 3325 case kExternalTypedDataFloat32ArrayCid:
3322 return Symbols::Float32List().raw(); 3326 return Symbols::Float32List().raw();
3323 case kTypedDataFloat64ArrayCid: 3327 case kTypedDataFloat64ArrayCid:
3324 case kExternalTypedDataFloat64ArrayCid: 3328 case kExternalTypedDataFloat64ArrayCid:
3325 return Symbols::Float64List().raw(); 3329 return Symbols::Float64List().raw();
3326 default:
3327 const String& name = String::Handle(Name());
3328 return String::IdentifierPrettyName(name);
3329 } 3330 }
3330 UNREACHABLE(); 3331 )
3332 const String& name = String::Handle(Name());
3333 return String::ScrubName(name);
3331 } 3334 }
3332 3335
3333 3336
3334 void Class::set_script(const Script& value) const { 3337 void Class::set_script(const Script& value) const {
3335 StorePointer(&raw_ptr()->script_, value.raw()); 3338 StorePointer(&raw_ptr()->script_, value.raw());
3336 } 3339 }
3337 3340
3338 3341
3339 void Class::set_token_pos(TokenPosition token_pos) const { 3342 void Class::set_token_pos(TokenPosition token_pos) const {
3340 ASSERT(!token_pos.IsClassifying()); 3343 ASSERT(!token_pos.IsClassifying());
(...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 ASSERT(obj.IsPatchClass()); 6651 ASSERT(obj.IsPatchClass());
6649 return PatchClass::Cast(obj).script(); 6652 return PatchClass::Cast(obj).script();
6650 } 6653 }
6651 6654
6652 6655
6653 bool Function::HasOptimizedCode() const { 6656 bool Function::HasOptimizedCode() const {
6654 return HasCode() && Code::Handle(CurrentCode()).is_optimized(); 6657 return HasCode() && Code::Handle(CurrentCode()).is_optimized();
6655 } 6658 }
6656 6659
6657 6660
6658 RawString* Function::PrettyName() const {
6659 const String& str = String::Handle(name());
6660 return String::IdentifierPrettyName(str);
6661 }
6662
6663
6664 const char* Function::QualifiedUserVisibleNameCString() const {
6665 const String& str = String::Handle(QualifiedUserVisibleName());
6666 return str.ToCString();
6667 }
6668
6669
6670 RawString* Function::UserVisibleName() const { 6661 RawString* Function::UserVisibleName() const {
6671 return PrettyName(); 6662 if (FLAG_show_internal_names) {
6663 return name();
6664 }
6665 return String::ScrubName(String::Handle(name()));
6672 } 6666 }
6673 6667
6674 6668
6675 RawString* Function::QualifiedPrettyName() const { 6669 RawString* Function::QualifiedName(NameVisibility name_visibility) const {
6676 String& tmp = String::Handle(); 6670 ASSERT(name_visibility != kInternalName); // We never request it.
6677 const Class& cls = Class::Handle(Owner()); 6671 // A function's scrubbed name and its user visible name are identical.
6678 6672 String& result = String::Handle(UserVisibleName());
6679 if (IsClosureFunction()) { 6673 if (IsClosureFunction()) {
6680 if (IsLocalFunction() && !IsImplicitClosureFunction()) { 6674 Function& fun = Function::Handle(raw());
6681 const Function& parent = Function::Handle(parent_function()); 6675 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
6682 tmp = parent.QualifiedPrettyName(); 6676 fun = fun.parent_function();
6683 } else { 6677 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6684 return PrettyName(); 6678 result = String::Concat(
6685 } 6679 String::Handle(fun.UserVisibleName()), result, Heap::kOld);
6686 } else {
6687 if (cls.IsTopLevel()) {
6688 return PrettyName();
6689 } else {
6690 tmp = cls.PrettyName();
6691 } 6680 }
6692 } 6681 }
6693 tmp = String::Concat(tmp, Symbols::Dot(), Heap::kOld); 6682 const Class& cls = Class::Handle(Owner());
6694 const String& suffix = String::Handle(PrettyName()); 6683 if (!cls.IsTopLevel()) {
6695 return String::Concat(tmp, suffix, Heap::kOld); 6684 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6685 const String& cls_name = String::Handle(
6686 name_visibility == kScrubbedName ? cls.ScrubbedName()
6687 : cls.UserVisibleName());
6688 result = String::Concat(cls_name, result, Heap::kOld);
6689 }
6690 return result.raw();
6696 } 6691 }
6697 6692
6698 6693
6699 RawString* Function::QualifiedUserVisibleName() const {
6700 String& tmp = String::Handle();
6701 const Class& cls = Class::Handle(Owner());
6702
6703 if (IsClosureFunction()) {
6704 if (IsLocalFunction() && !IsImplicitClosureFunction()) {
6705 const Function& parent = Function::Handle(parent_function());
6706 tmp = parent.QualifiedUserVisibleName();
6707 } else {
6708 return UserVisibleName();
6709 }
6710 } else {
6711 if (cls.IsTopLevel()) {
6712 return UserVisibleName();
6713 } else {
6714 tmp = cls.UserVisibleName();
6715 }
6716 }
6717 tmp = String::Concat(tmp, Symbols::Dot());
6718 const String& suffix = String::Handle(UserVisibleName());
6719 return String::Concat(tmp, suffix);
6720 }
6721
6722
6723 RawString* Function::GetSource() const { 6694 RawString* Function::GetSource() const {
6724 if (IsImplicitConstructor() || IsSignatureFunction()) { 6695 if (IsImplicitConstructor() || IsSignatureFunction()) {
6725 // We may need to handle more cases when the restrictions on mixins are 6696 // We may need to handle more cases when the restrictions on mixins are
6726 // relaxed. In particular we might start associating some source with the 6697 // relaxed. In particular we might start associating some source with the
6727 // forwarding constructors when it becomes possible to specify a particular 6698 // forwarding constructors when it becomes possible to specify a particular
6728 // constructor from the mixin to use. 6699 // constructor from the mixin to use.
6729 return String::null(); 6700 return String::null();
6730 } 6701 }
6731 const Script& func_script = Script::Handle(script()); 6702 const Script& func_script = Script::Handle(script());
6732 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); 6703 const TokenStream& stream = TokenStream::Handle(func_script.tokens());
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
7201 if (new_owner.NumTypeParameters() > 0) { 7172 if (new_owner.NumTypeParameters() > 0) {
7202 // Adjust the field type to refer to type parameters of the new owner. 7173 // Adjust the field type to refer to type parameters of the new owner.
7203 AbstractType& type = AbstractType::Handle(clone.type()); 7174 AbstractType& type = AbstractType::Handle(clone.type());
7204 type ^= type.CloneUninstantiated(new_owner); 7175 type ^= type.CloneUninstantiated(new_owner);
7205 clone.SetFieldType(type); 7176 clone.SetFieldType(type);
7206 } 7177 }
7207 return clone.raw(); 7178 return clone.raw();
7208 } 7179 }
7209 7180
7210 7181
7211 RawString* Field::PrettyName() const {
7212 const String& str = String::Handle(name());
7213 return String::IdentifierPrettyName(str);
7214 }
7215
7216
7217 RawString* Field::UserVisibleName() const { 7182 RawString* Field::UserVisibleName() const {
7218 return PrettyName(); 7183 if (FLAG_show_internal_names) {
7184 return name();
7185 }
7186 return String::ScrubName(String::Handle(name()));
7219 } 7187 }
7220 7188
7221 7189
7222 intptr_t Field::guarded_list_length() const { 7190 intptr_t Field::guarded_list_length() const {
7223 return Smi::Value(raw_ptr()->guarded_list_length_); 7191 return Smi::Value(raw_ptr()->guarded_list_length_);
7224 } 7192 }
7225 7193
7226 7194
7227 void Field::set_guarded_list_length(intptr_t list_length) const { 7195 void Field::set_guarded_list_length(intptr_t list_length) const {
7228 ASSERT(Thread::Current()->IsMutatorThread()); 7196 ASSERT(Thread::Current()->IsMutatorThread());
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
8965 return Symbols::FromConcatAll(pieces); 8933 return Symbols::FromConcatAll(pieces);
8966 } 8934 }
8967 8935
8968 8936
8969 static RawString* MakeFunctionMetaName(const Function& func) { 8937 static RawString* MakeFunctionMetaName(const Function& func) {
8970 const String& cname = 8938 const String& cname =
8971 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); 8939 String::Handle(MakeClassMetaName(Class::Handle(func.origin())));
8972 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8940 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8973 pieces.Add(cname); 8941 pieces.Add(cname);
8974 pieces.Add(Symbols::At()); 8942 pieces.Add(Symbols::At());
8975 pieces.Add(String::Handle(func.QualifiedPrettyName())); 8943 pieces.Add(String::Handle(func.QualifiedScrubbedName()));
8976 return Symbols::FromConcatAll(pieces); 8944 return Symbols::FromConcatAll(pieces);
8977 } 8945 }
8978 8946
8979 8947
8980 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { 8948 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) {
8981 const String& cname = String::Handle( 8949 const String& cname = String::Handle(
8982 MakeClassMetaName(Class::Handle(param.parameterized_class()))); 8950 MakeClassMetaName(Class::Handle(param.parameterized_class())));
8983 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8951 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8984 pieces.Add(cname); 8952 pieces.Add(cname);
8985 pieces.Add(Symbols::At()); 8953 pieces.Add(Symbols::At());
(...skipping 4039 matching lines...) Expand 10 before | Expand all | Expand 10 after
13025 Zone* zone = Thread::Current()->zone(); 12993 Zone* zone = Thread::Current()->zone();
13026 if (IsStubCode()) { 12994 if (IsStubCode()) {
13027 const char* name = StubCode::NameOfStub(EntryPoint()); 12995 const char* name = StubCode::NameOfStub(EntryPoint());
13028 return zone->PrintToString("[stub: %s]", name); 12996 return zone->PrintToString("[stub: %s]", name);
13029 } else { 12997 } else {
13030 return zone->PrintToString("Code entry:%" Px, EntryPoint()); 12998 return zone->PrintToString("Code entry:%" Px, EntryPoint());
13031 } 12999 }
13032 } 13000 }
13033 13001
13034 13002
13035 // Called by disassembler.
13036 RawString* Code::Name() const { 13003 RawString* Code::Name() const {
13037 const Object& obj = Object::Handle(owner()); 13004 const Object& obj = Object::Handle(owner());
13038 if (obj.IsNull()) { 13005 if (obj.IsNull()) {
13039 // Regular stub. 13006 // Regular stub.
13040 const char* name = StubCode::NameOfStub(EntryPoint()); 13007 const char* name = StubCode::NameOfStub(EntryPoint());
13041 ASSERT(name != NULL); 13008 ASSERT(name != NULL);
13042 const String& stub_name = String::Handle(Symbols::New(name)); 13009 const String& stub_name = String::Handle(Symbols::New(name));
13043 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name); 13010 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name);
13044 } else if (obj.IsClass()) { 13011 } else if (obj.IsClass()) {
13045 // Allocation stub. 13012 // Allocation stub.
13046 const Class& cls = Class::Cast(obj); 13013 const Class& cls = Class::Cast(obj);
13047 String& cls_name = String::Handle(cls.Name()); 13014 String& cls_name = String::Handle(cls.ScrubbedName());
13048 ASSERT(!cls_name.IsNull()); 13015 ASSERT(!cls_name.IsNull());
13049 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name); 13016 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name);
13050 } else { 13017 } else {
13051 ASSERT(obj.IsFunction()); 13018 ASSERT(obj.IsFunction());
13052 // Dart function. 13019 // Dart function.
13053 return Function::Cast(obj).name(); 13020 return Function::Cast(obj).UserVisibleName(); // Same as scrubbed name.
13054 } 13021 }
13055 } 13022 }
13056 13023
13057 13024
13058 RawString* Code::PrettyName() const { 13025 RawString* Code::QualifiedName() const {
13059 const Object& obj = Object::Handle(owner()); 13026 const Object& obj = Object::Handle(owner());
13060 if (obj.IsNull()) { 13027 if (obj.IsFunction()) {
13061 // Regular stub. 13028 return Function::Cast(obj).QualifiedScrubbedName();
13062 const char* name = StubCode::NameOfStub(EntryPoint());
13063 ASSERT(name != NULL);
13064 const String& stub_name = String::Handle(String::New(name));
13065 return String::Concat(Symbols::StubPrefix(), stub_name);
13066 } else if (obj.IsClass()) {
13067 // Allocation stub.
13068 const Class& cls = Class::Cast(obj);
13069 String& cls_name = String::Handle(cls.Name());
13070 ASSERT(!cls_name.IsNull());
13071 return String::Concat(Symbols::AllocationStubFor(), cls_name);
13072 } else {
13073 ASSERT(obj.IsFunction());
13074 // Dart function.
13075 return Function::Cast(obj).QualifiedPrettyName();
13076 } 13029 }
13030 return Name();
13077 } 13031 }
13078 13032
13079 13033
13080 bool Code::IsAllocationStubCode() const { 13034 bool Code::IsAllocationStubCode() const {
13081 const Object& obj = Object::Handle(owner()); 13035 const Object& obj = Object::Handle(owner());
13082 return obj.IsClass(); 13036 return obj.IsClass();
13083 } 13037 }
13084 13038
13085 13039
13086 bool Code::IsStubCode() const { 13040 bool Code::IsStubCode() const {
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
14778 } 14732 }
14779 } 14733 }
14780 } 14734 }
14781 (*trail)->Add(*this); 14735 (*trail)->Add(*this);
14782 (*trail)->Add(buddy); 14736 (*trail)->Add(buddy);
14783 return false; 14737 return false;
14784 } 14738 }
14785 14739
14786 14740
14787 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { 14741 RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
14742 ASSERT(name_visibility != kScrubbedName);
14788 Zone* zone = Thread::Current()->zone(); 14743 Zone* zone = Thread::Current()->zone();
14789 if (IsBoundedType()) { 14744 if (IsBoundedType()) {
14790 const AbstractType& type = AbstractType::Handle( 14745 const AbstractType& type = AbstractType::Handle(
14791 BoundedType::Cast(*this).type()); 14746 BoundedType::Cast(*this).type());
14792 if (name_visibility == kPrettyName) { 14747 if (name_visibility == kUserVisibleName) {
14793 return type.BuildName(kPrettyName);
14794 } else if (name_visibility == kUserVisibleName) {
14795 return type.BuildName(kUserVisibleName); 14748 return type.BuildName(kUserVisibleName);
14796 } 14749 }
14797 GrowableHandlePtrArray<const String> pieces(zone, 5); 14750 GrowableHandlePtrArray<const String> pieces(zone, 5);
14798 String& type_name = String::Handle(zone, type.BuildName(kInternalName)); 14751 String& type_name = String::Handle(zone, type.BuildName(kInternalName));
14799 pieces.Add(type_name); 14752 pieces.Add(type_name);
14800 pieces.Add(Symbols::SpaceExtendsSpace()); 14753 pieces.Add(Symbols::SpaceExtendsSpace());
14801 // Build the bound name without causing divergence. 14754 // Build the bound name without causing divergence.
14802 const AbstractType& bound = AbstractType::Handle( 14755 const AbstractType& bound = AbstractType::Handle(
14803 zone, BoundedType::Cast(*this).bound()); 14756 zone, BoundedType::Cast(*this).bound());
14804 String& bound_name = String::Handle(zone); 14757 String& bound_name = String::Handle(zone);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
14854 if (IsResolved() || !cls.IsMixinApplication()) { 14807 if (IsResolved() || !cls.IsMixinApplication()) {
14855 // Do not print the full vector, but only the declared type parameters. 14808 // Do not print the full vector, but only the declared type parameters.
14856 num_type_params = cls.NumTypeParameters(); 14809 num_type_params = cls.NumTypeParameters();
14857 } else { 14810 } else {
14858 // Do not print the type parameters of an unresolved mixin application, 14811 // Do not print the type parameters of an unresolved mixin application,
14859 // since it would prematurely trigger the application of the mixin type. 14812 // since it would prematurely trigger the application of the mixin type.
14860 num_type_params = 0; 14813 num_type_params = 0;
14861 } 14814 }
14862 if (name_visibility == kInternalName) { 14815 if (name_visibility == kInternalName) {
14863 class_name = cls.Name(); 14816 class_name = cls.Name();
14864 } else if (name_visibility == kPrettyName) {
14865 class_name = cls.PrettyName();
14866 } else { 14817 } else {
14867 ASSERT(name_visibility == kUserVisibleName); 14818 ASSERT(name_visibility == kUserVisibleName);
14868 // Map internal types to their corresponding public interfaces. 14819 // Map internal types to their corresponding public interfaces.
14869 class_name = cls.UserVisibleName(); 14820 class_name = cls.UserVisibleName();
14870 } 14821 }
14871 if (num_type_params > num_args) { 14822 if (num_type_params > num_args) {
14872 first_type_param_index = 0; 14823 first_type_param_index = 0;
14873 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { 14824 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) {
14874 // Most probably a malformed type. Do not fill up with "dynamic", 14825 // Most probably a malformed type. Do not fill up with "dynamic",
14875 // but use actual vector. 14826 // but use actual vector.
(...skipping 6595 matching lines...) Expand 10 before | Expand all | Expand 10 after
21471 return UserTag::null(); 21422 return UserTag::null();
21472 } 21423 }
21473 21424
21474 21425
21475 const char* UserTag::ToCString() const { 21426 const char* UserTag::ToCString() const {
21476 const String& tag_label = String::Handle(label()); 21427 const String& tag_label = String::Handle(label());
21477 return tag_label.ToCString(); 21428 return tag_label.ToCString();
21478 } 21429 }
21479 21430
21480 } // namespace dart 21431 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698