| OLD | NEW |
| 1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
| 2 // ********** Library dart:core ************** | 2 // ********** Library dart:core ************** |
| 3 // ********** Natives dart:core ************** | 3 // ********** Natives dart:core ************** |
| 4 /** | 4 /** |
| 5 * Generates a dynamic call stub for a function. | 5 * Generates a dynamic call stub for a function. |
| 6 * Our goal is to create a stub method like this on-the-fly: | 6 * Our goal is to create a stub method like this on-the-fly: |
| 7 * function($0, $1, capture) { this($0, $1, true, capture); } | 7 * function($0, $1, capture) { this($0, $1, true, capture); } |
| 8 * | 8 * |
| 9 * This stub then replaces the dynamic one on Function, with one that is | 9 * This stub then replaces the dynamic one on Function, with one that is |
| 10 * specialized for that particular function, taking into account its default | 10 * specialized for that particular function, taking into account its default |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 return ret; | 134 return ret; |
| 135 } | 135 } |
| 136 Object.prototype.$index = function(i) { return this[i]; } | 136 Object.prototype.$index = function(i) { return this[i]; } |
| 137 Array.prototype.$index = function(i) { return this[i]; } | 137 Array.prototype.$index = function(i) { return this[i]; } |
| 138 String.prototype.$index = function(i) { return this[i]; } | 138 String.prototype.$index = function(i) { return this[i]; } |
| 139 Object.prototype.$setindex = function(i, value) { return this[i] = value; } | 139 Object.prototype.$setindex = function(i, value) { return this[i] = value; } |
| 140 Array.prototype.$setindex = function(i, value) { return this[i] = value; } | 140 Array.prototype.$setindex = function(i, value) { return this[i] = value; } |
| 141 function $add(x, y) { | 141 function $add(x, y) { |
| 142 return ((typeof(x) == 'number' && typeof(y) == 'number') || | 142 return ((typeof(x) == 'number' && typeof(y) == 'number') || |
| 143 (typeof(x) == 'string' && typeof(y) == 'string')) | 143 (typeof(x) == 'string')) |
| 144 ? x + y : x.$add(y); | 144 ? x + y : x.$add(y); |
| 145 } | 145 } |
| 146 function $eq(x, y) { | 146 function $eq(x, y) { |
| 147 if (x == null) return y == null; | 147 if (x == null) return y == null; |
| 148 return (typeof(x) == 'number' && typeof(y) == 'number') || | 148 return (typeof(x) == 'number' && typeof(y) == 'number') || |
| 149 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || | 149 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || |
| 150 (typeof(x) == 'string' && typeof(y) == 'string') | 150 (typeof(x) == 'string' && typeof(y) == 'string') |
| 151 ? x == y : x.$eq(y); | 151 ? x == y : x.$eq(y); |
| 152 } | 152 } |
| 153 // TODO(jimhug): Should this or should it not match equals? | 153 // TODO(jimhug): Should this or should it not match equals? |
| (...skipping 12048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12202 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x.
$bit_not();\n}"; | 12202 code = "function $bit_not(x) {\n return (typeof(x) == 'number') ? ~x : x.
$bit_not();\n}"; |
| 12203 break; | 12203 break; |
| 12204 | 12204 |
| 12205 case '\$negate': | 12205 case '\$negate': |
| 12206 | 12206 |
| 12207 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$
negate();\n}"; | 12207 code = "function $negate(x) {\n return (typeof(x) == 'number') ? -x : x.$
negate();\n}"; |
| 12208 break; | 12208 break; |
| 12209 | 12209 |
| 12210 case '\$add': | 12210 case '\$add': |
| 12211 | 12211 |
| 12212 code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof(
y) == 'number') ||\n (typeof(x) == 'string' && typeof(y) == 'string'))\
n ? x + y : x.$add(y);\n}"; | 12212 code = "function $add(x, y) {\n return ((typeof(x) == 'number' && typeof(
y) == 'number') ||\n (typeof(x) == 'string'))\n ? x + y : x.$add(y);
\n}"; |
| 12213 break; | 12213 break; |
| 12214 | 12214 |
| 12215 case '\$truncdiv': | 12215 case '\$truncdiv': |
| 12216 | 12216 |
| 12217 this.useThrow = true; | 12217 this.useThrow = true; |
| 12218 code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number' && typeof(
y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroException());
\n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp);
\n } else {\n return x.$truncdiv(y);\n }\n}"; | 12218 code = "function $truncdiv(x, y) {\n if (typeof(x) == 'number' && typeof(
y) == 'number') {\n if (y == 0) $throw(new IntegerDivisionByZeroException());
\n var tmp = x / y;\n return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp);
\n } else {\n return x.$truncdiv(y);\n }\n}"; |
| 12219 break; | 12219 break; |
| 12220 | 12220 |
| 12221 case '\$mod': | 12221 case '\$mod': |
| 12222 | 12222 |
| (...skipping 11761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23984 NATIVE, | 23984 NATIVE, |
| 23985 NEGATE, | 23985 NEGATE, |
| 23986 OPERATOR, | 23986 OPERATOR, |
| 23987 SET, | 23987 SET, |
| 23988 SOURCE, | 23988 SOURCE, |
| 23989 STATIC, | 23989 STATIC, |
| 23990 TYPEDEF ]*/; | 23990 TYPEDEF ]*/; |
| 23991 var $globals = {}; | 23991 var $globals = {}; |
| 23992 $static_init(); | 23992 $static_init(); |
| 23993 main(); | 23993 main(); |
| OLD | NEW |