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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 404 }
405 } 405 }
406 406
407 return true; 407 return true;
408 } 408 }
409 409
410 410
411 static bool CompareNames(const Library& lib, 411 static bool CompareNames(const Library& lib,
412 const char* test_name, 412 const char* test_name,
413 const String& name) { 413 const String& name) {
414 ASSERT(Library::kPrivateIdentifierStart == '_');
414 const char* kPrivateGetterPrefix = "get:_"; 415 const char* kPrivateGetterPrefix = "get:_";
415 const char* kPrivateSetterPrefix = "set:_"; 416 const char* kPrivateSetterPrefix = "set:_";
416 417
417 if (test_name[0] == '_') { 418 if (test_name[0] == Library::kPrivateIdentifierStart) {
418 if (name.CharAt(0) != '_') { 419 if (name.CharAt(0) != Library::kPrivateIdentifierStart) {
419 return false; 420 return false;
420 } 421 }
421 } else if (strncmp(test_name, 422 } else if (strncmp(test_name,
422 kPrivateGetterPrefix, 423 kPrivateGetterPrefix,
423 strlen(kPrivateGetterPrefix)) == 0) { 424 strlen(kPrivateGetterPrefix)) == 0) {
424 if (!StartsWith(name, kPrivateGetterPrefix, strlen(kPrivateGetterPrefix))) { 425 if (!StartsWith(name, kPrivateGetterPrefix, strlen(kPrivateGetterPrefix))) {
425 return false; 426 return false;
426 } 427 }
427 } else if (strncmp(test_name, 428 } else if (strncmp(test_name,
428 kPrivateSetterPrefix, 429 kPrivateSetterPrefix,
429 strlen(kPrivateSetterPrefix)) == 0) { 430 strlen(kPrivateSetterPrefix)) == 0) {
430 if (!StartsWith(name, kPrivateSetterPrefix, strlen(kPrivateSetterPrefix))) { 431 if (!StartsWith(name, kPrivateSetterPrefix, strlen(kPrivateSetterPrefix))) {
431 return false; 432 return false;
432 } 433 }
433 } else { 434 } else {
434 // Compare without mangling. 435 // Compare without mangling.
435 return name.Equals(test_name); 436 return name.Equals(test_name);
436 } 437 }
437 438
438 // Both names are private. Mangle test_name before comparison. 439 // Both names are private. Mangle test_name before comparison.
439 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); 440 // Check if this is a constructor (e.g., List,), in which case the mangler
440 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); 441 // needs some help (see comment in Library::PrivateName).
442 String& test_name_symbol = String::Handle();
443 if (test_name[strlen(test_name) - 1] == '.') {
444 test_name_symbol = Symbols::New(test_name, strlen(test_name) - 1);
445 test_name_symbol = lib.PrivateName(test_name_symbol);
446 test_name_symbol = String::Concat(test_name_symbol, Symbols::Dot());
447 } else {
448 test_name_symbol = Symbols::New(test_name);
449 test_name_symbol = lib.PrivateName(test_name_symbol);
450 }
451 return test_name_symbol.Equals(name);
441 } 452 }
442 453
443 454
444 static bool IsRecognizedLibrary(const Library& library) { 455 static bool IsRecognizedLibrary(const Library& library) {
445 // List of libraries where methods can be recognized. 456 // List of libraries where methods can be recognized.
446 return (library.raw() == Library::CoreLibrary()) 457 return (library.raw() == Library::CoreLibrary())
447 || (library.raw() == Library::MathLibrary()) 458 || (library.raw() == Library::MathLibrary())
448 || (library.raw() == Library::TypedDataLibrary()) 459 || (library.raw() == Library::TypedDataLibrary())
449 || (library.raw() == Library::InternalLibrary()); 460 || (library.raw() == Library::InternalLibrary());
450 } 461 }
(...skipping 2962 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 case Token::kTRUNCDIV: return 0; 3424 case Token::kTRUNCDIV: return 0;
3414 case Token::kMOD: return 1; 3425 case Token::kMOD: return 1;
3415 default: UNIMPLEMENTED(); return -1; 3426 default: UNIMPLEMENTED(); return -1;
3416 } 3427 }
3417 } 3428 }
3418 3429
3419 3430
3420 #undef __ 3431 #undef __
3421 3432
3422 } // namespace dart 3433 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698