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

Side by Side Diff: frog/corejs.dart

Issue 8574066: Add a test for "is Object", fix try-catch of null (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: frogsh, status Created 9 years, 1 month 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 | « no previous file | frog/frogsh » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** 5 /**
6 * Generates JS helpers for dart:core. This used to be in a file "core.js". 6 * Generates JS helpers for dart:core. This used to be in a file "core.js".
7 * Having them in Dart code means we can easily control which are generated. 7 * Having them in Dart code means we can easily control which are generated.
8 */ 8 */
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native"
10 // methods somewhere in a library that we import. This would be rather elegant 10 // methods somewhere in a library that we import. This would be rather elegant
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}'; 236 var f = 'function(' + a.join(',') + '){return $f(' + p.join(',') + ');}';
237 return new Function('$f', 'return ' + f + '').call(null, this); 237 return new Function('$f', 'return ' + f + '').call(null, this);
238 }"""); 238 }""");
239 } 239 }
240 240
241 if (useStackTraceOf) { 241 if (useStackTraceOf) {
242 w.writeln(@""" 242 w.writeln(@"""
243 function $stackTraceOf(e) { 243 function $stackTraceOf(e) {
244 // TODO(jmesserly): we shouldn't be relying on the e.stack property. 244 // TODO(jmesserly): we shouldn't be relying on the e.stack property.
245 // Need to mangle it. 245 // Need to mangle it.
246 return e.stack ? e.stack : null; 246 return (e && e.stack) ? e.stack : null;
247 }"""); 247 }""");
248 } 248 }
249 249
250 if (useToDartException) { 250 if (useToDartException) {
251 w.writeln(@""" 251 w.writeln(@"""
252 // Translate a JavaScript exception to a Dart exception 252 // Translate a JavaScript exception to a Dart exception
253 // TODO(jmesserly): cross browser support. This is Chrome specific. 253 // TODO(jmesserly): cross browser support. This is Chrome specific.
254 function $toDartException(e) { 254 function $toDartException(e) {
255 var res = e; 255 var res = e;
256 if (e instanceof TypeError) { 256 if (e instanceof TypeError) {
(...skipping 17 matching lines...) Expand all
274 // TODO(jmesserly): can this ever happen? 274 // TODO(jmesserly): can this ever happen?
275 res = new NoSuchMethodException('', e.arguments[0], []); 275 res = new NoSuchMethodException('', e.arguments[0], []);
276 } 276 }
277 break; 277 break;
278 } 278 }
279 } else if (e instanceof RangeError) { 279 } else if (e instanceof RangeError) {
280 if (e.message.indexOf('call stack') >= 0) { 280 if (e.message.indexOf('call stack') >= 0) {
281 res = new StackOverflowException(); 281 res = new StackOverflowException();
282 } 282 }
283 } 283 }
284 // TODO(jmesserly): setting the stack property is not a long term solution. 284 if (res) {
285 // Also it causes the exception to print as if it were a TypeError or 285 // TODO(jmesserly): setting the stack property is not a long term solution.
286 // RangeError, instead of using the proper toString. 286 // Also it causes the exception to print as if it were a JS TypeError or
287 res.stack = e.stack; 287 // RangeError, instead of using the proper toString.
288 res.stack = e.stack;
289 }
288 return res; 290 return res;
289 }"""); 291 }""");
290 } 292 }
291 293
292 if (useNotNullBool) { 294 if (useNotNullBool) {
293 useThrow = true; 295 useThrow = true;
294 // This pattern chosen because IE9 does really badly with typeof, and 296 // This pattern chosen because IE9 does really badly with typeof, and
295 // it's still decent on other browsers. 297 // it's still decent on other browsers.
296 w.writeln(@""" 298 w.writeln(@"""
297 function $notnull_bool(test) { 299 function $notnull_bool(test) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 w.writeln(@"function $wrap_call$1(fn) { return fn; }"); 433 w.writeln(@"function $wrap_call$1(fn) { return fn; }");
432 } 434 }
433 } 435 }
434 436
435 // Write operator helpers 437 // Write operator helpers
436 for (var opImpl in orderValuesByKeys(_usedOperators)) { 438 for (var opImpl in orderValuesByKeys(_usedOperators)) {
437 w.writeln(opImpl); 439 w.writeln(opImpl);
438 } 440 }
439 } 441 }
440 } 442 }
OLDNEW
« no previous file with comments | « no previous file | frog/frogsh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698