| 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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
| 6 | 6 |
| 7 // These values are allowed to be passed directly over the wire. | 7 // These values are allowed to be passed directly over the wire. |
| 8 bool _isSimpleValue(var value) { | 8 bool _isSimpleValue(var value) { |
| 9 return (value == null || value is num || value is String || value is bool); | 9 return (value == null || value is num || value is String || value is bool); |
| 10 } | 10 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // TODO(turnidge): Consider truncating. | 213 // TODO(turnidge): Consider truncating. |
| 214 String _dartEscape(String str) { | 214 String _dartEscape(String str) { |
| 215 bool isNice(int code) => (code >= 32 && code <= 126); | 215 bool isNice(int code) => (code >= 32 && code <= 126); |
| 216 | 216 |
| 217 StringBuffer buf = new StringBuffer(); | 217 StringBuffer buf = new StringBuffer(); |
| 218 for (int i = 0; i < str.length; i++) { | 218 for (int i = 0; i < str.length; i++) { |
| 219 var input = str[i]; | 219 var input = str[i]; |
| 220 String output; | 220 String output; |
| 221 switch (input) { | 221 switch (input) { |
| 222 case '\\' : | 222 case '\\' : |
| 223 output = @'\\'; | 223 output = r'\\'; |
| 224 break; | 224 break; |
| 225 case "\'" : | 225 case "\'" : |
| 226 output = @"\'"; | 226 output = r"\'"; |
| 227 break; | 227 break; |
| 228 case '\n' : | 228 case '\n' : |
| 229 output = @'\n'; | 229 output = r'\n'; |
| 230 break; | 230 break; |
| 231 case '\r' : | 231 case '\r' : |
| 232 output = @'\r'; | 232 output = r'\r'; |
| 233 break; | 233 break; |
| 234 case '\f' : | 234 case '\f' : |
| 235 output = @'\f'; | 235 output = r'\f'; |
| 236 break; | 236 break; |
| 237 case '\b' : | 237 case '\b' : |
| 238 output = @'\b'; | 238 output = r'\b'; |
| 239 break; | 239 break; |
| 240 case '\t' : | 240 case '\t' : |
| 241 output = @'\t'; | 241 output = r'\t'; |
| 242 break; | 242 break; |
| 243 case '\v' : | 243 case '\v' : |
| 244 output = @'\v'; | 244 output = r'\v'; |
| 245 break; | 245 break; |
| 246 default: | 246 default: |
| 247 int code = input.charCodeAt(0); | 247 int code = input.charCodeAt(0); |
| 248 if (isNice(code)) { | 248 if (isNice(code)) { |
| 249 output = input; | 249 output = input; |
| 250 } else { | 250 } else { |
| 251 output = '\\u{${code.toRadixString(16)}}'; | 251 output = '\\u{${code.toRadixString(16)}}'; |
| 252 } | 252 } |
| 253 break; | 253 break; |
| 254 } | 254 } |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 963 |
| 964 // Creates a new local InstanceMirror | 964 // Creates a new local InstanceMirror |
| 965 static InstanceMirror makeLocalInstanceMirror(Object reflectee) | 965 static InstanceMirror makeLocalInstanceMirror(Object reflectee) |
| 966 native 'Mirrors_makeLocalInstanceMirror'; | 966 native 'Mirrors_makeLocalInstanceMirror'; |
| 967 | 967 |
| 968 // Creates a new local mirror for some Object. | 968 // Creates a new local mirror for some Object. |
| 969 static InstanceMirror reflect(Object reflectee) { | 969 static InstanceMirror reflect(Object reflectee) { |
| 970 return makeLocalInstanceMirror(reflectee); | 970 return makeLocalInstanceMirror(reflectee); |
| 971 } | 971 } |
| 972 } | 972 } |
| OLD | NEW |