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; | 5 import 'dart:_internal' as internal; |
6 import 'dart:convert' show JSON; | 6 import 'dart:convert' show JSON; |
7 | 7 |
8 patch class Error { | 8 patch class Error { |
9 /* patch */ static String _objectToString(Object object) { | 9 /* patch */ static String _objectToString(Object object) { |
10 return Object._toString(object); | 10 return Object._toString(object); |
11 } | 11 } |
12 | 12 |
13 /* patch */ static String _stringToSafeString(String string) { | 13 /* patch */ static String _stringToSafeString(String string) { |
14 return JSON.encode(string); | 14 return JSON.encode(string); |
15 } | 15 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 return ""; | 219 return ""; |
220 } | 220 } |
221 var type = _invocation_type & _InvocationMirror._TYPE_MASK; | 221 var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
222 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & | 222 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
223 _InvocationMirror._CALL_MASK; | 223 _InvocationMirror._CALL_MASK; |
224 var type_str = | 224 var type_str = |
225 (const ["method", "getter", "setter", "getter or setter", "variable"])[t
ype]; | 225 (const ["method", "getter", "setter", "getter or setter", "variable"])[t
ype]; |
226 var args_message = args_mismatch ? " with matching arguments" : ""; | 226 var args_message = args_mismatch ? " with matching arguments" : ""; |
227 var msg; | 227 var msg; |
228 var memberName = | 228 var memberName = |
229 (_memberName == null) ? "" : MirrorSystem.getName(_memberName); | 229 (_memberName == null) ? "" : internal.Symbol.getUnmangledName(_memberNam
e); |
230 | 230 |
231 if (type == _InvocationMirror._LOCAL_VAR) { | 231 if (type == _InvocationMirror._LOCAL_VAR) { |
232 return "cannot assign to final variable '$memberName'.\n\n"; | 232 return "cannot assign to final variable '$memberName'.\n\n"; |
233 } | 233 } |
234 switch (level) { | 234 switch (level) { |
235 case _InvocationMirror._DYNAMIC: { | 235 case _InvocationMirror._DYNAMIC: { |
236 if (_receiver == null) { | 236 if (_receiver == null) { |
237 msg = "The null object does not have a $type_str '$memberName'" | 237 msg = "The null object does not have a $type_str '$memberName'" |
238 "$args_message."; | 238 "$args_message."; |
239 } else { | 239 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 actual_buf.write(", "); | 283 actual_buf.write(", "); |
284 } | 284 } |
285 actual_buf.write(Error.safeToString(_arguments[i])); | 285 actual_buf.write(Error.safeToString(_arguments[i])); |
286 } | 286 } |
287 } | 287 } |
288 if (_namedArguments != null) { | 288 if (_namedArguments != null) { |
289 _namedArguments.forEach((Symbol key, var value) { | 289 _namedArguments.forEach((Symbol key, var value) { |
290 if (i > 0) { | 290 if (i > 0) { |
291 actual_buf.write(", "); | 291 actual_buf.write(", "); |
292 } | 292 } |
293 actual_buf.write(MirrorSystem.getName(key)); | 293 actual_buf.write(internal.Symbol.getUnmangledName(key)); |
294 actual_buf.write(": "); | 294 actual_buf.write(": "); |
295 actual_buf.write(Error.safeToString(value)); | 295 actual_buf.write(Error.safeToString(value)); |
296 i++; | 296 i++; |
297 }); | 297 }); |
298 } | 298 } |
299 var args_mismatch = _existingArgumentNames != null; | 299 var args_mismatch = _existingArgumentNames != null; |
300 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); | 300 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); |
301 String receiver_str; | 301 String receiver_str; |
302 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & | 302 var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
303 _InvocationMirror._CALL_MASK; | 303 _InvocationMirror._CALL_MASK; |
304 if ( level == _InvocationMirror._TOP_LEVEL) { | 304 if ( level == _InvocationMirror._TOP_LEVEL) { |
305 receiver_str = "top-level"; | 305 receiver_str = "top-level"; |
306 } else { | 306 } else { |
307 receiver_str = Error.safeToString(_receiver); | 307 receiver_str = Error.safeToString(_receiver); |
308 } | 308 } |
309 var memberName = | 309 var memberName = |
310 (_memberName == null) ? "" : MirrorSystem.getName(_memberName); | 310 (_memberName == null) ? "" : internal.Symbol.getUnmangledName(_memberNam
e); |
311 var type = _invocation_type & _InvocationMirror._TYPE_MASK; | 311 var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
312 if (type == _InvocationMirror._LOCAL_VAR) { | 312 if (type == _InvocationMirror._LOCAL_VAR) { |
313 msg_buf.write( | 313 msg_buf.write( |
314 "NoSuchMethodError: cannot assign to final variable '$memberName'"); | 314 "NoSuchMethodError: cannot assign to final variable '$memberName'"); |
315 } else if (!args_mismatch) { | 315 } else if (!args_mismatch) { |
316 msg_buf.write( | 316 msg_buf.write( |
317 "NoSuchMethodError: method not found: '$memberName'\n" | 317 "NoSuchMethodError: method not found: '$memberName'\n" |
318 "Receiver: $receiver_str\n" | 318 "Receiver: $receiver_str\n" |
319 "Arguments: [$actual_buf]"); | 319 "Arguments: [$actual_buf]"); |
320 } else { | 320 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
345 String toString() => "Javascript Integer Overflow: $_value"; | 345 String toString() => "Javascript Integer Overflow: $_value"; |
346 } | 346 } |
347 | 347 |
348 class _JavascriptCompatibilityError extends Error { | 348 class _JavascriptCompatibilityError extends Error { |
349 final String _msg; | 349 final String _msg; |
350 | 350 |
351 _JavascriptCompatibilityError(this._msg); | 351 _JavascriptCompatibilityError(this._msg); |
352 String toString() => "Javascript Compatibility Error: $_msg"; | 352 String toString() => "Javascript Compatibility Error: $_msg"; |
353 } | 353 } |
354 | 354 |
OLD | NEW |