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

Unified Diff: runtime/vm/intrinsifier.cc

Issue 11779018: Fix Intrinsifier and MethodRecognizer to correctly match private getters and setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 side-by-side diff with in-line comments
Download patch
« runtime/vm/intermediate_language.cc ('K') | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier.cc
diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc
index 9e4188b4af83cd58d4da508bfa5010a2a4fbb3c6..fcb937885255c2c5641ed881dabb711ff52bbdc9 100644
--- a/runtime/vm/intrinsifier.cc
+++ b/runtime/vm/intrinsifier.cc
@@ -13,28 +13,44 @@ DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible");
static bool CompareNames(const char* test_name, const char* name) {
- if (strcmp(test_name, name) == 0) {
- return true;
- }
- if ((name[0] == '_') && (test_name[0] == '_')) {
- // Check if the private class is member of core or scalarlist and matches
- // the test_class_name.
- const Library& core_lib = Library::Handle(Library::CoreLibrary());
- const Library& scalarlist_lib =
- Library::Handle(Library::ScalarlistLibrary());
- String& test_str = String::Handle(String::New(test_name));
- String& test_str_with_key = String::Handle();
- test_str_with_key =
- String::Concat(test_str, String::Handle(core_lib.private_key()));
- if (strcmp(test_str_with_key.ToCString(), name) == 0) {
- return true;
+ static const intptr_t kPrefixLength = 5;
+ static const char* kGetterPrefix = "get:_";
+ static const char* kSetterPrefix = "set:_";
Florian Schneider 2013/01/07 13:15:48 I'd define those in one place and remove kPrefixLe
Vyacheslav Egorov (Google) 2013/01/07 15:02:47 I renamed & started to use strlen. I am however
+
+ if (test_name[0] == '_') {
+ if (name[0] != '_') {
+ return false;
}
- test_str_with_key =
- String::Concat(test_str, String::Handle(scalarlist_lib.private_key()));
- if (strcmp(test_str_with_key.ToCString(), name) == 0) {
- return true;
+ } else if (strncmp(test_name, kGetterPrefix, kPrefixLength) == 0) {
+ if (strncmp(name, kGetterPrefix, kPrefixLength) != 0) {
+ return false;
+ }
+ } else if (strncmp(test_name, kSetterPrefix, kPrefixLength) == 0) {
+ if (strncmp(name, kSetterPrefix, kPrefixLength) != 0) {
+ return false;
}
+ } else {
+ return (strcmp(test_name, name) == 0);
}
+
+ // Check if the private class is member of core or scalarlist and matches
+ // the test_class_name.
+ const Library& core_lib = Library::Handle(Library::CoreLibrary());
+ const Library& scalarlist_lib =
+ Library::Handle(Library::ScalarlistLibrary());
+ String& test_str = String::Handle(String::New(test_name));
+ String& test_str_with_key = String::Handle();
+ test_str_with_key =
+ String::Concat(test_str, String::Handle(core_lib.private_key()));
+ if (strcmp(test_str_with_key.ToCString(), name) == 0) {
+ return true;
+ }
+ test_str_with_key =
+ String::Concat(test_str, String::Handle(scalarlist_lib.private_key()));
+ if (strcmp(test_str_with_key.ToCString(), name) == 0) {
+ return true;
+ }
+
return false;
}
« runtime/vm/intermediate_language.cc ('K') | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698