| 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 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, | 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
| 9 JS, | 9 JS, |
| 10 JS_CALL_IN_ISOLATE, | 10 JS_CALL_IN_ISOLATE, |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 var jsFunction = JS('var', '#[#]', function, selectorName); | 559 var jsFunction = JS('var', '#[#]', function, selectorName); |
| 560 if (jsFunction == null) { | 560 if (jsFunction == null) { |
| 561 throw new NoSuchMethodError(function, selectorName, arguments, {}); | 561 throw new NoSuchMethodError(function, selectorName, arguments, {}); |
| 562 } | 562 } |
| 563 // We bound 'this' to [function] because of how we compile | 563 // We bound 'this' to [function] because of how we compile |
| 564 // closures: escaped local variables are stored and accessed through | 564 // closures: escaped local variables are stored and accessed through |
| 565 // [function]. | 565 // [function]. |
| 566 return JS('var', '#.apply(#, #)', jsFunction, function, arguments); | 566 return JS('var', '#.apply(#, #)', jsFunction, function, arguments); |
| 567 } | 567 } |
| 568 | 568 |
| 569 static getConstructor(String className) { | 569 static getConstructorOrInterceptor(String className) { |
| 570 // TODO(ahe): Generalize this and improve test coverage of | 570 // TODO(ahe): Generalize this and improve test coverage of |
| 571 // reflecting on intercepted classes. | 571 // reflecting on intercepted classes. |
| 572 if (JS('bool', '# == "String"', className)) return const JSString(); | 572 if (JS('bool', '# == "String"', className)) return const JSString(); |
| 573 if (JS('bool', '# == "int"', className)) return const JSInt(); | 573 if (JS('bool', '# == "int"', className)) return const JSInt(); |
| 574 if (JS('bool', '# == "double"', className)) return const JSDouble(); | 574 if (JS('bool', '# == "double"', className)) return const JSDouble(); |
| 575 if (JS('bool', '# == "num"', className)) return const JSNumber(); | 575 if (JS('bool', '# == "num"', className)) return const JSNumber(); |
| 576 if (JS('bool', '# == "bool"', className)) return const JSBool(); | 576 if (JS('bool', '# == "bool"', className)) return const JSBool(); |
| 577 if (JS('bool', '# == "List"', className)) return const JSArray(); | 577 if (JS('bool', '# == "List"', className)) return const JSArray(); |
| 578 return JS('var', '#[#]', JS_CURRENT_ISOLATE(), className); | 578 return JS('var', '#[#]', JS_CURRENT_ISOLATE(), className); |
| 579 } | 579 } |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 /** | 1451 /** |
| 1452 * Error thrown when a runtime error occurs. | 1452 * Error thrown when a runtime error occurs. |
| 1453 */ | 1453 */ |
| 1454 class RuntimeError implements Error { | 1454 class RuntimeError implements Error { |
| 1455 final message; | 1455 final message; |
| 1456 RuntimeError(this.message); | 1456 RuntimeError(this.message); |
| 1457 String toString() => "RuntimeError: $message"; | 1457 String toString() => "RuntimeError: $message"; |
| 1458 } | 1458 } |
| OLD | NEW |