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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 285543002: Recognize List constructor and turn it into CreateArray ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 36052)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -411,11 +411,12 @@
static bool CompareNames(const Library& lib,
const char* test_name,
const String& name) {
+ ASSERT(Library::kPrivateIdentifierStart == '_');
const char* kPrivateGetterPrefix = "get:_";
const char* kPrivateSetterPrefix = "set:_";
- if (test_name[0] == '_') {
- if (name.CharAt(0) != '_') {
+ if (test_name[0] == Library::kPrivateIdentifierStart) {
+ if (name.CharAt(0) != Library::kPrivateIdentifierStart) {
return false;
}
} else if (strncmp(test_name,
@@ -436,8 +437,18 @@
}
// 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);
+ // Check if this is a constructor (e.g., List,), in which case the mangler
+ // needs some help (see comment in Library::PrivateName).
+ String& test_name_symbol = String::Handle();
+ if (test_name[strlen(test_name) - 1] == '.') {
+ test_name_symbol = Symbols::New(test_name, strlen(test_name) - 1);
+ test_name_symbol = lib.PrivateName(test_name_symbol);
+ test_name_symbol = String::Concat(test_name_symbol, Symbols::Dot());
+ } else {
+ test_name_symbol = Symbols::New(test_name);
+ test_name_symbol = lib.PrivateName(test_name_symbol);
+ }
+ return test_name_symbol.Equals(name);
}

Powered by Google App Engine
This is Rietveld 408576698