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

Unified Diff: runtime/vm/intermediate_language.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: Address Florian's comments 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
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 86240ec4255c2ebb9961f42f07cbe28a28da37c8..b69ff4469b96368a29d0a8029226e5635acc48f2 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -217,15 +217,53 @@ ConstantInstr* GraphEntryInstr::constant_null() {
}
+static bool StartsWith(const String& name, const char* prefix, intptr_t n) {
+ ASSERT(name.IsOneByteString());
+
+ if (name.Length() < n) {
+ return false;
+ }
+
+ for (intptr_t i = 0; i < n; i++) {
+ if (name.CharAt(i) != prefix[i]) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
static bool CompareNames(const Library& lib,
const char* test_name,
const String& name) {
- // If both names are private mangle test_name before comparison.
- if ((name.CharAt(0) == '_') && (test_name[0] == '_')) {
- const String& test_name_symbol = String::Handle(Symbols::New(test_name));
- return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name);
+ const char* kPrivateGetterPrefix = "get:_";
+ const char* kPrivateSetterPrefix = "set:_";
+
+ if (test_name[0] == '_') {
+ if (name.CharAt(0) != '_') {
+ return false;
+ }
+ } else if (strncmp(test_name,
+ kPrivateGetterPrefix,
+ strlen(kPrivateGetterPrefix)) == 0) {
+ if (!StartsWith(name, kPrivateGetterPrefix, strlen(kPrivateGetterPrefix))) {
+ return false;
+ }
+ } else if (strncmp(test_name,
+ kPrivateSetterPrefix,
+ strlen(kPrivateSetterPrefix)) == 0) {
+ if (!StartsWith(name, kPrivateSetterPrefix, strlen(kPrivateSetterPrefix))) {
+ return false;
+ }
+ } else {
+ // Compare without mangling.
+ return name.Equals(test_name);
}
- return name.Equals(test_name);
+
+ // Both names are private. Mangle test_name before comparison.
+ const String& test_name_symbol = String::Handle(Symbols::New(test_name));
+ return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name);
}
@@ -236,6 +274,7 @@ static bool IsRecognizedLibrary(const Library& library) {
|| (library.raw() == Library::ScalarlistLibrary());
}
+
MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
const Function& function) {
const Class& function_class = Class::Handle(function.Owner());
« no previous file with comments | « no previous file | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698