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 import 'dart:mirrors' show MirrorSystem; |
| 6 |
5 patch class Error { | 7 patch class Error { |
6 /* patch */ static String _objectToString(Object object) { | 8 /* patch */ static String _objectToString(Object object) { |
7 return Object._toString(object); | 9 return Object._toString(object); |
8 } | 10 } |
9 | 11 |
10 /* patch */ StackTrace get stackTrace => _stackTrace; | 12 /* patch */ StackTrace get stackTrace => _stackTrace; |
11 | 13 |
12 StackTrace _stackTrace; | 14 StackTrace _stackTrace; |
13 } | 15 } |
14 | 16 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return ""; | 211 return ""; |
210 } | 212 } |
211 var type = _invocation_type & _InvocationMirror._TYPE_MASK; | 213 var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
212 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & | 214 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
213 _InvocationMirror._CALL_MASK; | 215 _InvocationMirror._CALL_MASK; |
214 var type_str = | 216 var type_str = |
215 (const ["method", "getter", "setter", "getter or setter", "variable"])[t
ype]; | 217 (const ["method", "getter", "setter", "getter or setter", "variable"])[t
ype]; |
216 var args_message = args_mismatch ? " with matching arguments" : ""; | 218 var args_message = args_mismatch ? " with matching arguments" : ""; |
217 var msg; | 219 var msg; |
218 var memberName = | 220 var memberName = |
219 (_memberName == null) ? "" : internal.Symbol.getName(_memberName); | 221 (_memberName == null) ? "" : MirrorSystem.getName(_memberName); |
220 | 222 |
221 if (type == _InvocationMirror._LOCAL_VAR) { | 223 if (type == _InvocationMirror._LOCAL_VAR) { |
222 return "cannot assign to final variable '$memberName'.\n\n"; | 224 return "cannot assign to final variable '$memberName'.\n\n"; |
223 } | 225 } |
224 switch (level) { | 226 switch (level) { |
225 case _InvocationMirror._DYNAMIC: { | 227 case _InvocationMirror._DYNAMIC: { |
226 if (_receiver == null) { | 228 if (_receiver == null) { |
227 msg = "The null object does not have a $type_str '$memberName'" | 229 msg = "The null object does not have a $type_str '$memberName'" |
228 "$args_message."; | 230 "$args_message."; |
229 } else { | 231 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 actual_buf.write(", "); | 275 actual_buf.write(", "); |
274 } | 276 } |
275 actual_buf.write(Error.safeToString(_arguments[i])); | 277 actual_buf.write(Error.safeToString(_arguments[i])); |
276 } | 278 } |
277 } | 279 } |
278 if (_namedArguments != null) { | 280 if (_namedArguments != null) { |
279 _namedArguments.forEach((Symbol key, var value) { | 281 _namedArguments.forEach((Symbol key, var value) { |
280 if (i > 0) { | 282 if (i > 0) { |
281 actual_buf.write(", "); | 283 actual_buf.write(", "); |
282 } | 284 } |
283 actual_buf.write(internal.Symbol.getName(key)); | 285 actual_buf.write(MirrorSystem.getName(key)); |
284 actual_buf.write(": "); | 286 actual_buf.write(": "); |
285 actual_buf.write(Error.safeToString(value)); | 287 actual_buf.write(Error.safeToString(value)); |
286 i++; | 288 i++; |
287 }); | 289 }); |
288 } | 290 } |
289 var args_mismatch = _existingArgumentNames != null; | 291 var args_mismatch = _existingArgumentNames != null; |
290 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); | 292 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); |
291 String receiver_str; | 293 String receiver_str; |
292 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & | 294 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
293 _InvocationMirror._CALL_MASK; | 295 _InvocationMirror._CALL_MASK; |
294 if ( level == _InvocationMirror._TOP_LEVEL) { | 296 if ( level == _InvocationMirror._TOP_LEVEL) { |
295 receiver_str = "top-level"; | 297 receiver_str = "top-level"; |
296 } else { | 298 } else { |
297 receiver_str = Error.safeToString(_receiver); | 299 receiver_str = Error.safeToString(_receiver); |
298 } | 300 } |
299 var memberName = | 301 var memberName = |
300 (_memberName == null) ? "" : internal.Symbol.getName(_memberName); | 302 (_memberName == null) ? "" : MirrorSystem.getName(_memberName); |
301 var type = _invocation_type & _InvocationMirror._TYPE_MASK; | 303 var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
302 if (type == _InvocationMirror._LOCAL_VAR) { | 304 if (type == _InvocationMirror._LOCAL_VAR) { |
303 msg_buf.write( | 305 msg_buf.write( |
304 "NoSuchMethodError: cannot assign to final variable '$memberName'"); | 306 "NoSuchMethodError: cannot assign to final variable '$memberName'"); |
305 } else if (!args_mismatch) { | 307 } else if (!args_mismatch) { |
306 msg_buf.write( | 308 msg_buf.write( |
307 "NoSuchMethodError: method not found: '$memberName'\n" | 309 "NoSuchMethodError: method not found: '$memberName'\n" |
308 "Receiver: $receiver_str\n" | 310 "Receiver: $receiver_str\n" |
309 "Arguments: [$actual_buf]"); | 311 "Arguments: [$actual_buf]"); |
310 } else { | 312 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
335 String toString() => "Javascript Integer Overflow: $_value"; | 337 String toString() => "Javascript Integer Overflow: $_value"; |
336 } | 338 } |
337 | 339 |
338 class _JavascriptCompatibilityError extends Error { | 340 class _JavascriptCompatibilityError extends Error { |
339 final String _msg; | 341 final String _msg; |
340 | 342 |
341 _JavascriptCompatibilityError(this._msg); | 343 _JavascriptCompatibilityError(this._msg); |
342 String toString() => "Javascript Compatibility Error: $_msg"; | 344 String toString() => "Javascript Compatibility Error: $_msg"; |
343 } | 345 } |
344 | 346 |
OLD | NEW |