| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "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 5484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5495 return true; | 5495 return true; |
| 5496 } | 5496 } |
| 5497 | 5497 |
| 5498 | 5498 |
| 5499 // Helper allocating a C string buffer in the zone, printing the fully qualified | 5499 // Helper allocating a C string buffer in the zone, printing the fully qualified |
| 5500 // name of a function in it, and replacing ':' by '_' to make sure the | 5500 // name of a function in it, and replacing ':' by '_' to make sure the |
| 5501 // constructed name is a valid C++ identifier for debugging purpose. | 5501 // constructed name is a valid C++ identifier for debugging purpose. |
| 5502 // Set 'chars' to allocated buffer and return number of written characters. | 5502 // Set 'chars' to allocated buffer and return number of written characters. |
| 5503 static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, | 5503 static intptr_t ConstructFunctionFullyQualifiedCString(const Function& function, |
| 5504 char** chars, | 5504 char** chars, |
| 5505 intptr_t reserve_len) { | 5505 intptr_t reserve_len, |
| 5506 bool with_lib) { |
| 5506 const char* name = String::Handle(function.name()).ToCString(); | 5507 const char* name = String::Handle(function.name()).ToCString(); |
| 5507 const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; | 5508 const char* function_format = (reserve_len == 0) ? "%s" : "%s_"; |
| 5508 reserve_len += OS::SNPrint(NULL, 0, function_format, name); | 5509 reserve_len += OS::SNPrint(NULL, 0, function_format, name); |
| 5509 const Function& parent = Function::Handle(function.parent_function()); | 5510 const Function& parent = Function::Handle(function.parent_function()); |
| 5510 intptr_t written = 0; | 5511 intptr_t written = 0; |
| 5511 if (parent.IsNull()) { | 5512 if (parent.IsNull()) { |
| 5512 const Class& function_class = Class::Handle(function.Owner()); | 5513 const Class& function_class = Class::Handle(function.Owner()); |
| 5513 ASSERT(!function_class.IsNull()); | 5514 ASSERT(!function_class.IsNull()); |
| 5514 const char* class_name = String::Handle(function_class.Name()).ToCString(); | 5515 const char* class_name = String::Handle(function_class.Name()).ToCString(); |
| 5515 ASSERT(class_name != NULL); | 5516 ASSERT(class_name != NULL); |
| 5516 const Library& library = Library::Handle(function_class.library()); | 5517 const Library& library = Library::Handle(function_class.library()); |
| 5517 ASSERT(!library.IsNull()); | 5518 ASSERT(!library.IsNull()); |
| 5518 const char* library_name = String::Handle(library.url()).ToCString(); | 5519 const char* library_name = NULL; |
| 5519 ASSERT(library_name != NULL); | 5520 const char* lib_class_format = NULL; |
| 5520 const char* lib_class_format = | 5521 if (with_lib) { |
| 5521 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; | 5522 library_name = String::Handle(library.url()).ToCString(); |
| 5523 ASSERT(library_name != NULL); |
| 5524 lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; |
| 5525 } else { |
| 5526 library_name = ""; |
| 5527 lib_class_format = "%s%s."; |
| 5528 } |
| 5522 reserve_len += | 5529 reserve_len += |
| 5523 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); | 5530 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); |
| 5524 ASSERT(chars != NULL); | 5531 ASSERT(chars != NULL); |
| 5525 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); | 5532 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); |
| 5526 written = OS::SNPrint( | 5533 written = OS::SNPrint( |
| 5527 *chars, reserve_len + 1, lib_class_format, library_name, class_name); | 5534 *chars, reserve_len + 1, lib_class_format, library_name, class_name); |
| 5528 } else { | 5535 } else { |
| 5529 written = ConstructFunctionFullyQualifiedCString(parent, | 5536 written = ConstructFunctionFullyQualifiedCString(parent, |
| 5530 chars, | 5537 chars, |
| 5531 reserve_len); | 5538 reserve_len, |
| 5539 with_lib); |
| 5532 } | 5540 } |
| 5533 ASSERT(*chars != NULL); | 5541 ASSERT(*chars != NULL); |
| 5534 char* next = *chars + written; | 5542 char* next = *chars + written; |
| 5535 written += OS::SNPrint(next, reserve_len + 1, function_format, name); | 5543 written += OS::SNPrint(next, reserve_len + 1, function_format, name); |
| 5536 // Replace ":" with "_". | 5544 // Replace ":" with "_". |
| 5537 while (true) { | 5545 while (true) { |
| 5538 next = strchr(next, ':'); | 5546 next = strchr(next, ':'); |
| 5539 if (next == NULL) break; | 5547 if (next == NULL) break; |
| 5540 *next = '_'; | 5548 *next = '_'; |
| 5541 } | 5549 } |
| 5542 return written; | 5550 return written; |
| 5543 } | 5551 } |
| 5544 | 5552 |
| 5545 | 5553 |
| 5546 const char* Function::ToFullyQualifiedCString() const { | 5554 const char* Function::ToFullyQualifiedCString() const { |
| 5547 char* chars = NULL; | 5555 char* chars = NULL; |
| 5548 ConstructFunctionFullyQualifiedCString(*this, &chars, 0); | 5556 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, true); |
| 5557 return chars; |
| 5558 } |
| 5559 |
| 5560 |
| 5561 const char* Function::ToQualifiedCString() const { |
| 5562 char* chars = NULL; |
| 5563 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false); |
| 5549 return chars; | 5564 return chars; |
| 5550 } | 5565 } |
| 5551 | 5566 |
| 5552 | 5567 |
| 5553 bool Function::HasCompatibleParametersWith(const Function& other, | 5568 bool Function::HasCompatibleParametersWith(const Function& other, |
| 5554 Error* bound_error) const { | 5569 Error* bound_error) const { |
| 5555 ASSERT(FLAG_error_on_bad_override); | 5570 ASSERT(FLAG_error_on_bad_override); |
| 5556 ASSERT((bound_error != NULL) && bound_error->IsNull()); | 5571 ASSERT((bound_error != NULL) && bound_error->IsNull()); |
| 5557 // Check that this function's signature type is a subtype of the other | 5572 // Check that this function's signature type is a subtype of the other |
| 5558 // function's signature type. | 5573 // function's signature type. |
| (...skipping 12396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17955 return "_MirrorReference"; | 17970 return "_MirrorReference"; |
| 17956 } | 17971 } |
| 17957 | 17972 |
| 17958 | 17973 |
| 17959 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17974 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17960 Instance::PrintToJSONStream(stream, ref); | 17975 Instance::PrintToJSONStream(stream, ref); |
| 17961 } | 17976 } |
| 17962 | 17977 |
| 17963 | 17978 |
| 17964 } // namespace dart | 17979 } // namespace dart |
| OLD | NEW |