Chromium Code Reviews| Index: dart/runtime/lib/mirrors_impl.dart |
| diff --git a/dart/runtime/lib/mirrors_impl.dart b/dart/runtime/lib/mirrors_impl.dart |
| index ef95c2be15e7ef9f0b59f1c6d3c628511e4af3ca..1e50da1a7fb04c0cbfaea7fa4c1fa22184506546 100644 |
| --- a/dart/runtime/lib/mirrors_impl.dart |
| +++ b/dart/runtime/lib/mirrors_impl.dart |
| @@ -249,55 +249,6 @@ abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl |
| native 'LocalObjectMirrorImpl_setField'; |
| } |
| -// Prints a string as it might appear in dart program text. |
| -// TODO(turnidge): Consider truncating. |
| -String _dartEscape(String str) { |
|
ahe
2013/06/12 16:27:26
I have requested something like this gets integrat
|
| - bool isNice(int code) => (code >= 32 && code <= 126); |
| - |
| - StringBuffer buf = new StringBuffer(); |
| - for (int i = 0; i < str.length; i++) { |
| - var input = str[i]; |
| - String output; |
| - switch (input) { |
| - case '\\' : |
| - output = r'\\'; |
| - break; |
| - case "\'" : |
| - output = r"\'"; |
| - break; |
| - case '\n' : |
| - output = r'\n'; |
| - break; |
| - case '\r' : |
| - output = r'\r'; |
| - break; |
| - case '\f' : |
| - output = r'\f'; |
| - break; |
| - case '\b' : |
| - output = r'\b'; |
| - break; |
| - case '\t' : |
| - output = r'\t'; |
| - break; |
| - case '\v' : |
| - output = r'\v'; |
| - break; |
| - default: |
| - // TODO(lrn): Someone decide if this should combine surrogate pairs. |
| - int code = input.codeUnitAt(0); |
| - if (isNice(code)) { |
| - output = input; |
| - } else { |
| - output = '\\u{${code.toRadixString(16)}}'; |
| - } |
| - break; |
| - } |
| - buf.write(output); |
| - } |
| - return buf.toString(); |
| -} |
| - |
| class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl |
| implements InstanceMirror { |
| // TODO(ahe): This is a hack, see delegate below. |
| @@ -336,17 +287,7 @@ class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl |
| return _invokeOnClosure(reflectee, invocation); |
| } |
| - String toString() { |
| - if (_isSimpleValue(_reflectee)) { |
| - if (_reflectee is String) { |
| - return "InstanceMirror on <'${_dartEscape(_reflectee)}'>"; |
| - } else { |
| - return "InstanceMirror on <$_reflectee>"; |
| - } |
| - } else { |
| - return "InstanceMirror on instance of '${type.simpleName}'"; |
| - } |
| - } |
| + String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; |
| } |
| class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl |
| @@ -398,6 +339,8 @@ class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl |
| static _apply(ref, positionalArguments, async) |
| native 'LocalClosureMirrorImpl_apply'; |
| + |
| + String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; |
| } |
| class _LazyTypeMirror { |
| @@ -564,7 +507,10 @@ class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| 'ClassMirror.originalDeclaration is not implemented'); |
| } |
| - String toString() => "ClassMirror on '$simpleName'"; |
| + String toString() { |
| + String prettyName = isClass ? 'ClassMirror' : 'TypeMirror'; |
| + return "$prettyName on '${_n(simpleName)}'"; |
| + } |
| InstanceMirror newInstance(Symbol constructorName, |
| List positionalArguments, |
| @@ -645,7 +591,7 @@ class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl |
| final List<ParameterMirror> parameters; |
| - String toString() => "FunctionTypeMirror on '$simpleName'"; |
| + String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; |
| } |
| @@ -704,7 +650,7 @@ class _LocalTypeVariableMirrorImpl extends _LocalMirrorImpl |
| return _upperBound; |
| } |
| - String toString() => "TypeVariableMirror on '$simpleName'"; |
| + String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; |
| } |
| @@ -750,7 +696,7 @@ class _LocalTypedefMirrorImpl extends _LocalMirrorImpl |
| return _referent; |
| } |
| - String toString() => "TypedefMirror on '$simpleName'"; |
| + String toString() => "TypedefMirror on '${_n(simpleName)}'"; |
| } |
| @@ -843,7 +789,7 @@ class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
| return _variables; |
| } |
| - String toString() => "LibraryMirror on '$simpleName'"; |
| + String toString() => "LibraryMirror on '${_n(simpleName)}'"; |
| } |
| class _LocalMethodMirrorImpl extends _LocalMirrorImpl |
| @@ -943,7 +889,7 @@ class _LocalMethodMirrorImpl extends _LocalMirrorImpl |
| final bool isRedirectingConstructor; |
| final bool isFactoryConstructor; |
| - String toString() => "MethodMirror on '$simpleName'"; |
| + String toString() => "MethodMirror on '${_n(simpleName)}'"; |
| } |
| class _LocalVariableMirrorImpl extends _LocalMirrorImpl |
| @@ -997,7 +943,7 @@ class _LocalVariableMirrorImpl extends _LocalMirrorImpl |
| final bool isStatic; |
| final bool isFinal; |
| - String toString() => "VariableMirror on '$simpleName'"; |
| + String toString() => "VariableMirror on '${_n(simpleName)}'"; |
| } |
| class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |