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

Side by Side Diff: frog/corejs.dart

Issue 8677018: add with strings bug fix (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 | « no previous file | frog/frogsh » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Generates JS helpers for dart:core. This used to be in a file "core.js". 6 * Generates JS helpers for dart:core. This used to be in a file "core.js".
7 * Having them in Dart code means we can easily control which are generated. 7 * Having them in Dart code means we can easily control which are generated.
8 */ 8 */
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native"
10 // methods somewhere in a library that we import. This would be rather elegant 10 // methods somewhere in a library that we import. This would be rather elegant
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 }"""; 76 }""";
77 break; 77 break;
78 78
79 case '\$negate': 79 case '\$negate':
80 code = @""" 80 code = @"""
81 function $negate(x) { 81 function $negate(x) {
82 return (typeof(x) == 'number') ? -x : x.$negate(); 82 return (typeof(x) == 'number') ? -x : x.$negate();
83 }"""; 83 }""";
84 break; 84 break;
85 85
86 // This relies on JS's string "+" to match Dart's.
86 case '\$add': 87 case '\$add':
87 code = @""" 88 code = @"""
88 function $add(x, y) { 89 function $add(x, y) {
89 return ((typeof(x) == 'number' && typeof(y) == 'number') || 90 return ((typeof(x) == 'number' && typeof(y) == 'number') ||
90 (typeof(x) == 'string' && typeof(y) == 'string')) 91 (typeof(x) == 'string'))
91 ? x + y : x.$add(y); 92 ? x + y : x.$add(y);
92 }"""; 93 }""";
93 break; 94 break;
94 95
95 case '\$truncdiv': 96 case '\$truncdiv':
96 useThrow = true; 97 useThrow = true;
97 code = @""" 98 code = @"""
98 function $truncdiv(x, y) { 99 function $truncdiv(x, y) {
99 if (typeof(x) == 'number' && typeof(y) == 'number') { 100 if (typeof(x) == 'number' && typeof(y) == 'number') {
100 if (y == 0) $throw(new IntegerDivisionByZeroException()); 101 if (y == 0) $throw(new IntegerDivisionByZeroException());
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 w.writeln(@"function $wrap_call$1(fn) { return fn; }"); 435 w.writeln(@"function $wrap_call$1(fn) { return fn; }");
435 } 436 }
436 } 437 }
437 438
438 // Write operator helpers 439 // Write operator helpers
439 for (var opImpl in orderValuesByKeys(_usedOperators)) { 440 for (var opImpl in orderValuesByKeys(_usedOperators)) {
440 w.writeln(opImpl); 441 w.writeln(opImpl);
441 } 442 }
442 } 443 }
443 } 444 }
OLDNEW
« no previous file with comments | « no previous file | frog/frogsh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698