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

Unified Diff: frog/corejs.dart

Issue 8763001: Fix names with '$' to not conflict with operators or internal helpers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged again Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/html/scripts/html-diff.dart ('k') | frog/element.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/corejs.dart
diff --git a/frog/corejs.dart b/frog/corejs.dart
index fd5432d220f8ba0aa9cd6104582890861779e8d1..cffc80f4793ee55586075a25680f3cc16e5b42fb 100644
--- a/frog/corejs.dart
+++ b/frog/corejs.dart
@@ -50,7 +50,7 @@ class CoreJs {
var code;
switch (name) {
- case '\$ne':
+ case ':ne':
code = @"""
function $ne(x, y) {
if (x == null) return y != null;
@@ -61,7 +61,7 @@ function $ne(x, y) {
}""";
break;
- case '\$eq':
+ case ':eq':
code = @"""
function $eq(x, y) {
if (x == null) return y == null;
@@ -74,14 +74,14 @@ function $eq(x, y) {
Object.prototype.$eq = function(other) { return this === other; }""";
break;
- case '\$bit_not':
+ case ':bit_not':
code = @"""
function $bit_not(x) {
return (typeof(x) == 'number') ? ~x : x.$bit_not();
}""";
break;
- case '\$negate':
+ case ':negate':
code = @"""
function $negate(x) {
return (typeof(x) == 'number') ? -x : x.$negate();
@@ -89,7 +89,7 @@ function $negate(x) {
break;
// This relies on JS's string "+" to match Dart's.
- case '\$add':
+ case ':add':
code = @"""
function $add(x, y) {
return ((typeof(x) == 'number' && typeof(y) == 'number') ||
@@ -98,7 +98,7 @@ function $add(x, y) {
}""";
break;
- case '\$truncdiv':
+ case ':truncdiv':
useThrow = true;
code = @"""
function $truncdiv(x, y) {
@@ -112,7 +112,7 @@ function $truncdiv(x, y) {
}""";
break;
- case '\$mod':
+ case ':mod':
code = @"""
function $mod(x, y) {
if (typeof(x) == 'number' && typeof(y) == 'number') {
@@ -136,10 +136,11 @@ function $mod(x, y) {
default:
// All of the other helpers are generated the same way
var op = TokenKind.rawOperatorFromMethod(name);
+ var jsname = world.toJsIdentifier(name);
code = """
-function ${name}(x, y) {
+function $jsname(x, y) {
return (typeof(x) == 'number' && typeof(y) == 'number')
- ? x ${op} y : x.${name}(y);
+ ? x $op y : x.$jsname(y);
}""";
break;
}
« no previous file with comments | « client/html/scripts/html-diff.dart ('k') | frog/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698