| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Native helpers generated by the compiler | 5 // Native helpers generated by the compiler |
| 6 // TODO(jmesserly): more natives should use this pattern | 6 // TODO(jmesserly): more natives should use this pattern |
| 7 | 7 |
| 8 // Translate a JavaScript exception to a Dart exception | 8 // Translate a JavaScript exception to a Dart exception |
| 9 // TODO(jmesserly): cross browser support. This is Chrome specific. | 9 // TODO(jmesserly): cross browser support. This is Chrome specific. |
| 10 _toDartException(e) native @""" | 10 _toDartException(e) native @""" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 break; | 39 break; |
| 40 case 'non_object_property_call': | 40 case 'non_object_property_call': |
| 41 case 'non_object_property_load': | 41 case 'non_object_property_load': |
| 42 return attachStack(new NullPointerException()); | 42 return attachStack(new NullPointerException()); |
| 43 break; | 43 break; |
| 44 case 'undefined_method': | 44 case 'undefined_method': |
| 45 if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') { | 45 if (e.arguments[0] == 'call' || e.arguments[0] == 'apply') { |
| 46 return attachStack(new ObjectNotClosureException()); | 46 return attachStack(new ObjectNotClosureException()); |
| 47 } else { | 47 } else { |
| 48 // TODO(jmesserly): can this ever happen? | 48 // TODO(jmesserly): fix noSuchMethod on operators so we don't hit this |
| 49 // sra: Yes, seen on '$add'. | |
| 50 return attachStack(new NoSuchMethodException('', e.arguments[0], [])); | 49 return attachStack(new NoSuchMethodException('', e.arguments[0], [])); |
| 51 } | 50 } |
| 52 break; | 51 break; |
| 53 } | 52 } |
| 54 } else if (e instanceof RangeError) { | 53 } else if (e instanceof RangeError) { |
| 55 if (e.message.indexOf('call stack') >= 0) { | 54 if (e.message.indexOf('call stack') >= 0) { |
| 56 return attachStack(new StackOverflowException()); | 55 return attachStack(new StackOverflowException()); |
| 57 } | 56 } |
| 58 } | 57 } |
| 59 return e;""" { | 58 return e;""" { |
| 60 // Ensure constructors are generated | 59 // Ensure constructors are generated |
| 61 new ObjectNotClosureException(); | 60 new ObjectNotClosureException(); |
| 62 new NullPointerException(); | 61 new NullPointerException(); |
| 63 new NoSuchMethodException(null, null, null); | 62 new NoSuchMethodException(null, null, null); |
| 64 new StackOverflowException(); | 63 new StackOverflowException(); |
| 65 } | 64 } |
| OLD | NEW |