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

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

Issue 11418115: Fix Unicode issues in dart2js and dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 8
9 part 'constant_map.dart'; 9 part 'constant_map.dart';
10 part 'native_helper.dart'; 10 part 'native_helper.dart';
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if ((length is !int) || (length < 0)) { 528 if ((length is !int) || (length < 0)) {
529 throw new ArgumentError(length); 529 throw new ArgumentError(length);
530 } 530 }
531 var result = JS('=List', r'new Array(#)', length); 531 var result = JS('=List', r'new Array(#)', length);
532 JS('void', r'#.fixed$length = #', result, true); 532 JS('void', r'#.fixed$length = #', result, true);
533 return result; 533 return result;
534 } 534 }
535 535
536 static num dateNow() => JS('num', r'Date.now()'); 536 static num dateNow() => JS('num', r'Date.now()');
537 537
538 static stringFromCodePoints(codePoints) {
539 List<int> a = <int>[];
540 for (var i in codePoints) {
541 if (i is !int) throw new ArgumentError(i);
542 if (i <= 0xffff) {
543 JS('void', r'#.push(#)', a, i);
floitsch 2012/11/21 16:16:50 a.add(i) should be fine. We know the type of the a
erikcorry 2012/11/22 12:42:15 It's not fine, but i changed it back to just use a
544 } else if (i <= 0x10ffff) {
545 JS('void', r'#.push(0xd800 + ((((#) >> 10) & 0x3ff)))', a, i - 0x10000);
546 JS('void', r'#.push(#)', a, 0xdc00 + (i & 0x3ff));
547 } else {
548 throw new ArgumentError(i);
549 }
550 }
551 return JS('String', r'String.fromCharCode.apply(#, #)', null, a);
552 }
553
538 static String stringFromCharCodes(charCodes) { 554 static String stringFromCharCodes(charCodes) {
539 for (var i in charCodes) { 555 for (var i in charCodes) {
540 if (i is !int) throw new ArgumentError(i); 556 if (i is !int) throw new ArgumentError(i);
557 if (i < 0) throw new ArgumentError(i);
558 if (i > 0xffff) return stringFromCodePoints(charCodes);
541 } 559 }
542 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes); 560 return JS('String', r'String.fromCharCode.apply(#, #)', null, charCodes);
543 } 561 }
544 562
545 static String getTimeZoneName(receiver) { 563 static String getTimeZoneName(receiver) {
546 // When calling toString on a Date it will emit the timezone in parenthesis. 564 // When calling toString on a Date it will emit the timezone in parenthesis.
547 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)". 565 // Example: "Wed May 16 2012 21:13:00 GMT+0200 (CEST)".
548 // We extract this name using a regexp. 566 // We extract this name using a regexp.
549 var d = lazyAsJsDate(receiver); 567 var d = lazyAsJsDate(receiver);
550 return JS('String', r'/\((.*)\)/.exec(#.toString())[1]', d); 568 return JS('String', r'/\((.*)\)/.exec(#.toString())[1]', d);
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 return typeName == other.typeName; 1554 return typeName == other.typeName;
1537 } 1555 }
1538 } 1556 }
1539 1557
1540 String getRuntimeTypeString(var object) { 1558 String getRuntimeTypeString(var object) {
1541 var typeInfo = JS('var', r'#.builtin$typeInfo', object); 1559 var typeInfo = JS('var', r'#.builtin$typeInfo', object);
1542 return JS('String', r'#.runtimeType', typeInfo); 1560 return JS('String', r'#.runtimeType', typeInfo);
1543 } 1561 }
1544 1562
1545 createRuntimeType(String name) => new TypeImpl(name); 1563 createRuntimeType(String name) => new TypeImpl(name);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698