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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 | 569 |
570 throwAbstractClassInstantiationError(className) { | 570 throwAbstractClassInstantiationError(className) { |
571 throw new AbstractClassInstantiationError(className); | 571 throw new AbstractClassInstantiationError(className); |
572 } | 572 } |
573 | 573 |
574 @NoInline() | 574 @NoInline() |
575 throwConcurrentModificationError(collection) { | 575 throwConcurrentModificationError(collection) { |
576 throw new ConcurrentModificationError(collection); | 576 throw new ConcurrentModificationError(collection); |
577 } | 577 } |
578 | 578 |
579 class NullError extends Error implements NoSuchMethodError { | 579 @JsPeerInterface(name: 'TypeError') |
580 final String _message; | 580 class NullError extends Interceptor implements NoSuchMethodError { |
581 final String _method; | 581 StackTrace get stackTrace => Primitives.extractStackTrace(this); |
582 | |
583 NullError(this._message, match) | |
584 : _method = match == null ? null : JS('', '#.method', match); | |
585 | 582 |
586 String toString() { | 583 String toString() { |
587 if (_method == null) return 'NullError: $_message'; | 584 // TODO(vsm): Distinguish between null reference errors and other |
588 return "NullError: method not found: '$_method' on null"; | 585 // TypeErrors. We should not get non-null TypeErrors from DDC code, |
| 586 // but we may from native JavaScript. |
| 587 var message = JS('String', '#.message', this); |
| 588 return "NullError: $message"; |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 class JsNoSuchMethodError extends Error implements NoSuchMethodError { | 592 class JsNoSuchMethodError extends Error implements NoSuchMethodError { |
593 final String _message; | 593 final String _message; |
594 final String _method; | 594 final String _method; |
595 final String _receiver; | 595 final String _receiver; |
596 | 596 |
597 JsNoSuchMethodError(this._message, match) | 597 JsNoSuchMethodError(this._message, match) |
598 : _method = match == null ? null : JS('String|Null', '#.method', match), | 598 : _method = match == null ? null : JS('String|Null', '#.method', match), |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 // we have no way of telling the compiler yet, so it will generate an extra | 915 // we have no way of telling the compiler yet, so it will generate an extra |
916 // layer of indirection that wraps the SyncIterator. | 916 // layer of indirection that wraps the SyncIterator. |
917 _jsIterator() => JS('', '#(...#)', _generator, _args); | 917 _jsIterator() => JS('', '#(...#)', _generator, _args); |
918 | 918 |
919 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 919 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
920 } | 920 } |
921 | 921 |
922 class BooleanConversionAssertionError extends AssertionError { | 922 class BooleanConversionAssertionError extends AssertionError { |
923 toString() => 'Failed assertion: boolean expression must not be null'; | 923 toString() => 'Failed assertion: boolean expression must not be null'; |
924 } | 924 } |
OLD | NEW |