| OLD | NEW |
| 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('coreimpl.dart'); | 7 #import('coreimpl.dart'); |
| 8 | 8 |
| 9 #source('constant_map.dart'); | 9 #source('constant_map.dart'); |
| 10 #source('date_helper.dart'); | 10 #source('date_helper.dart'); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (checkNumbers(a, b)) { | 39 if (checkNumbers(a, b)) { |
| 40 return JS('num', @'# + #', a, b); | 40 return JS('num', @'# + #', a, b); |
| 41 } else if (a is String) { | 41 } else if (a is String) { |
| 42 b = b.toString(); | 42 b = b.toString(); |
| 43 if (b is String) { | 43 if (b is String) { |
| 44 return JS('String', @'# + #', a, b); | 44 return JS('String', @'# + #', a, b); |
| 45 } | 45 } |
| 46 checkNull(b); | 46 checkNull(b); |
| 47 throw new IllegalArgumentException(b); | 47 throw new IllegalArgumentException(b); |
| 48 } | 48 } |
| 49 checkNull(a); | |
| 50 return UNINTERCEPTED(a + b); | 49 return UNINTERCEPTED(a + b); |
| 51 } | 50 } |
| 52 | 51 |
| 53 div(var a, var b) { | 52 div(var a, var b) { |
| 54 if (checkNumbers(a, b)) { | 53 if (checkNumbers(a, b)) { |
| 55 return JS('num', @'# / #', a, b); | 54 return JS('num', @'# / #', a, b); |
| 56 } | 55 } |
| 57 checkNull(a); | |
| 58 return UNINTERCEPTED(a / b); | 56 return UNINTERCEPTED(a / b); |
| 59 } | 57 } |
| 60 | 58 |
| 61 mul(var a, var b) { | 59 mul(var a, var b) { |
| 62 if (checkNumbers(a, b)) { | 60 if (checkNumbers(a, b)) { |
| 63 return JS('num', @'# * #', a, b); | 61 return JS('num', @'# * #', a, b); |
| 64 } | 62 } |
| 65 checkNull(a); | |
| 66 return UNINTERCEPTED(a * b); | 63 return UNINTERCEPTED(a * b); |
| 67 } | 64 } |
| 68 | 65 |
| 69 sub(var a, var b) { | 66 sub(var a, var b) { |
| 70 if (checkNumbers(a, b)) { | 67 if (checkNumbers(a, b)) { |
| 71 return JS('num', @'# - #', a, b); | 68 return JS('num', @'# - #', a, b); |
| 72 } | 69 } |
| 73 checkNull(a); | |
| 74 return UNINTERCEPTED(a - b); | 70 return UNINTERCEPTED(a - b); |
| 75 } | 71 } |
| 76 | 72 |
| 77 mod(var a, var b) { | 73 mod(var a, var b) { |
| 78 if (checkNumbers(a, b)) { | 74 if (checkNumbers(a, b)) { |
| 79 // Euclidean Modulo. | 75 // Euclidean Modulo. |
| 80 int result = JS('num', @'# % #', a, b); | 76 int result = JS('num', @'# % #', a, b); |
| 81 if (result == 0) return 0; // Make sure we don't return -0.0. | 77 if (result == 0) return 0; // Make sure we don't return -0.0. |
| 82 if (result > 0) return result; | 78 if (result > 0) return result; |
| 83 if (b < 0) { | 79 if (b < 0) { |
| 84 return result - b; | 80 return result - b; |
| 85 } else { | 81 } else { |
| 86 return result + b; | 82 return result + b; |
| 87 } | 83 } |
| 88 } | 84 } |
| 89 checkNull(a); | |
| 90 return UNINTERCEPTED(a % b); | 85 return UNINTERCEPTED(a % b); |
| 91 } | 86 } |
| 92 | 87 |
| 93 tdiv(var a, var b) { | 88 tdiv(var a, var b) { |
| 94 if (checkNumbers(a, b)) { | 89 if (checkNumbers(a, b)) { |
| 95 return (a / b).truncate(); | 90 return (a / b).truncate(); |
| 96 } | 91 } |
| 97 checkNull(a); | |
| 98 return UNINTERCEPTED(a ~/ b); | 92 return UNINTERCEPTED(a ~/ b); |
| 99 } | 93 } |
| 100 | 94 |
| 101 eq(var a, var b) { | 95 eq(var a, var b) { |
| 102 if (JS('bool', @'typeof # === "object"', a)) { | 96 if (JS('bool', @'typeof # === "object"', a)) { |
| 103 if (JS_HAS_EQUALS(a)) { | 97 if (JS_HAS_EQUALS(a)) { |
| 104 return UNINTERCEPTED(a == b) === true; | 98 return UNINTERCEPTED(a == b) === true; |
| 105 } else { | 99 } else { |
| 106 return JS('bool', @'# === #', a, b); | 100 return JS('bool', @'# === #', a, b); |
| 107 } | 101 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 123 } | 117 } |
| 124 } else { | 118 } else { |
| 125 return JS('bool', @'typeof # === "undefined"', a); | 119 return JS('bool', @'typeof # === "undefined"', a); |
| 126 } | 120 } |
| 127 } | 121 } |
| 128 | 122 |
| 129 gt(var a, var b) { | 123 gt(var a, var b) { |
| 130 if (checkNumbers(a, b)) { | 124 if (checkNumbers(a, b)) { |
| 131 return JS('bool', @'# > #', a, b); | 125 return JS('bool', @'# > #', a, b); |
| 132 } | 126 } |
| 133 checkNull(a); | |
| 134 return UNINTERCEPTED(a > b); | 127 return UNINTERCEPTED(a > b); |
| 135 } | 128 } |
| 136 | 129 |
| 137 ge(var a, var b) { | 130 ge(var a, var b) { |
| 138 if (checkNumbers(a, b)) { | 131 if (checkNumbers(a, b)) { |
| 139 return JS('bool', @'# >= #', a, b); | 132 return JS('bool', @'# >= #', a, b); |
| 140 } | 133 } |
| 141 checkNull(a); | |
| 142 return UNINTERCEPTED(a >= b); | 134 return UNINTERCEPTED(a >= b); |
| 143 } | 135 } |
| 144 | 136 |
| 145 lt(var a, var b) { | 137 lt(var a, var b) { |
| 146 if (checkNumbers(a, b)) { | 138 if (checkNumbers(a, b)) { |
| 147 return JS('bool', @'# < #', a, b); | 139 return JS('bool', @'# < #', a, b); |
| 148 } | 140 } |
| 149 checkNull(a); | |
| 150 return UNINTERCEPTED(a < b); | 141 return UNINTERCEPTED(a < b); |
| 151 } | 142 } |
| 152 | 143 |
| 153 le(var a, var b) { | 144 le(var a, var b) { |
| 154 if (checkNumbers(a, b)) { | 145 if (checkNumbers(a, b)) { |
| 155 return JS('bool', @'# <= #', a, b); | 146 return JS('bool', @'# <= #', a, b); |
| 156 } | 147 } |
| 157 checkNull(a); | |
| 158 return UNINTERCEPTED(a <= b); | 148 return UNINTERCEPTED(a <= b); |
| 159 } | 149 } |
| 160 | 150 |
| 161 shl(var a, var b) { | 151 shl(var a, var b) { |
| 162 // TODO(floitsch): inputs must be integers. | 152 // TODO(floitsch): inputs must be integers. |
| 163 if (checkNumbers(a, b)) { | 153 if (checkNumbers(a, b)) { |
| 164 if (b < 0) throw new IllegalArgumentException(b); | 154 if (b < 0) throw new IllegalArgumentException(b); |
| 165 return JS('num', @'# << #', a, b); | 155 return JS('num', @'# << #', a, b); |
| 166 } | 156 } |
| 167 checkNull(a); | |
| 168 return UNINTERCEPTED(a << b); | 157 return UNINTERCEPTED(a << b); |
| 169 } | 158 } |
| 170 | 159 |
| 171 shr(var a, var b) { | 160 shr(var a, var b) { |
| 172 // TODO(floitsch): inputs must be integers. | 161 // TODO(floitsch): inputs must be integers. |
| 173 if (checkNumbers(a, b)) { | 162 if (checkNumbers(a, b)) { |
| 174 if (b < 0) throw new IllegalArgumentException(b); | 163 if (b < 0) throw new IllegalArgumentException(b); |
| 175 return JS('num', @'# >> #', a, b); | 164 return JS('num', @'# >> #', a, b); |
| 176 } | 165 } |
| 177 checkNull(a); | |
| 178 return UNINTERCEPTED(a >> b); | 166 return UNINTERCEPTED(a >> b); |
| 179 } | 167 } |
| 180 | 168 |
| 181 and(var a, var b) { | 169 and(var a, var b) { |
| 182 // TODO(floitsch): inputs must be integers. | 170 // TODO(floitsch): inputs must be integers. |
| 183 if (checkNumbers(a, b)) { | 171 if (checkNumbers(a, b)) { |
| 184 return JS('num', @'# & #', a, b); | 172 return JS('num', @'# & #', a, b); |
| 185 } | 173 } |
| 186 checkNull(a); | |
| 187 return UNINTERCEPTED(a & b); | 174 return UNINTERCEPTED(a & b); |
| 188 } | 175 } |
| 189 | 176 |
| 190 or(var a, var b) { | 177 or(var a, var b) { |
| 191 // TODO(floitsch): inputs must be integers. | 178 // TODO(floitsch): inputs must be integers. |
| 192 if (checkNumbers(a, b)) { | 179 if (checkNumbers(a, b)) { |
| 193 return JS('num', @'# | #', a, b); | 180 return JS('num', @'# | #', a, b); |
| 194 } | 181 } |
| 195 checkNull(a); | |
| 196 return UNINTERCEPTED(a | b); | 182 return UNINTERCEPTED(a | b); |
| 197 } | 183 } |
| 198 | 184 |
| 199 xor(var a, var b) { | 185 xor(var a, var b) { |
| 200 // TODO(floitsch): inputs must be integers. | 186 // TODO(floitsch): inputs must be integers. |
| 201 if (checkNumbers(a, b)) { | 187 if (checkNumbers(a, b)) { |
| 202 return JS('num', @'# ^ #', a, b); | 188 return JS('num', @'# ^ #', a, b); |
| 203 } | 189 } |
| 204 checkNull(a); | |
| 205 return UNINTERCEPTED(a ^ b); | 190 return UNINTERCEPTED(a ^ b); |
| 206 } | 191 } |
| 207 | 192 |
| 208 not(var a) { | 193 not(var a) { |
| 209 if (JS('bool', @'typeof # === "number"', a)) return JS('num', @'~#', a); | 194 if (JS('bool', @'typeof # === "number"', a)) return JS('num', @'~#', a); |
| 210 checkNull(a); | |
| 211 return UNINTERCEPTED(~a); | 195 return UNINTERCEPTED(~a); |
| 212 } | 196 } |
| 213 | 197 |
| 214 neg(var a) { | 198 neg(var a) { |
| 215 if (JS('bool', @'typeof # === "number"', a)) return JS('num', @'-#', a); | 199 if (JS('bool', @'typeof # === "number"', a)) return JS('num', @'-#', a); |
| 216 checkNull(a); | |
| 217 return UNINTERCEPTED(-a); | 200 return UNINTERCEPTED(-a); |
| 218 } | 201 } |
| 219 | 202 |
| 220 index(var a, var index) { | 203 index(var a, var index) { |
| 221 checkNull(a); | |
| 222 if (a is String || isJsArray(a)) { | 204 if (a is String || isJsArray(a)) { |
| 223 if (index is !int) { | 205 if (index is !int) { |
| 224 if (index is !num) throw new IllegalArgumentException(index); | 206 if (index is !num) throw new IllegalArgumentException(index); |
| 225 if (index.truncate() !== index) throw new IllegalArgumentException(index); | 207 if (index.truncate() !== index) throw new IllegalArgumentException(index); |
| 226 } | 208 } |
| 227 if (index < 0 || index >= a.length) { | 209 if (index < 0 || index >= a.length) { |
| 228 throw new IndexOutOfRangeException(index); | 210 throw new IndexOutOfRangeException(index); |
| 229 } | 211 } |
| 230 return JS('Object', @'#[#]', a, index); | 212 return JS('Object', @'#[#]', a, index); |
| 231 } | 213 } |
| 232 checkNull(a); | |
| 233 return UNINTERCEPTED(a[index]); | 214 return UNINTERCEPTED(a[index]); |
| 234 } | 215 } |
| 235 | 216 |
| 236 void indexSet(var a, var index, var value) { | 217 void indexSet(var a, var index, var value) { |
| 237 checkNull(a); | |
| 238 if (isJsArray(a)) { | 218 if (isJsArray(a)) { |
| 239 if (!(index is int)) { | 219 if (!(index is int)) { |
| 240 throw new IllegalArgumentException(index); | 220 throw new IllegalArgumentException(index); |
| 241 } | 221 } |
| 242 if (index < 0 || index >= a.length) { | 222 if (index < 0 || index >= a.length) { |
| 243 throw new IndexOutOfRangeException(index); | 223 throw new IndexOutOfRangeException(index); |
| 244 } | 224 } |
| 245 checkMutable(a, 'indexed set'); | 225 checkMutable(a, 'indexed set'); |
| 246 JS('Object', @'#[#] = #', a, index, value); | 226 JS('Object', @'#[#] = #', a, index, value); |
| 247 return; | 227 return; |
| 248 } | 228 } |
| 249 checkNull(a); | |
| 250 UNINTERCEPTED(a[index] = value); | 229 UNINTERCEPTED(a[index] = value); |
| 251 } | 230 } |
| 252 | 231 |
| 253 checkMutable(list, reason) { | 232 checkMutable(list, reason) { |
| 254 if (JS('bool', @'!!(#.immutable$list)', list)) { | 233 if (JS('bool', @'!!(#.immutable$list)', list)) { |
| 255 throw new UnsupportedOperationException(reason); | 234 throw new UnsupportedOperationException(reason); |
| 256 } | 235 } |
| 257 } | 236 } |
| 258 | 237 |
| 259 builtin$add$1(var receiver, var value) { | 238 builtin$add$1(var receiver, var value) { |
| 260 checkNull(receiver); | |
| 261 if (isJsArray(receiver)) { | 239 if (isJsArray(receiver)) { |
| 262 checkGrowable(receiver, 'add'); | 240 checkGrowable(receiver, 'add'); |
| 263 JS('Object', @'#.push(#)', receiver, value); | 241 JS('Object', @'#.push(#)', receiver, value); |
| 264 return; | 242 return; |
| 265 } | 243 } |
| 266 return UNINTERCEPTED(receiver.add(value)); | 244 return UNINTERCEPTED(receiver.add(value)); |
| 267 } | 245 } |
| 268 | 246 |
| 269 builtin$removeLast$0(var receiver) { | 247 builtin$removeLast$0(var receiver) { |
| 270 checkNull(receiver); | |
| 271 if (isJsArray(receiver)) { | 248 if (isJsArray(receiver)) { |
| 272 checkGrowable(receiver, 'removeLast'); | 249 checkGrowable(receiver, 'removeLast'); |
| 273 if (receiver.length === 0) throw new IndexOutOfRangeException(-1); | 250 if (receiver.length === 0) throw new IndexOutOfRangeException(-1); |
| 274 return JS('Object', @'#.pop()', receiver); | 251 return JS('Object', @'#.pop()', receiver); |
| 275 } | 252 } |
| 276 return UNINTERCEPTED(receiver.removeLast()); | 253 return UNINTERCEPTED(receiver.removeLast()); |
| 277 } | 254 } |
| 278 | 255 |
| 279 builtin$filter$1(var receiver, var predicate) { | 256 builtin$filter$1(var receiver, var predicate) { |
| 280 checkNull(receiver); | 257 if (!isJsArray(receiver)) { |
| 281 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.filter(predicate)); | 258 return UNINTERCEPTED(receiver.filter(predicate)); |
| 282 | 259 } else { |
| 283 return Collections.filter(receiver, [], predicate); | 260 return Collections.filter(receiver, [], predicate); |
| 261 } |
| 284 } | 262 } |
| 285 | 263 |
| 286 | 264 |
| 287 builtin$get$length(var receiver) { | 265 builtin$get$length(var receiver) { |
| 288 checkNull(receiver); | |
| 289 if (receiver is String || isJsArray(receiver)) { | 266 if (receiver is String || isJsArray(receiver)) { |
| 290 return JS('num', @'#.length', receiver); | 267 return JS('num', @'#.length', receiver); |
| 268 } else { |
| 269 return UNINTERCEPTED(receiver.length); |
| 291 } | 270 } |
| 292 return UNINTERCEPTED(receiver.length); | |
| 293 } | 271 } |
| 294 | 272 |
| 295 builtin$set$length(receiver, newLength) { | 273 builtin$set$length(receiver, newLength) { |
| 296 checkNull(receiver); | |
| 297 if (isJsArray(receiver)) { | 274 if (isJsArray(receiver)) { |
| 298 checkNull(newLength); // TODO(ahe): This is not specified but co19 tests it. | 275 checkNull(newLength); // TODO(ahe): This is not specified but co19 tests it. |
| 299 if (newLength is !int) throw new IllegalArgumentException(newLength); | 276 if (newLength is !int) throw new IllegalArgumentException(newLength); |
| 300 if (newLength < 0) throw new IndexOutOfRangeException(newLength); | 277 if (newLength < 0) throw new IndexOutOfRangeException(newLength); |
| 301 checkGrowable(receiver, 'set length'); | 278 checkGrowable(receiver, 'set length'); |
| 302 JS('void', @'#.length = #', receiver, newLength); | 279 JS('void', @'#.length = #', receiver, newLength); |
| 303 } else { | 280 } else { |
| 304 UNINTERCEPTED(receiver.length = newLength); | 281 UNINTERCEPTED(receiver.length = newLength); |
| 305 } | 282 } |
| 306 return newLength; | 283 return newLength; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 325 } | 302 } |
| 326 if (value === null) return 'null'; | 303 if (value === null) return 'null'; |
| 327 if (JS('bool', @'typeof # == "function"', value)) { | 304 if (JS('bool', @'typeof # == "function"', value)) { |
| 328 return 'Closure'; | 305 return 'Closure'; |
| 329 } | 306 } |
| 330 return JS('string', @'String(#)', value); | 307 return JS('string', @'String(#)', value); |
| 331 } | 308 } |
| 332 | 309 |
| 333 | 310 |
| 334 builtin$iterator$0(receiver) { | 311 builtin$iterator$0(receiver) { |
| 335 checkNull(receiver); | |
| 336 if (isJsArray(receiver)) { | 312 if (isJsArray(receiver)) { |
| 337 return new ListIterator(receiver); | 313 return new ListIterator(receiver); |
| 338 } | 314 } |
| 339 return UNINTERCEPTED(receiver.iterator()); | 315 return UNINTERCEPTED(receiver.iterator()); |
| 340 } | 316 } |
| 341 | 317 |
| 342 class ListIterator<T> implements Iterator<T> { | 318 class ListIterator<T> implements Iterator<T> { |
| 343 int i; | 319 int i; |
| 344 List<T> list; | 320 List<T> list; |
| 345 ListIterator(List<T> this.list) : i = 0; | 321 ListIterator(List<T> this.list) : i = 0; |
| 346 bool hasNext() => i < JS('int', @'#.length', list); | 322 bool hasNext() => i < JS('int', @'#.length', list); |
| 347 T next() { | 323 T next() { |
| 348 if (!hasNext()) throw new NoMoreElementsException(); | 324 if (!hasNext()) throw new NoMoreElementsException(); |
| 349 var value = JS('Object', @'#[#]', list, i); | 325 var value = JS('Object', @'#[#]', list, i); |
| 350 i += 1; | 326 i += 1; |
| 351 return value; | 327 return value; |
| 352 } | 328 } |
| 353 } | 329 } |
| 354 | 330 |
| 355 builtin$charCodeAt$1(var receiver, int index) { | 331 builtin$charCodeAt$1(var receiver, int index) { |
| 356 checkNull(receiver); | |
| 357 if (receiver is String) { | 332 if (receiver is String) { |
| 358 if (index is !num) throw new IllegalArgumentException(index); | 333 if (index is !num) throw new IllegalArgumentException(index); |
| 359 if (index < 0) throw new IndexOutOfRangeException(index); | 334 if (index < 0) throw new IndexOutOfRangeException(index); |
| 360 if (index >= receiver.length) throw new IndexOutOfRangeException(index); | 335 if (index >= receiver.length) throw new IndexOutOfRangeException(index); |
| 361 return JS('int', @'#.charCodeAt(#)', receiver, index); | 336 return JS('int', @'#.charCodeAt(#)', receiver, index); |
| 362 } else { | 337 } else { |
| 363 return UNINTERCEPTED(receiver.charCodeAt(index)); | 338 return UNINTERCEPTED(receiver.charCodeAt(index)); |
| 364 } | 339 } |
| 365 } | 340 } |
| 366 | 341 |
| 367 builtin$isEmpty$0(receiver) { | 342 builtin$isEmpty$0(receiver) { |
| 368 checkNull(receiver); | |
| 369 if (receiver is String || isJsArray(receiver)) { | 343 if (receiver is String || isJsArray(receiver)) { |
| 370 return JS('bool', @'#.length === 0', receiver); | 344 return JS('bool', @'#.length === 0', receiver); |
| 371 } | 345 } |
| 372 return UNINTERCEPTED(receiver.isEmpty()); | 346 return UNINTERCEPTED(receiver.isEmpty()); |
| 373 } | 347 } |
| 374 | 348 |
| 375 class Primitives { | 349 class Primitives { |
| 376 static void printString(String string) { | 350 static void printString(String string) { |
| 377 var hasConsole = JS('bool', @'typeof console == "object"'); | 351 var hasConsole = JS('bool', @'typeof console == "object"'); |
| 378 if (hasConsole) { | 352 if (hasConsole) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 static valueFromDateString(str) { | 491 static valueFromDateString(str) { |
| 518 checkNull(str); | 492 checkNull(str); |
| 519 if (str is !String) throw new IllegalArgumentException(str); | 493 if (str is !String) throw new IllegalArgumentException(str); |
| 520 var value = JS('num', @'Date.parse(#)', str); | 494 var value = JS('num', @'Date.parse(#)', str); |
| 521 if (value.isNaN()) throw new IllegalArgumentException(str); | 495 if (value.isNaN()) throw new IllegalArgumentException(str); |
| 522 return value; | 496 return value; |
| 523 } | 497 } |
| 524 } | 498 } |
| 525 | 499 |
| 526 builtin$compareTo$1(a, b) { | 500 builtin$compareTo$1(a, b) { |
| 527 checkNull(a); | |
| 528 if (checkNumbers(a, b)) { | 501 if (checkNumbers(a, b)) { |
| 529 if (a < b) { | 502 if (a < b) { |
| 530 return -1; | 503 return -1; |
| 531 } else if (a > b) { | 504 } else if (a > b) { |
| 532 return 1; | 505 return 1; |
| 533 } else if (a == b) { | 506 } else if (a == b) { |
| 534 if (a == 0) { | 507 if (a == 0) { |
| 535 bool aIsNegative = a.isNegative(); | 508 bool aIsNegative = a.isNegative(); |
| 536 bool bIsNegative = b.isNegative(); | 509 bool bIsNegative = b.isNegative(); |
| 537 if (aIsNegative == bIsNegative) return 0; | 510 if (aIsNegative == bIsNegative) return 0; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 568 /** | 541 /** |
| 569 * Called by generated code to throw an index-out-of-range exception, | 542 * Called by generated code to throw an index-out-of-range exception, |
| 570 * for example, if a bounds check fails in an optimized indexed | 543 * for example, if a bounds check fails in an optimized indexed |
| 571 * access. | 544 * access. |
| 572 */ | 545 */ |
| 573 ioore(index) { | 546 ioore(index) { |
| 574 throw new IndexOutOfRangeException(index); | 547 throw new IndexOutOfRangeException(index); |
| 575 } | 548 } |
| 576 | 549 |
| 577 builtin$addAll$1(receiver, collection) { | 550 builtin$addAll$1(receiver, collection) { |
| 578 checkNull(receiver); | |
| 579 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.addAll(collection)); | 551 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.addAll(collection)); |
| 580 | 552 |
| 581 // TODO(ahe): Use for-in when it is implemented correctly. | 553 // TODO(ahe): Use for-in when it is implemented correctly. |
| 582 var iterator = collection.iterator(); | 554 var iterator = collection.iterator(); |
| 583 while (iterator.hasNext()) { | 555 while (iterator.hasNext()) { |
| 584 receiver.add(iterator.next()); | 556 receiver.add(iterator.next()); |
| 585 } | 557 } |
| 586 } | 558 } |
| 587 | 559 |
| 588 builtin$addLast$1(receiver, value) { | 560 builtin$addLast$1(receiver, value) { |
| 589 checkNull(receiver); | |
| 590 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.addLast(value)); | 561 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.addLast(value)); |
| 591 | 562 |
| 592 checkGrowable(receiver, 'addLast'); | 563 checkGrowable(receiver, 'addLast'); |
| 593 JS('Object', @'#.push(#)', receiver, value); | 564 JS('Object', @'#.push(#)', receiver, value); |
| 594 } | 565 } |
| 595 | 566 |
| 596 builtin$clear$0(receiver) { | 567 builtin$clear$0(receiver) { |
| 597 checkNull(receiver); | |
| 598 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.clear()); | 568 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.clear()); |
| 599 receiver.length = 0; | 569 receiver.length = 0; |
| 600 } | 570 } |
| 601 | 571 |
| 602 builtin$forEach$1(receiver, f) { | 572 builtin$forEach$1(receiver, f) { |
| 603 checkNull(receiver); | 573 if (!isJsArray(receiver)) { |
| 604 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.forEach(f)); | 574 return UNINTERCEPTED(receiver.forEach(f)); |
| 575 } else { |
| 576 return Collections.forEach(receiver, f); |
| 577 } |
| 578 } |
| 605 | 579 |
| 606 | 580 builtin$map$1(receiver, f) { |
| 607 var length = JS('num', @'#.length', receiver); | 581 if (!isJsArray(receiver)) { |
| 608 if (length > 0 && f === null) throw new ObjectNotClosureException(); // Sigh. | 582 return UNINTERCEPTED(receiver.map(f)); |
| 609 for (var i = 0; i < length; i++) { | 583 } else { |
| 610 f(JS('Object', @'#[#]', receiver, i)); | 584 return Collections.map(receiver, [], f); |
| 611 } | 585 } |
| 612 } | 586 } |
| 613 | 587 |
| 614 builtin$getRange$2(receiver, start, length) { | 588 builtin$getRange$2(receiver, start, length) { |
| 615 checkNull(receiver); | |
| 616 if (!isJsArray(receiver)) { | 589 if (!isJsArray(receiver)) { |
| 617 return UNINTERCEPTED(receiver.getRange(start, length)); | 590 return UNINTERCEPTED(receiver.getRange(start, length)); |
| 618 } | 591 } |
| 619 if (0 === length) return []; | 592 if (0 === length) return []; |
| 620 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. | 593 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
| 621 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. | 594 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
| 622 if (start is !int) throw new IllegalArgumentException(start); | 595 if (start is !int) throw new IllegalArgumentException(start); |
| 623 if (length is !int) throw new IllegalArgumentException(length); | 596 if (length is !int) throw new IllegalArgumentException(length); |
| 624 if (start < 0) throw new IndexOutOfRangeException(start); | 597 if (start < 0) throw new IndexOutOfRangeException(start); |
| 625 if (length < 0) throw new IllegalArgumentException(length); | 598 if (length < 0) throw new IllegalArgumentException(length); |
| 626 var end = start + length; | 599 var end = start + length; |
| 627 if (end > receiver.length) { | 600 if (end > receiver.length) { |
| 628 throw new IndexOutOfRangeException(length); | 601 throw new IndexOutOfRangeException(length); |
| 629 } | 602 } |
| 630 if (length < 0) throw new IllegalArgumentException(length); | 603 if (length < 0) throw new IllegalArgumentException(length); |
| 631 return JS('Object', @'#.slice(#, #)', receiver, start, end); | 604 return JS('Object', @'#.slice(#, #)', receiver, start, end); |
| 632 } | 605 } |
| 633 | 606 |
| 634 builtin$indexOf$1(receiver, element) { | 607 builtin$indexOf$1(receiver, element) { |
| 635 checkNull(receiver); | |
| 636 if (isJsArray(receiver) || receiver is String) { | 608 if (isJsArray(receiver) || receiver is String) { |
| 637 return builtin$indexOf$2(receiver, element, 0); | 609 return builtin$indexOf$2(receiver, element, 0); |
| 638 } | 610 } |
| 639 return UNINTERCEPTED(receiver.indexOf(element)); | 611 return UNINTERCEPTED(receiver.indexOf(element)); |
| 640 } | 612 } |
| 641 | 613 |
| 642 builtin$indexOf$2(receiver, element, start) { | 614 builtin$indexOf$2(receiver, element, start) { |
| 643 checkNull(receiver); | |
| 644 if (isJsArray(receiver)) { | 615 if (isJsArray(receiver)) { |
| 645 if (start is !int) throw new IllegalArgumentException(start); | 616 if (start is !int) throw new IllegalArgumentException(start); |
| 646 var length = JS('num', @'#.length', receiver); | 617 var length = JS('num', @'#.length', receiver); |
| 647 return Arrays.indexOf(receiver, element, start, length); | 618 return Arrays.indexOf(receiver, element, start, length); |
| 648 } else if (receiver is String) { | 619 } else if (receiver is String) { |
| 649 checkNull(element); | 620 checkNull(element); |
| 650 if (start is !int) throw new IllegalArgumentException(start); | 621 if (start is !int) throw new IllegalArgumentException(start); |
| 651 if (element is !String) throw new IllegalArgumentException(element); | 622 if (element is !String) throw new IllegalArgumentException(element); |
| 652 if (start < 0) return -1; // TODO(ahe): Is this correct? | 623 if (start < 0) return -1; // TODO(ahe): Is this correct? |
| 653 return JS('int', @'#.indexOf(#, #)', receiver, element, start); | 624 return JS('int', @'#.indexOf(#, #)', receiver, element, start); |
| 654 } | 625 } |
| 655 return UNINTERCEPTED(receiver.indexOf(element, start)); | 626 return UNINTERCEPTED(receiver.indexOf(element, start)); |
| 656 } | 627 } |
| 657 | 628 |
| 658 builtin$insertRange$2(receiver, start, length) { | 629 builtin$insertRange$2(receiver, start, length) { |
| 659 checkNull(receiver); | |
| 660 if (isJsArray(receiver)) { | 630 if (isJsArray(receiver)) { |
| 661 return builtin$insertRange$3(receiver, start, length, null); | 631 return builtin$insertRange$3(receiver, start, length, null); |
| 662 } | 632 } |
| 663 return UNINTERCEPTED(receiver.insertRange(start, length)); | 633 return UNINTERCEPTED(receiver.insertRange(start, length)); |
| 664 } | 634 } |
| 665 | 635 |
| 666 builtin$insertRange$3(receiver, start, length, initialValue) { | 636 builtin$insertRange$3(receiver, start, length, initialValue) { |
| 667 checkNull(receiver); | |
| 668 if (!isJsArray(receiver)) { | 637 if (!isJsArray(receiver)) { |
| 669 return UNINTERCEPTED(receiver.insertRange(start, length, initialValue)); | 638 return UNINTERCEPTED(receiver.insertRange(start, length, initialValue)); |
| 670 } | 639 } |
| 671 return listInsertRange(receiver, start, length, initialValue); | 640 return listInsertRange(receiver, start, length, initialValue); |
| 672 } | 641 } |
| 673 | 642 |
| 674 listInsertRange(receiver, start, length, initialValue) { | 643 listInsertRange(receiver, start, length, initialValue) { |
| 675 if (length === 0) { | 644 if (length === 0) { |
| 676 return; | 645 return; |
| 677 } | 646 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 693 receiverLength - start); | 662 receiverLength - start); |
| 694 if (initialValue !== null) { | 663 if (initialValue !== null) { |
| 695 for (int i = start; i < start + length; i++) { | 664 for (int i = start; i < start + length; i++) { |
| 696 receiver[i] = initialValue; | 665 receiver[i] = initialValue; |
| 697 } | 666 } |
| 698 } | 667 } |
| 699 receiver.length = receiverLength + length; | 668 receiver.length = receiverLength + length; |
| 700 } | 669 } |
| 701 | 670 |
| 702 builtin$last$0(receiver) { | 671 builtin$last$0(receiver) { |
| 703 checkNull(receiver); | |
| 704 if (!isJsArray(receiver)) { | 672 if (!isJsArray(receiver)) { |
| 705 return UNINTERCEPTED(receiver.last()); | 673 return UNINTERCEPTED(receiver.last()); |
| 706 } | 674 } |
| 707 return receiver[receiver.length - 1]; | 675 return receiver[receiver.length - 1]; |
| 708 } | 676 } |
| 709 | 677 |
| 710 builtin$lastIndexOf$1(receiver, element) { | 678 builtin$lastIndexOf$1(receiver, element) { |
| 711 checkNull(receiver); | |
| 712 if (isJsArray(receiver)) { | 679 if (isJsArray(receiver)) { |
| 713 var start = JS('num', @'#.length', receiver); | 680 var start = JS('num', @'#.length', receiver); |
| 714 return Arrays.lastIndexOf(receiver, element, start); | 681 return Arrays.lastIndexOf(receiver, element, start); |
| 715 } else if (receiver is String) { | 682 } else if (receiver is String) { |
| 716 checkNull(element); | 683 checkNull(element); |
| 717 if (element is !String) throw new IllegalArgumentException(element); | 684 if (element is !String) throw new IllegalArgumentException(element); |
| 718 return JS('int', @'#.lastIndexOf(#)', receiver, element); | 685 return JS('int', @'#.lastIndexOf(#)', receiver, element); |
| 719 } | 686 } |
| 720 return UNINTERCEPTED(receiver.lastIndexOf(element)); | 687 return UNINTERCEPTED(receiver.lastIndexOf(element)); |
| 721 } | 688 } |
| 722 | 689 |
| 723 builtin$lastIndexOf$2(receiver, element, start) { | 690 builtin$lastIndexOf$2(receiver, element, start) { |
| 724 checkNull(receiver); | |
| 725 if (isJsArray(receiver)) { | 691 if (isJsArray(receiver)) { |
| 726 return Arrays.lastIndexOf(receiver, element, start); | 692 return Arrays.lastIndexOf(receiver, element, start); |
| 727 } else if (receiver is String) { | 693 } else if (receiver is String) { |
| 728 checkNull(element); | 694 checkNull(element); |
| 729 if (element is !String) throw new IllegalArgumentException(element); | 695 if (element is !String) throw new IllegalArgumentException(element); |
| 730 if (start !== null) { | 696 if (start !== null) { |
| 731 if (start is !num) throw new IllegalArgumentException(start); | 697 if (start is !num) throw new IllegalArgumentException(start); |
| 732 if (start < 0) return -1; | 698 if (start < 0) return -1; |
| 733 if (start >= receiver.length) start = receiver.length - 1; | 699 if (start >= receiver.length) start = receiver.length - 1; |
| 734 } | 700 } |
| 735 return stringLastIndexOfUnchecked(receiver, element, start); | 701 return stringLastIndexOfUnchecked(receiver, element, start); |
| 736 } | 702 } |
| 737 return UNINTERCEPTED(receiver.lastIndexOf(element, start)); | 703 return UNINTERCEPTED(receiver.lastIndexOf(element, start)); |
| 738 } | 704 } |
| 739 | 705 |
| 740 stringLastIndexOfUnchecked(receiver, element, start) | 706 stringLastIndexOfUnchecked(receiver, element, start) |
| 741 => JS('int', @'#.lastIndexOf(#, #)', receiver, element, start); | 707 => JS('int', @'#.lastIndexOf(#, #)', receiver, element, start); |
| 742 | 708 |
| 743 builtin$removeRange$2(receiver, start, length) { | 709 builtin$removeRange$2(receiver, start, length) { |
| 744 checkNull(receiver); | |
| 745 if (!isJsArray(receiver)) { | 710 if (!isJsArray(receiver)) { |
| 746 return UNINTERCEPTED(receiver.removeRange(start, length)); | 711 return UNINTERCEPTED(receiver.removeRange(start, length)); |
| 747 } | 712 } |
| 748 checkGrowable(receiver, 'removeRange'); | 713 checkGrowable(receiver, 'removeRange'); |
| 749 if (length == 0) { | 714 if (length == 0) { |
| 750 return; | 715 return; |
| 751 } | 716 } |
| 752 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. | 717 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
| 753 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. | 718 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
| 754 if (start is !int) throw new IllegalArgumentException(start); | 719 if (start is !int) throw new IllegalArgumentException(start); |
| 755 if (length is !int) throw new IllegalArgumentException(length); | 720 if (length is !int) throw new IllegalArgumentException(length); |
| 756 if (length < 0) throw new IllegalArgumentException(length); | 721 if (length < 0) throw new IllegalArgumentException(length); |
| 757 var receiverLength = JS('num', @'#.length', receiver); | 722 var receiverLength = JS('num', @'#.length', receiver); |
| 758 if (start < 0 || start >= receiverLength) { | 723 if (start < 0 || start >= receiverLength) { |
| 759 throw new IndexOutOfRangeException(start); | 724 throw new IndexOutOfRangeException(start); |
| 760 } | 725 } |
| 761 if (start + length > receiverLength) { | 726 if (start + length > receiverLength) { |
| 762 throw new IndexOutOfRangeException(start + length); | 727 throw new IndexOutOfRangeException(start + length); |
| 763 } | 728 } |
| 764 Arrays.copy(receiver, | 729 Arrays.copy(receiver, |
| 765 start + length, | 730 start + length, |
| 766 receiver, | 731 receiver, |
| 767 start, | 732 start, |
| 768 receiverLength - length - start); | 733 receiverLength - length - start); |
| 769 receiver.length = receiverLength - length; | 734 receiver.length = receiverLength - length; |
| 770 } | 735 } |
| 771 | 736 |
| 772 builtin$setRange$3(receiver, start, length, from) { | 737 builtin$setRange$3(receiver, start, length, from) { |
| 773 checkNull(receiver); | |
| 774 if (isJsArray(receiver)) { | 738 if (isJsArray(receiver)) { |
| 775 return builtin$setRange$4(receiver, start, length, from, 0); | 739 return builtin$setRange$4(receiver, start, length, from, 0); |
| 776 } | 740 } |
| 777 return UNINTERCEPTED(receiver.setRange(start, length, from)); | 741 return UNINTERCEPTED(receiver.setRange(start, length, from)); |
| 778 } | 742 } |
| 779 | 743 |
| 780 builtin$setRange$4(receiver, start, length, from, startFrom) { | 744 builtin$setRange$4(receiver, start, length, from, startFrom) { |
| 781 checkNull(receiver); | |
| 782 if (!isJsArray(receiver)) { | 745 if (!isJsArray(receiver)) { |
| 783 return UNINTERCEPTED(receiver.setRange(start, length, from, startFrom)); | 746 return UNINTERCEPTED(receiver.setRange(start, length, from, startFrom)); |
| 784 } | 747 } |
| 785 | 748 |
| 786 checkMutable(receiver, 'indexed set'); | 749 checkMutable(receiver, 'indexed set'); |
| 787 if (length === 0) return; | 750 if (length === 0) return; |
| 788 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. | 751 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. |
| 789 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. | 752 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. |
| 790 checkNull(from); // TODO(ahe): This is not specified but co19 tests it. | 753 checkNull(from); // TODO(ahe): This is not specified but co19 tests it. |
| 791 checkNull(startFrom); // TODO(ahe): This is not specified but co19 tests it. | 754 checkNull(startFrom); // TODO(ahe): This is not specified but co19 tests it. |
| 792 if (start is !int) throw new IllegalArgumentException(start); | 755 if (start is !int) throw new IllegalArgumentException(start); |
| 793 if (length is !int) throw new IllegalArgumentException(length); | 756 if (length is !int) throw new IllegalArgumentException(length); |
| 794 if (startFrom is !int) throw new IllegalArgumentException(startFrom); | 757 if (startFrom is !int) throw new IllegalArgumentException(startFrom); |
| 795 if (length < 0) throw new IllegalArgumentException(length); | 758 if (length < 0) throw new IllegalArgumentException(length); |
| 796 if (start < 0) throw new IndexOutOfRangeException(start); | 759 if (start < 0) throw new IndexOutOfRangeException(start); |
| 797 if (start + length > receiver.length) { | 760 if (start + length > receiver.length) { |
| 798 throw new IndexOutOfRangeException(start + length); | 761 throw new IndexOutOfRangeException(start + length); |
| 799 } | 762 } |
| 800 | 763 |
| 801 Arrays.copy(from, startFrom, receiver, start, length); | 764 Arrays.copy(from, startFrom, receiver, start, length); |
| 802 } | 765 } |
| 803 | 766 |
| 804 builtin$some$1(receiver, f) { | 767 builtin$some$1(receiver, f) { |
| 805 checkNull(receiver); | 768 if (!isJsArray(receiver)) { |
| 806 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.some(f)); | 769 return UNINTERCEPTED(receiver.some(f)); |
| 807 | 770 } else { |
| 808 return Collections.some(receiver, f); | 771 return Collections.some(receiver, f); |
| 772 } |
| 809 } | 773 } |
| 810 | 774 |
| 811 builtin$every$1(receiver, f) { | 775 builtin$every$1(receiver, f) { |
| 812 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.every(f)); | 776 if (!isJsArray(receiver)) { |
| 813 | 777 return UNINTERCEPTED(receiver.every(f)); |
| 814 return Collections.every(receiver, f); | 778 } else { |
| 779 return Collections.every(receiver, f); |
| 780 } |
| 815 } | 781 } |
| 816 | 782 |
| 817 builtin$sort$1(receiver, compare) { | 783 builtin$sort$1(receiver, compare) { |
| 818 checkNull(receiver); | |
| 819 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare)); | 784 if (!isJsArray(receiver)) return UNINTERCEPTED(receiver.sort(compare)); |
| 820 | 785 |
| 821 DualPivotQuicksort.sort(receiver, compare); | 786 DualPivotQuicksort.sort(receiver, compare); |
| 822 } | 787 } |
| 823 | 788 |
| 824 checkNull(object) { | 789 checkNull(object) { |
| 825 if (object === null) throw new NullPointerException(); | 790 if (object === null) throw new NullPointerException(); |
| 826 return object; | 791 return object; |
| 827 } | 792 } |
| 828 | 793 |
| 829 checkNum(value) { | 794 checkNum(value) { |
| 830 checkNull(value); | 795 if (value is !num) { |
| 831 if (value is !num) throw new IllegalArgumentException(value); | 796 checkNull(value); |
| 797 throw new IllegalArgumentException(value); |
| 798 } |
| 832 return value; | 799 return value; |
| 833 } | 800 } |
| 834 | 801 |
| 835 checkInt(value) { | 802 checkInt(value) { |
| 836 checkNull(value); | 803 if (value is !int) { |
| 837 if (value is !int) throw new IllegalArgumentException(value); | 804 checkNull(value); |
| 805 throw new IllegalArgumentException(value); |
| 806 } |
| 838 return value; | 807 return value; |
| 839 } | 808 } |
| 840 | 809 |
| 841 checkBool(value) { | 810 checkBool(value) { |
| 842 checkNull(value); | 811 if (value is !bool) { |
| 843 if (value is !bool) throw new IllegalArgumentException(value); | 812 checkNull(value); |
| 813 throw new IllegalArgumentException(value); |
| 814 } |
| 844 return value; | 815 return value; |
| 845 } | 816 } |
| 846 | 817 |
| 847 checkString(value) { | 818 checkString(value) { |
| 848 checkNull(value); | 819 if (value is !String) { |
| 849 if (value is !String) throw new IllegalArgumentException(value); | 820 checkNull(value); |
| 821 throw new IllegalArgumentException(value); |
| 822 } |
| 850 return value; | 823 return value; |
| 851 } | 824 } |
| 852 | 825 |
| 853 builtin$isNegative$0(receiver) { | 826 builtin$isNegative$0(receiver) { |
| 854 checkNull(receiver); | |
| 855 if (receiver is num) { | 827 if (receiver is num) { |
| 856 return (receiver === 0) ? (1 / receiver) < 0 : receiver < 0; | 828 return (receiver === 0) ? (1 / receiver) < 0 : receiver < 0; |
| 857 } else { | 829 } else { |
| 858 return UNINTERCEPTED(receiver.isNegative()); | 830 return UNINTERCEPTED(receiver.isNegative()); |
| 859 } | 831 } |
| 860 } | 832 } |
| 861 | 833 |
| 862 builtin$isNaN$0(receiver) { | 834 builtin$isNaN$0(receiver) { |
| 863 checkNull(receiver); | |
| 864 if (receiver is num) { | 835 if (receiver is num) { |
| 865 return JS('bool', @'isNaN(#)', receiver); | 836 return JS('bool', @'isNaN(#)', receiver); |
| 866 } else { | 837 } else { |
| 867 return UNINTERCEPTED(receiver.isNegative()); | 838 return UNINTERCEPTED(receiver.isNegative()); |
| 868 } | 839 } |
| 869 } | 840 } |
| 870 | 841 |
| 871 builtin$remainder$1(a, b) { | 842 builtin$remainder$1(a, b) { |
| 872 checkNull(a); | |
| 873 if (checkNumbers(a, b)) { | 843 if (checkNumbers(a, b)) { |
| 874 return JS('num', @'# % #', a, b); | 844 return JS('num', @'# % #', a, b); |
| 875 } else { | 845 } else { |
| 876 return UNINTERCEPTED(a.remainder(b)); | 846 return UNINTERCEPTED(a.remainder(b)); |
| 877 } | 847 } |
| 878 } | 848 } |
| 879 | 849 |
| 880 builtin$abs$0(receiver) { | 850 builtin$abs$0(receiver) { |
| 881 checkNull(receiver); | |
| 882 if (receiver is !num) return UNINTERCEPTED(receiver.abs()); | 851 if (receiver is !num) return UNINTERCEPTED(receiver.abs()); |
| 883 | 852 |
| 884 return JS('num', @'Math.abs(#)', receiver); | 853 return JS('num', @'Math.abs(#)', receiver); |
| 885 } | 854 } |
| 886 | 855 |
| 887 builtin$toInt$0(receiver) { | 856 builtin$toInt$0(receiver) { |
| 888 checkNull(receiver); | |
| 889 if (receiver is !num) return UNINTERCEPTED(receiver.toInt()); | 857 if (receiver is !num) return UNINTERCEPTED(receiver.toInt()); |
| 890 | 858 |
| 891 if (receiver.isNaN()) throw new BadNumberFormatException('NaN'); | 859 if (receiver.isNaN()) throw new BadNumberFormatException('NaN'); |
| 892 | 860 |
| 893 if (receiver.isInfinite()) throw new BadNumberFormatException('Infinity'); | 861 if (receiver.isInfinite()) throw new BadNumberFormatException('Infinity'); |
| 894 | 862 |
| 895 var truncated = receiver.truncate(); | 863 var truncated = receiver.truncate(); |
| 896 return JS('bool', @'# == -0.0', truncated) ? 0 : truncated; | 864 return JS('bool', @'# == -0.0', truncated) ? 0 : truncated; |
| 897 } | 865 } |
| 898 | 866 |
| 899 builtin$ceil$0(receiver) { | 867 builtin$ceil$0(receiver) { |
| 900 checkNull(receiver); | |
| 901 if (receiver is !num) return UNINTERCEPTED(receiver.ceil()); | 868 if (receiver is !num) return UNINTERCEPTED(receiver.ceil()); |
| 902 | 869 |
| 903 return JS('num', @'Math.ceil(#)', receiver); | 870 return JS('num', @'Math.ceil(#)', receiver); |
| 904 } | 871 } |
| 905 | 872 |
| 906 builtin$floor$0(receiver) { | 873 builtin$floor$0(receiver) { |
| 907 checkNull(receiver); | |
| 908 if (receiver is !num) return UNINTERCEPTED(receiver.floor()); | 874 if (receiver is !num) return UNINTERCEPTED(receiver.floor()); |
| 909 | 875 |
| 910 return JS('num', @'Math.floor(#)', receiver); | 876 return JS('num', @'Math.floor(#)', receiver); |
| 911 } | 877 } |
| 912 | 878 |
| 913 builtin$isInfinite$0(receiver) { | 879 builtin$isInfinite$0(receiver) { |
| 914 checkNull(receiver); | |
| 915 if (receiver is !num) return UNINTERCEPTED(receiver.isInfinite()); | 880 if (receiver is !num) return UNINTERCEPTED(receiver.isInfinite()); |
| 916 | 881 |
| 917 return JS('bool', @'# == Infinity', receiver) | 882 return JS('bool', @'# == Infinity', receiver) |
| 918 || JS('bool', @'# == -Infinity', receiver); | 883 || JS('bool', @'# == -Infinity', receiver); |
| 919 } | 884 } |
| 920 | 885 |
| 921 builtin$negate$0(receiver) { | 886 builtin$negate$0(receiver) { |
| 922 checkNull(receiver); | |
| 923 if (receiver is !num) return UNINTERCEPTED(receiver.negate()); | 887 if (receiver is !num) return UNINTERCEPTED(receiver.negate()); |
| 924 | 888 |
| 925 return JS('num', @'-#', receiver); | 889 return JS('num', @'-#', receiver); |
| 926 } | 890 } |
| 927 | 891 |
| 928 builtin$round$0(receiver) { | 892 builtin$round$0(receiver) { |
| 929 checkNull(receiver); | |
| 930 if (receiver is !num) return UNINTERCEPTED(receiver.round()); | 893 if (receiver is !num) return UNINTERCEPTED(receiver.round()); |
| 931 | 894 |
| 932 if (JS('bool', @'# < 0', receiver)) { | 895 if (JS('bool', @'# < 0', receiver)) { |
| 933 return JS('num', @'-Math.round(-#)', receiver); | 896 return JS('num', @'-Math.round(-#)', receiver); |
| 934 } else { | 897 } else { |
| 935 return JS('num', @'Math.round(#)', receiver); | 898 return JS('num', @'Math.round(#)', receiver); |
| 936 } | 899 } |
| 937 } | 900 } |
| 938 | 901 |
| 939 builtin$toDouble$0(receiver) { | 902 builtin$toDouble$0(receiver) { |
| 940 checkNull(receiver); | |
| 941 if (receiver is !num) return UNINTERCEPTED(receiver.toDouble()); | 903 if (receiver is !num) return UNINTERCEPTED(receiver.toDouble()); |
| 942 | 904 |
| 943 // TODO(ahe): Just return receiver? | 905 // TODO(ahe): Just return receiver? |
| 944 return JS('double', @'# + 0', receiver); | 906 return JS('double', @'# + 0', receiver); |
| 945 } | 907 } |
| 946 | 908 |
| 947 builtin$truncate$0(receiver) { | 909 builtin$truncate$0(receiver) { |
| 948 checkNull(receiver); | |
| 949 if (receiver is !num) return UNINTERCEPTED(receiver.truncate()); | 910 if (receiver is !num) return UNINTERCEPTED(receiver.truncate()); |
| 950 | 911 |
| 951 return receiver < 0 ? receiver.ceil() : receiver.floor(); | 912 return receiver < 0 ? receiver.ceil() : receiver.floor(); |
| 952 } | 913 } |
| 953 | 914 |
| 954 builtin$toStringAsFixed$1(receiver, fractionDigits) { | 915 builtin$toStringAsFixed$1(receiver, fractionDigits) { |
| 955 checkNull(receiver); | |
| 956 if (receiver is !num) { | 916 if (receiver is !num) { |
| 957 return UNINTERCEPTED(receiver.toStringAsFixed(fractionDigits)); | 917 return UNINTERCEPTED(receiver.toStringAsFixed(fractionDigits)); |
| 958 } | 918 } |
| 959 checkNum(fractionDigits); | 919 checkNum(fractionDigits); |
| 960 | 920 |
| 961 String result = JS('String', @'#.toFixed(#)', receiver, fractionDigits); | 921 String result = JS('String', @'#.toFixed(#)', receiver, fractionDigits); |
| 962 if (receiver == 0 && receiver.isNegative()) return "-$result"; | 922 if (receiver == 0 && receiver.isNegative()) return "-$result"; |
| 963 return result; | 923 return result; |
| 964 } | 924 } |
| 965 | 925 |
| 966 builtin$toStringAsExponential$1(receiver, fractionDigits) { | 926 builtin$toStringAsExponential$1(receiver, fractionDigits) { |
| 967 checkNull(receiver); | |
| 968 if (receiver is !num) { | 927 if (receiver is !num) { |
| 969 return UNINTERCEPTED(receiver.toStringAsExponential(fractionDigits)); | 928 return UNINTERCEPTED(receiver.toStringAsExponential(fractionDigits)); |
| 970 } | 929 } |
| 971 if (fractionDigits !== null) checkNum(fractionDigits); | 930 if (fractionDigits !== null) checkNum(fractionDigits); |
| 972 | 931 |
| 973 String result = JS('String', @'#.toExponential(#)', | 932 String result = JS('String', @'#.toExponential(#)', |
| 974 receiver, fractionDigits); | 933 receiver, fractionDigits); |
| 975 if (receiver == 0 && receiver.isNegative()) return "-$result"; | 934 if (receiver == 0 && receiver.isNegative()) return "-$result"; |
| 976 return result; | 935 return result; |
| 977 } | 936 } |
| 978 | 937 |
| 979 builtin$toStringAsPrecision$1(receiver, fractionDigits) { | 938 builtin$toStringAsPrecision$1(receiver, fractionDigits) { |
| 980 checkNull(receiver); | |
| 981 if (receiver is !num) { | 939 if (receiver is !num) { |
| 982 return UNINTERCEPTED(receiver.toStringAsPrecision(fractionDigits)); | 940 return UNINTERCEPTED(receiver.toStringAsPrecision(fractionDigits)); |
| 983 } | 941 } |
| 984 checkNum(fractionDigits); | 942 checkNum(fractionDigits); |
| 985 | 943 |
| 986 String result = JS('String', @'#.toPrecision(#)', | 944 String result = JS('String', @'#.toPrecision(#)', |
| 987 receiver, fractionDigits); | 945 receiver, fractionDigits); |
| 988 if (receiver == 0 && receiver.isNegative()) return "-$result"; | 946 if (receiver == 0 && receiver.isNegative()) return "-$result"; |
| 989 return result; | 947 return result; |
| 990 } | 948 } |
| 991 | 949 |
| 992 builtin$toRadixString$1(receiver, radix) { | 950 builtin$toRadixString$1(receiver, radix) { |
| 993 checkNull(receiver); | |
| 994 if (receiver is !num) { | 951 if (receiver is !num) { |
| 995 return UNINTERCEPTED(receiver.toRadixString(radix)); | 952 return UNINTERCEPTED(receiver.toRadixString(radix)); |
| 996 } | 953 } |
| 997 checkNum(radix); | 954 checkNum(radix); |
| 998 | 955 |
| 999 return JS('String', @'#.toString(#)', receiver, radix); | 956 return JS('String', @'#.toString(#)', receiver, radix); |
| 1000 } | 957 } |
| 1001 | 958 |
| 1002 builtin$allMatches$1(receiver, str) { | 959 builtin$allMatches$1(receiver, str) { |
| 1003 checkNull(receiver); | |
| 1004 if (receiver is !String) return UNINTERCEPTED(receiver.allMatches(str)); | 960 if (receiver is !String) return UNINTERCEPTED(receiver.allMatches(str)); |
| 1005 checkString(str); | 961 checkString(str); |
| 1006 return allMatchesInStringUnchecked(receiver, str); | 962 return allMatchesInStringUnchecked(receiver, str); |
| 1007 } | 963 } |
| 1008 | 964 |
| 1009 builtin$concat$1(receiver, other) { | 965 builtin$concat$1(receiver, other) { |
| 1010 checkNull(receiver); | |
| 1011 if (receiver is !String) return UNINTERCEPTED(receiver.concat(other)); | 966 if (receiver is !String) return UNINTERCEPTED(receiver.concat(other)); |
| 1012 | 967 |
| 1013 if (other is !String) throw new IllegalArgumentException(other); | 968 if (other is !String) throw new IllegalArgumentException(other); |
| 1014 return JS('String', @'#.concat(#)', receiver, other); | 969 return JS('String', @'#.concat(#)', receiver, other); |
| 1015 } | 970 } |
| 1016 | 971 |
| 1017 builtin$contains$1(receiver, other) { | 972 builtin$contains$1(receiver, other) { |
| 1018 if (receiver is !String) { | 973 if (receiver is !String) { |
| 1019 checkNull(receiver); | |
| 1020 return UNINTERCEPTED(receiver.contains(other)); | 974 return UNINTERCEPTED(receiver.contains(other)); |
| 1021 } | 975 } |
| 1022 return builtin$contains$2(receiver, other, 0); | 976 return builtin$contains$2(receiver, other, 0); |
| 1023 } | 977 } |
| 1024 | 978 |
| 1025 builtin$contains$2(receiver, other, startIndex) { | 979 builtin$contains$2(receiver, other, startIndex) { |
| 1026 checkNull(receiver); | |
| 1027 if (receiver is !String) { | 980 if (receiver is !String) { |
| 1028 return UNINTERCEPTED(receiver.contains(other, startIndex)); | 981 return UNINTERCEPTED(receiver.contains(other, startIndex)); |
| 1029 } | 982 } |
| 1030 checkNull(other); | 983 checkNull(other); |
| 1031 return stringContainsUnchecked(receiver, other, startIndex); | 984 return stringContainsUnchecked(receiver, other, startIndex); |
| 1032 } | 985 } |
| 1033 | 986 |
| 1034 builtin$endsWith$1(receiver, other) { | 987 builtin$endsWith$1(receiver, other) { |
| 1035 checkNull(receiver); | |
| 1036 if (receiver is !String) return UNINTERCEPTED(receiver.endsWith(other)); | 988 if (receiver is !String) return UNINTERCEPTED(receiver.endsWith(other)); |
| 1037 | 989 |
| 1038 checkNull(other); | 990 checkString(other); |
| 1039 if (other is !String) throw new IllegalArgumentException(other); | |
| 1040 | |
| 1041 int receiverLength = receiver.length; | 991 int receiverLength = receiver.length; |
| 1042 int otherLength = other.length; | 992 int otherLength = other.length; |
| 1043 if (otherLength > receiverLength) return false; | 993 if (otherLength > receiverLength) return false; |
| 1044 return other == receiver.substring(receiverLength - otherLength); | 994 return other == receiver.substring(receiverLength - otherLength); |
| 1045 } | 995 } |
| 1046 | 996 |
| 1047 builtin$replaceAll$2(receiver, from, to) { | 997 builtin$replaceAll$2(receiver, from, to) { |
| 1048 checkNull(receiver); | |
| 1049 if (receiver is !String) return UNINTERCEPTED(receiver.replaceAll(from, to)); | 998 if (receiver is !String) return UNINTERCEPTED(receiver.replaceAll(from, to)); |
| 1050 | 999 |
| 1051 checkNull(from); | |
| 1052 checkString(to); | 1000 checkString(to); |
| 1053 return stringReplaceAllUnchecked(receiver, from, to); | 1001 return stringReplaceAllUnchecked(receiver, from, to); |
| 1054 } | 1002 } |
| 1055 | 1003 |
| 1056 builtin$replaceFirst$2(receiver, from, to) { | 1004 builtin$replaceFirst$2(receiver, from, to) { |
| 1057 checkNull(receiver); | |
| 1058 if (receiver is !String) { | 1005 if (receiver is !String) { |
| 1059 return UNINTERCEPTED(receiver.replaceFirst(from, to)); | 1006 return UNINTERCEPTED(receiver.replaceFirst(from, to)); |
| 1060 } | 1007 } |
| 1061 checkNull(from); | |
| 1062 checkString(to); | 1008 checkString(to); |
| 1063 return stringReplaceFirstUnchecked(receiver, from, to); | 1009 return stringReplaceFirstUnchecked(receiver, from, to); |
| 1064 } | 1010 } |
| 1065 | 1011 |
| 1066 builtin$split$1(receiver, pattern) { | 1012 builtin$split$1(receiver, pattern) { |
| 1067 checkNull(receiver); | |
| 1068 if (receiver is !String) return UNINTERCEPTED(receiver.split(pattern)); | 1013 if (receiver is !String) return UNINTERCEPTED(receiver.split(pattern)); |
| 1069 checkNull(pattern); | 1014 checkNull(pattern); |
| 1070 return stringSplitUnchecked(receiver, pattern); | 1015 return stringSplitUnchecked(receiver, pattern); |
| 1071 } | 1016 } |
| 1072 | 1017 |
| 1073 builtin$splitChars$0(receiver) { | 1018 builtin$splitChars$0(receiver) { |
| 1074 checkNull(receiver); | |
| 1075 if (receiver is !String) return UNINTERCEPTED(receiver.splitChars()); | 1019 if (receiver is !String) return UNINTERCEPTED(receiver.splitChars()); |
| 1076 | 1020 |
| 1077 return JS('List', @'#.split("")', receiver); | 1021 return JS('List', @'#.split("")', receiver); |
| 1078 } | 1022 } |
| 1079 | 1023 |
| 1080 builtin$startsWith$1(receiver, other) { | 1024 builtin$startsWith$1(receiver, other) { |
| 1081 checkNull(receiver); | |
| 1082 if (receiver is !String) return UNINTERCEPTED(receiver.startsWith(other)); | 1025 if (receiver is !String) return UNINTERCEPTED(receiver.startsWith(other)); |
| 1083 checkNull(other); | 1026 checkString(other); |
| 1084 if (other is !String) throw new IllegalArgumentException(other); | |
| 1085 | 1027 |
| 1086 int length = other.length; | 1028 int length = other.length; |
| 1087 if (length > receiver.length) return false; | 1029 if (length > receiver.length) return false; |
| 1088 return JS('bool', @'# == #', other, | 1030 return JS('bool', @'# == #', other, |
| 1089 JS('String', @'#.substring(0, #)', receiver, length)); | 1031 JS('String', @'#.substring(0, #)', receiver, length)); |
| 1090 } | 1032 } |
| 1091 | 1033 |
| 1092 builtin$substring$1(receiver, startIndex) { | 1034 builtin$substring$1(receiver, startIndex) { |
| 1093 checkNull(receiver); | |
| 1094 if (receiver is !String) return UNINTERCEPTED(receiver.substring(startIndex)); | 1035 if (receiver is !String) return UNINTERCEPTED(receiver.substring(startIndex)); |
| 1095 | 1036 |
| 1096 return builtin$substring$2(receiver, startIndex, null); | 1037 return builtin$substring$2(receiver, startIndex, null); |
| 1097 } | 1038 } |
| 1098 | 1039 |
| 1099 builtin$substring$2(receiver, startIndex, endIndex) { | 1040 builtin$substring$2(receiver, startIndex, endIndex) { |
| 1100 checkNull(receiver); | |
| 1101 if (receiver is !String) { | 1041 if (receiver is !String) { |
| 1102 return UNINTERCEPTED(receiver.substring(startIndex, endIndex)); | 1042 return UNINTERCEPTED(receiver.substring(startIndex, endIndex)); |
| 1103 } | 1043 } |
| 1104 checkNum(startIndex); | 1044 checkNum(startIndex); |
| 1105 var length = receiver.length; | 1045 var length = receiver.length; |
| 1106 if (endIndex === null) endIndex = length; | 1046 if (endIndex === null) endIndex = length; |
| 1107 checkNum(endIndex); | 1047 checkNum(endIndex); |
| 1108 if (startIndex < 0 ) throw new IndexOutOfRangeException(startIndex); | 1048 if (startIndex < 0 ) throw new IndexOutOfRangeException(startIndex); |
| 1109 if (startIndex > endIndex) throw new IndexOutOfRangeException(startIndex); | 1049 if (startIndex > endIndex) throw new IndexOutOfRangeException(startIndex); |
| 1110 if (endIndex > length) throw new IndexOutOfRangeException(endIndex); | 1050 if (endIndex > length) throw new IndexOutOfRangeException(endIndex); |
| 1111 return substringUnchecked(receiver, startIndex, endIndex); | 1051 return substringUnchecked(receiver, startIndex, endIndex); |
| 1112 } | 1052 } |
| 1113 | 1053 |
| 1114 substringUnchecked(receiver, startIndex, endIndex) | 1054 substringUnchecked(receiver, startIndex, endIndex) |
| 1115 => JS('String', @'#.substring(#, #)', receiver, startIndex, endIndex); | 1055 => JS('String', @'#.substring(#, #)', receiver, startIndex, endIndex); |
| 1116 | 1056 |
| 1117 | 1057 |
| 1118 builtin$toLowerCase$0(receiver) { | 1058 builtin$toLowerCase$0(receiver) { |
| 1119 checkNull(receiver); | |
| 1120 if (receiver is !String) return UNINTERCEPTED(receiver.toLowerCase()); | 1059 if (receiver is !String) return UNINTERCEPTED(receiver.toLowerCase()); |
| 1121 | 1060 |
| 1122 return JS('String', @'#.toLowerCase()', receiver); | 1061 return JS('String', @'#.toLowerCase()', receiver); |
| 1123 } | 1062 } |
| 1124 | 1063 |
| 1125 builtin$toUpperCase$0(receiver) { | 1064 builtin$toUpperCase$0(receiver) { |
| 1126 checkNull(receiver); | |
| 1127 if (receiver is !String) return UNINTERCEPTED(receiver.toUpperCase()); | 1065 if (receiver is !String) return UNINTERCEPTED(receiver.toUpperCase()); |
| 1128 | 1066 |
| 1129 return JS('String', @'#.toUpperCase()', receiver); | 1067 return JS('String', @'#.toUpperCase()', receiver); |
| 1130 } | 1068 } |
| 1131 | 1069 |
| 1132 builtin$trim$0(receiver) { | 1070 builtin$trim$0(receiver) { |
| 1133 checkNull(receiver); | |
| 1134 if (receiver is !String) return UNINTERCEPTED(receiver.trim()); | 1071 if (receiver is !String) return UNINTERCEPTED(receiver.trim()); |
| 1135 | 1072 |
| 1136 return JS('String', @'#.trim()', receiver); | 1073 return JS('String', @'#.trim()', receiver); |
| 1137 } | 1074 } |
| 1138 | 1075 |
| 1139 class MathNatives { | 1076 class MathNatives { |
| 1140 static int parseInt(str) { | 1077 static int parseInt(str) { |
| 1141 checkNull(str); | 1078 checkString(str); |
| 1142 if (str is !String) throw new IllegalArgumentException(str); | |
| 1143 if (!JS('bool', | 1079 if (!JS('bool', |
| 1144 @'/^\s*[+-]?(?:0[xX][abcdefABCDEF0-9]+|\d+)\s*$/.test(#)', | 1080 @'/^\s*[+-]?(?:0[xX][abcdefABCDEF0-9]+|\d+)\s*$/.test(#)', |
| 1145 str)) { | 1081 str)) { |
| 1146 throw new BadNumberFormatException(str); | 1082 throw new BadNumberFormatException(str); |
| 1147 } | 1083 } |
| 1148 var trimmed = str.trim(); | 1084 var trimmed = str.trim(); |
| 1149 var base = 10;; | 1085 var base = 10;; |
| 1150 if ((trimmed.length > 2 && (trimmed[1] == 'x' || trimmed[1] == 'X')) || | 1086 if ((trimmed.length > 2 && (trimmed[1] == 'x' || trimmed[1] == 'X')) || |
| 1151 (trimmed.length > 3 && (trimmed[2] == 'x' || trimmed[2] == 'X'))) { | 1087 (trimmed.length > 3 && (trimmed[2] == 'x' || trimmed[2] == 'X'))) { |
| 1152 base = 16; | 1088 base = 16; |
| 1153 } | 1089 } |
| 1154 var ret = JS('num', @'parseInt(#, #)', trimmed, base); | 1090 var ret = JS('num', @'parseInt(#, #)', trimmed, base); |
| 1155 if (ret.isNaN()) throw new BadNumberFormatException(str); | 1091 if (ret.isNaN()) throw new BadNumberFormatException(str); |
| 1156 return ret; | 1092 return ret; |
| 1157 } | 1093 } |
| 1158 | 1094 |
| 1159 static double parseDouble(String str) { | 1095 static double parseDouble(String str) { |
| 1160 checkNull(str); | 1096 checkString(str); |
| 1161 if (str is !String) throw new IllegalArgumentException(); | |
| 1162 var ret = JS('num', @'parseFloat(#)', str); | 1097 var ret = JS('num', @'parseFloat(#)', str); |
| 1163 if (ret == 0 && (str.startsWith("0x") || str.startsWith("0X"))) { | 1098 if (ret == 0 && (str.startsWith("0x") || str.startsWith("0X"))) { |
| 1164 // TODO(ahe): This is unspecified, but tested by co19. | 1099 // TODO(ahe): This is unspecified, but tested by co19. |
| 1165 ret = JS('num', @'parseInt(#)', str); | 1100 ret = JS('num', @'parseInt(#)', str); |
| 1166 } | 1101 } |
| 1167 if (ret.isNaN() && str != 'NaN' && str != '-NaN') { | 1102 if (ret.isNaN() && str != 'NaN' && str != '-NaN') { |
| 1168 throw new BadNumberFormatException(str); | 1103 throw new BadNumberFormatException(str); |
| 1169 } | 1104 } |
| 1170 return ret; | 1105 return ret; |
| 1171 } | 1106 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 | 1184 |
| 1250 /** | 1185 /** |
| 1251 * This method is installed as JavaScript toString method on exception | 1186 * This method is installed as JavaScript toString method on exception |
| 1252 * objects in [captureStackTrace]. So JavaScript 'this' binds to an | 1187 * objects in [captureStackTrace]. So JavaScript 'this' binds to an |
| 1253 * instance of JavaScript Error to which we have added a property | 1188 * instance of JavaScript Error to which we have added a property |
| 1254 * 'dartException' which holds a Dart object. | 1189 * 'dartException' which holds a Dart object. |
| 1255 */ | 1190 */ |
| 1256 toStringWrapper() => JS('Object', @'this.dartException').toString(); | 1191 toStringWrapper() => JS('Object', @'this.dartException').toString(); |
| 1257 | 1192 |
| 1258 builtin$charCodes$0(receiver) { | 1193 builtin$charCodes$0(receiver) { |
| 1259 checkNull(receiver); | |
| 1260 if (receiver is !String) return UNINTERCEPTED(receiver.charCodes()); | 1194 if (receiver is !String) return UNINTERCEPTED(receiver.charCodes()); |
| 1261 int len = receiver.length; | 1195 int len = receiver.length; |
| 1262 List<int> result = new List<int>(len); | 1196 List<int> result = new List<int>(len); |
| 1263 for (int i = 0; i < len; i++) { | 1197 for (int i = 0; i < len; i++) { |
| 1264 result[i] = receiver.charCodeAt(i); | 1198 result[i] = receiver.charCodeAt(i); |
| 1265 } | 1199 } |
| 1266 return result; | 1200 return result; |
| 1267 } | 1201 } |
| 1268 | 1202 |
| 1269 makeLiteralListConst(list) { | 1203 makeLiteralListConst(list) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 | 1326 |
| 1393 jsPropertyAccess(var jsObject, String property) { | 1327 jsPropertyAccess(var jsObject, String property) { |
| 1394 return JS('var', @'#[#]', jsObject, property); | 1328 return JS('var', @'#[#]', jsObject, property); |
| 1395 } | 1329 } |
| 1396 | 1330 |
| 1397 /** | 1331 /** |
| 1398 * Called at the end of unaborted switch cases to get the singleton | 1332 * Called at the end of unaborted switch cases to get the singleton |
| 1399 * FallThroughError exception that will be thrown. | 1333 * FallThroughError exception that will be thrown. |
| 1400 */ | 1334 */ |
| 1401 getFallThroughError() => const FallThroughError(); | 1335 getFallThroughError() => const FallThroughError(); |
| 1336 |
| 1337 builtin$isEven$0(receiver) { |
| 1338 if (receiver is !int) return UNINTERCEPTED(receiver.isEven()); |
| 1339 return (receiver & 1) === 0; |
| 1340 } |
| 1341 |
| 1342 builtin$isOdd$0(receiver) { |
| 1343 if (receiver is !int) return UNINTERCEPTED(receiver.isOdd()); |
| 1344 return (receiver & 1) === 1; |
| 1345 } |
| OLD | NEW |