Chromium Code Reviews| 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 patch class Error { | 5 patch class Error { |
| 6 /* patch */ static String _objectToString(Object object) { | 6 /* patch */ static String _objectToString(Object object) { |
| 7 return Object._toString(object); | 7 return Object._toString(object); |
| 8 } | 8 } |
| 9 | |
| 10 // TODO(XYZ): implement stackTrace on Error. | |
|
Lasse Reichstein Nielsen
2013/07/03 13:06:13
XYZ -> number.
floitsch
2013/07/03 14:50:20
Done.
| |
| 11 /* patch */ StackTrace get stackTrace => null; | |
| 9 } | 12 } |
| 10 | 13 |
| 11 patch class NoSuchMethodError { | 14 patch class NoSuchMethodError { |
| 12 // The compiler emits a call to _throwNew when it cannot resolve a static | 15 // The compiler emits a call to _throwNew when it cannot resolve a static |
| 13 // method at compile time. The receiver is actually the literal class of the | 16 // method at compile time. The receiver is actually the literal class of the |
| 14 // unresolved method. | 17 // unresolved method. |
| 15 static void _throwNew(Object receiver, | 18 static void _throwNew(Object receiver, |
| 16 String memberName, | 19 String memberName, |
| 17 int invocation_type, | 20 int invocation_type, |
| 18 List arguments, | 21 List arguments, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 31 positionalArguments = argumentNames == null ? null : []; | 34 positionalArguments = argumentNames == null ? null : []; |
| 32 } else { | 35 } else { |
| 33 positionalArguments = arguments.sublist(0, numPositionalArguments); | 36 positionalArguments = arguments.sublist(0, numPositionalArguments); |
| 34 } | 37 } |
| 35 Map<String, dynamic> namedArguments = new Map<String, dynamic>(); | 38 Map<String, dynamic> namedArguments = new Map<String, dynamic>(); |
| 36 for (int i = 0; i < numNamedArguments; i++) { | 39 for (int i = 0; i < numNamedArguments; i++) { |
| 37 var arg_value = arguments[numPositionalArguments + i]; | 40 var arg_value = arguments[numPositionalArguments + i]; |
| 38 namedArguments[argumentNames[i]] = arg_value; | 41 namedArguments[argumentNames[i]] = arg_value; |
| 39 } | 42 } |
| 40 throw new NoSuchMethodError._withType(receiver, | 43 throw new NoSuchMethodError._withType(receiver, |
| 41 memberName, | 44 memberName, |
| 42 invocation_type, | 45 invocation_type, |
| 43 positionalArguments, | 46 positionalArguments, |
| 44 namedArguments, | 47 namedArguments, |
| 45 existingArgumentNames); | 48 existingArgumentNames); |
| 46 } | 49 } |
| 47 | 50 |
| 48 // Remember the type from the invocation mirror or static compilation | 51 // Remember the type from the invocation mirror or static compilation |
| 49 // analysis when thrown directly with _throwNew. A negative value means | 52 // analysis when thrown directly with _throwNew. A negative value means |
| 50 // that no information is available. | 53 // that no information is available. |
| 51 final int _invocation_type; | 54 final int _invocation_type; |
| 52 | 55 |
| 53 const NoSuchMethodError(Object this._receiver, | 56 NoSuchMethodError(Object this._receiver, |
| 54 String this._memberName, | 57 String this._memberName, |
| 55 List this._arguments, | 58 List this._arguments, |
| 56 Map<String,dynamic> this._namedArguments, | 59 Map<String,dynamic> this._namedArguments, |
| 57 [List existingArgumentNames = null]) | 60 [List existingArgumentNames = null]) |
| 58 : this._existingArgumentNames = existingArgumentNames, | 61 : this._existingArgumentNames = existingArgumentNames, |
| 59 this._invocation_type = -1; | 62 this._invocation_type = -1; |
| 60 | 63 |
| 61 const NoSuchMethodError._withType(Object this._receiver, | 64 NoSuchMethodError._withType(Object this._receiver, |
| 62 String this._memberName, | 65 String this._memberName, |
| 63 this._invocation_type, | 66 this._invocation_type, |
| 64 List this._arguments, | 67 List this._arguments, |
| 65 Map<String,dynamic> this._namedArguments, | 68 Map<String,dynamic> this._namedArguments, |
| 66 [List existingArgumentNames = null]) | 69 [List existingArgumentNames = null]) |
| 67 : this._existingArgumentNames = existingArgumentNames; | 70 : this._existingArgumentNames = existingArgumentNames; |
| 68 | 71 |
| 69 | 72 |
| 70 String _developerMessage(args_mismatch) { | 73 String _developerMessage(args_mismatch) { |
| 71 if (_invocation_type < 0) { | 74 if (_invocation_type < 0) { |
| 72 return ""; | 75 return ""; |
| 73 } | 76 } |
| 74 var type = _invocation_type & _InvocationMirror._TYPE_MASK; | 77 var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
| 75 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & | 78 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
| 76 _InvocationMirror._CALL_MASK; | 79 _InvocationMirror._CALL_MASK; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 "NoSuchMethodError: incorrect number of arguments passed to " | 166 "NoSuchMethodError: incorrect number of arguments passed to " |
| 164 "method named '$_memberName'\n" | 167 "method named '$_memberName'\n" |
| 165 "Receiver: $receiver_str\n" | 168 "Receiver: $receiver_str\n" |
| 166 "Tried calling: $_memberName($actualParameters)\n" | 169 "Tried calling: $_memberName($actualParameters)\n" |
| 167 "Found: $_memberName($formalParameters)"); | 170 "Found: $_memberName($formalParameters)"); |
| 168 } | 171 } |
| 169 return msg_buf.toString(); | 172 return msg_buf.toString(); |
| 170 } | 173 } |
| 171 } | 174 } |
| 172 | 175 |
| 173 class _FiftyThreeBitOverflowError implements Error { | 176 class _FiftyThreeBitOverflowError extends Error { |
| 174 final Object _value; | 177 final Object _value; |
| 175 | 178 |
| 176 const _FiftyThreeBitOverflowError(this._value); | 179 _FiftyThreeBitOverflowError(this._value); |
| 177 String toString() => "53-bit Overflow: $_value"; | 180 String toString() => "53-bit Overflow: $_value"; |
| 178 } | 181 } |
| OLD | NEW |