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 #library('js_helper'); | 5 #library('js_helper'); |
| 6 | 6 |
| 7 #import('coreimpl.dart'); | 7 #import('coreimpl.dart'); |
| 8 | 8 |
| 9 #source('date_helper.dart'); | 9 #source('date_helper.dart'); |
| 10 #source('regexp_helper.dart'); | 10 #source('regexp_helper.dart'); |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 result[i] = receiver.charCodeAt(i); | 1222 result[i] = receiver.charCodeAt(i); |
| 1223 } | 1223 } |
| 1224 return result; | 1224 return result; |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 makeLiteralListConst(list) { | 1227 makeLiteralListConst(list) { |
| 1228 JS('bool', @'$0.immutable$list = $1', list, true); | 1228 JS('bool', @'$0.immutable$list = $1', list, true); |
| 1229 JS('bool', @'$0.fixed$length = $1', list, true); | 1229 JS('bool', @'$0.fixed$length = $1', list, true); |
| 1230 return list; | 1230 return list; |
| 1231 } | 1231 } |
| 1232 | |
| 1233 /** | |
| 1234 * Called from catch blocks in generated code to extract the Dart | |
| 1235 * exception from the thrown value. The thrown value may have been | |
| 1236 * created by [captureStackTrace] or it may be a "native" JS | |
| 1237 * exception. | |
| 1238 * | |
| 1239 * Some native exceptions are mapped to new Dart instances, others are | |
| 1240 * returned unmodified. | |
| 1241 */ | |
| 1242 unwrapException(ex) { | |
| 1243 if (JS('bool', @'"dartException" in $0', ex)) { | |
| 1244 return JS('Object', @'$0.dartException', ex); | |
| 1245 } else if (JS('bool', @'$0 instanceof TypeError', ex)) { | |
| 1246 var type = JS('String', @'$0.type', ex); | |
|
kasperl
2012/02/28 09:22:11
This (ex.type) is very Chrome specific code. Maybe
ahe
2012/02/28 16:25:53
Done.
| |
| 1247 var jsArguments = JS('Object', @'$0.arguments', ex); | |
| 1248 var name = jsArguments[0]; | |
| 1249 if (type == 'property_not_function' || | |
| 1250 type == 'called_non_callable' || | |
| 1251 type == 'non_object_property_call' || | |
| 1252 type == 'non_object_property_load') { | |
| 1253 if (name !== null && name.startsWith(@'$call$')) { | |
| 1254 return new ObjectNotClosureException(); | |
| 1255 } else { | |
| 1256 return new NullPointerException(); | |
| 1257 } | |
| 1258 } else if (type == 'undefined_method') { | |
| 1259 if (name is String && name.startsWith(@'$call$')) { | |
| 1260 return new ObjectNotClosureException(); | |
| 1261 } else { | |
| 1262 return new NoSuchMethodException('', name, []); | |
| 1263 } | |
| 1264 } | |
| 1265 } else if (JS('bool', @'$0 instanceof RangeError', ex)) { | |
| 1266 var message = JS('String', @'$0.message', ex); | |
| 1267 if (message.contains('call stack')) { | |
| 1268 return new StackOverflowException(); | |
| 1269 } | |
| 1270 } | |
| 1271 return ex; | |
| 1272 } | |
| OLD | NEW |