| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_helper; | 5 library dart._js_helper; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'dart:_debugger' show stackTraceMapper; | 9 import 'dart:_debugger' show stackTraceMapper; |
| 10 | 10 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 return JS('var', '#[#]', object, key); | 485 return JS('var', '#[#]', object, key); |
| 486 } | 486 } |
| 487 | 487 |
| 488 static void setProperty(object, key, value) { | 488 static void setProperty(object, key, value) { |
| 489 if (object == null || object is bool || object is num || object is String) { | 489 if (object == null || object is bool || object is num || object is String) { |
| 490 throw argumentErrorValue(object); | 490 throw argumentErrorValue(object); |
| 491 } | 491 } |
| 492 JS('void', '#[#] = #', object, key, value); | 492 JS('void', '#[#] = #', object, key, value); |
| 493 } | 493 } |
| 494 | 494 |
| 495 static StackTrace extractStackTrace(Error error) { | 495 static StackTrace extractStackTrace(Error error) => |
| 496 return getTraceFromException(JS('', r'#.$thrownJsError', error)); | 496 getTraceFromException(error); |
| 497 } | |
| 498 } | 497 } |
| 499 | 498 |
| 500 /** | 499 /** |
| 501 * Diagnoses an indexing error. Returns the ArgumentError or RangeError that | 500 * Diagnoses an indexing error. Returns the ArgumentError or RangeError that |
| 502 * describes the problem. | 501 * describes the problem. |
| 503 */ | 502 */ |
| 504 @NoInline() | 503 @NoInline() |
| 505 Error diagnoseIndexError(indexable, index) { | 504 Error diagnoseIndexError(indexable, index) { |
| 506 if (index is! int) return new ArgumentError.value(index, 'index'); | 505 if (index is! int) return new ArgumentError.value(index, 'index'); |
| 507 int length = indexable.length; | 506 int length = indexable.length; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 619 |
| 621 class UnknownJsTypeError extends Error { | 620 class UnknownJsTypeError extends Error { |
| 622 final String _message; | 621 final String _message; |
| 623 | 622 |
| 624 UnknownJsTypeError(this._message); | 623 UnknownJsTypeError(this._message); |
| 625 | 624 |
| 626 String toString() => _message.isEmpty ? 'Error' : 'Error: $_message'; | 625 String toString() => _message.isEmpty ? 'Error' : 'Error: $_message'; |
| 627 } | 626 } |
| 628 | 627 |
| 629 /** | 628 /** |
| 630 * Called by generated code to fetch the stack trace from an | 629 * Called by generated code to fetch the stack trace from a Dart |
| 631 * exception. Should never return null. | 630 * exception. Should never return null. |
| 632 */ | 631 */ |
| 633 StackTrace getTraceFromException(exception) => new _StackTrace(exception); | 632 final _stackTrace = JS('', 'Symbol("_stackTrace")'); |
| 633 StackTrace getTraceFromException(exception) { |
| 634 var error = JS('', 'dart.recordJsError(#)', exception); |
| 635 var trace = JS('StackTrace', '#[#]', error, _stackTrace); |
| 636 if (trace != null) return trace; |
| 637 trace = new _StackTrace(error); |
| 638 JS('', '#[#] = #', error, _stackTrace, trace); |
| 639 return trace; |
| 640 } |
| 634 | 641 |
| 635 class _StackTrace implements StackTrace { | 642 class _StackTrace implements StackTrace { |
| 636 var _exception; | 643 var _exception; |
| 637 String _trace; | 644 String _trace; |
| 638 | 645 |
| 639 _StackTrace(this._exception); | 646 _StackTrace(this._exception); |
| 640 | 647 |
| 641 String toString() { | 648 String toString() { |
| 642 if (_trace != null) return _trace; | 649 if (_trace != null) return _trace; |
| 643 | 650 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 // we have no way of telling the compiler yet, so it will generate an extra | 923 // we have no way of telling the compiler yet, so it will generate an extra |
| 917 // layer of indirection that wraps the SyncIterator. | 924 // layer of indirection that wraps the SyncIterator. |
| 918 _jsIterator() => JS('', '#(...#)', _generator, _args); | 925 _jsIterator() => JS('', '#(...#)', _generator, _args); |
| 919 | 926 |
| 920 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 927 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
| 921 } | 928 } |
| 922 | 929 |
| 923 class BooleanConversionAssertionError extends AssertionError { | 930 class BooleanConversionAssertionError extends AssertionError { |
| 924 toString() => 'Failed assertion: boolean expression must not be null'; | 931 toString() => 'Failed assertion: boolean expression must not be null'; |
| 925 } | 932 } |
| OLD | NEW |