Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: dart/frog/leg/lib/js_helper.dart

Issue 9474040: Improve exception handling: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add TODO Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/frog/leg/emitter.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // TODO(ahe): ex.type is Chrome specific.
1247 var type = JS('String', @'$0.type', ex);
1248 var jsArguments = JS('Object', @'$0.arguments', ex);
1249 var name = jsArguments[0];
1250 if (type == 'property_not_function' ||
1251 type == 'called_non_callable' ||
1252 type == 'non_object_property_call' ||
1253 type == 'non_object_property_load') {
1254 if (name !== null && name.startsWith(@'$call$')) {
1255 return new ObjectNotClosureException();
1256 } else {
1257 return new NullPointerException();
1258 }
1259 } else if (type == 'undefined_method') {
1260 if (name is String && name.startsWith(@'$call$')) {
1261 return new ObjectNotClosureException();
1262 } else {
1263 return new NoSuchMethodException('', name, []);
1264 }
1265 }
1266 } else if (JS('bool', @'$0 instanceof RangeError', ex)) {
1267 var message = JS('String', @'$0.message', ex);
1268 if (message.contains('call stack')) {
1269 return new StackOverflowException();
1270 }
1271 }
1272 return ex;
1273 }
OLDNEW
« no previous file with comments | « dart/frog/leg/emitter.dart ('k') | dart/frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698