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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/js_helper.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
OLDNEW
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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS,
9 JS, 9 JS,
10 JS_CALL_IN_ISOLATE, 10 JS_CALL_IN_ISOLATE,
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if (namedArguments != null && !namedArguments.isEmpty) { 508 if (namedArguments != null && !namedArguments.isEmpty) {
509 // Call new List.from to make sure we get a JavaScript array. 509 // Call new List.from to make sure we get a JavaScript array.
510 List<String> listOfNamedArguments = 510 List<String> listOfNamedArguments =
511 new List<String>.from(namedArguments.keys); 511 new List<String>.from(namedArguments.keys);
512 argumentCount += namedArguments.length; 512 argumentCount += namedArguments.length;
513 // We're sorting on strings, and the behavior is the same between 513 // We're sorting on strings, and the behavior is the same between
514 // Dart string sort and JS string sort. To avoid needing the Dart 514 // Dart string sort and JS string sort. To avoid needing the Dart
515 // sort implementation, we use the JavaScript one instead. 515 // sort implementation, we use the JavaScript one instead.
516 JS('void', '#.sort()', listOfNamedArguments); 516 JS('void', '#.sort()', listOfNamedArguments);
517 listOfNamedArguments.forEach((String name) { 517 listOfNamedArguments.forEach((String name) {
518 buffer.add('\$$name'); 518 buffer.write('\$$name');
519 arguments.add(namedArguments[name]); 519 arguments.add(namedArguments[name]);
520 }); 520 });
521 } 521 }
522 522
523 String selectorName = 'call\$$argumentCount$buffer'; 523 String selectorName = 'call\$$argumentCount$buffer';
524 var jsFunction = JS('var', '#[#]', function, selectorName); 524 var jsFunction = JS('var', '#[#]', function, selectorName);
525 if (jsFunction == null) { 525 if (jsFunction == null) {
526 throw new NoSuchMethodError(function, selectorName, arguments, {}); 526 throw new NoSuchMethodError(function, selectorName, arguments, {});
527 } 527 }
528 // We bound 'this' to [function] because of how we compile 528 // We bound 'this' to [function] because of how we compile
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 } 1448 }
1449 } 1449 }
1450 1450
1451 String joinArguments(var types, int startIndex) { 1451 String joinArguments(var types, int startIndex) {
1452 bool firstArgument = true; 1452 bool firstArgument = true;
1453 StringBuffer buffer = new StringBuffer(); 1453 StringBuffer buffer = new StringBuffer();
1454 for (int index = startIndex; index < types.length; index++) { 1454 for (int index = startIndex; index < types.length; index++) {
1455 if (firstArgument) { 1455 if (firstArgument) {
1456 firstArgument = false; 1456 firstArgument = false;
1457 } else { 1457 } else {
1458 buffer. add(', '); 1458 buffer.write(', ');
1459 } 1459 }
1460 var argument = types[index]; 1460 var argument = types[index];
1461 buffer.add(runtimeTypeToString(argument)); 1461 buffer.write(runtimeTypeToString(argument));
1462 } 1462 }
1463 return buffer.toString(); 1463 return buffer.toString();
1464 } 1464 }
1465 1465
1466 String getRuntimeTypeString(var object) { 1466 String getRuntimeTypeString(var object) {
1467 String className = isJsArray(object) ? 'List' : getClassName(object); 1467 String className = isJsArray(object) ? 'List' : getClassName(object);
1468 var typeInfo = JS('var', r'#.$builtinTypeInfo', object); 1468 var typeInfo = JS('var', r'#.$builtinTypeInfo', object);
1469 if (typeInfo == null) return className; 1469 if (typeInfo == null) return className;
1470 return "$className<${joinArguments(typeInfo, 0)}>"; 1470 return "$className<${joinArguments(typeInfo, 0)}>";
1471 } 1471 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 // of [t]. 1590 // of [t].
1591 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) || 1591 if ((!isJsArray(s) && JS('bool', '# == null', substitution)) ||
1592 !isJsArray(t)) { 1592 !isJsArray(t)) {
1593 return true; 1593 return true;
1594 } 1594 }
1595 // Recursively check the type arguments. 1595 // Recursively check the type arguments.
1596 return checkArguments(substitution, getArguments(s), getArguments(t)); 1596 return checkArguments(substitution, getArguments(s), getArguments(t));
1597 } 1597 }
1598 1598
1599 createRuntimeType(String name) => new TypeImpl(name); 1599 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698