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

Side by Side Diff: lib/runtime/_operations.js

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: format fix Created 5 years, 5 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
« no previous file with comments | « no previous file | lib/runtime/dart/_interceptors.js » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /* This library defines runtime operations on objects used by the code 5 /* This library defines runtime operations on objects used by the code
6 * generator. 6 * generator.
7 */ 7 */
8 dart_library.library('dart_runtime/_operations', null, /* Imports */[ 8 dart_library.library('dart_runtime/_operations', null, /* Imports */[
9 ], /* Lazy Imports */[ 9 ], /* Lazy Imports */[
10 'dart/async', 10 'dart/async',
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 return map; 263 return map;
264 } 264 }
265 exports.map = map; 265 exports.map = map;
266 266
267 function assert(condition) { 267 function assert(condition) {
268 if (!condition) errors.throwAssertionError(); 268 if (!condition) errors.throwAssertionError();
269 } 269 }
270 exports.assert = assert; 270 exports.assert = assert;
271 271
272 function throw_(obj) { throw obj; } 272 let _stack = Symbol('_stack');
273 exports.throw_ = throw_;
274 273
274 function throw_(obj) {
275 obj[_stack] = new Error();
276 throw obj;
277 }
278 exports.throw = throw_;
279
280 function getError(exception) {
281 return exception[_stack] ? exception[_stack] : exception;
282 }
283
284 // This is a utility function: it is only intended to be called from dev
285 // tools.
286 function stackPrint(exception) {
287 var error = getError(exception);
288 console.log(error.stack ? error.stack : 'No stack trace for: ' + error);
289 }
290 exports.stackPrint = stackPrint;
275 291
276 function stackTrace(exception) { 292 function stackTrace(exception) {
277 return _js_helper.getTraceFromException(exception); 293 var error = getError(exception);
294 return _js_helper.getTraceFromException(error);
278 } 295 }
279 exports.stackTrace = stackTrace; 296 exports.stackTrace = stackTrace;
280 297
281 let _value = Symbol('_value'); 298 let _value = Symbol('_value');
282 /** 299 /**
283 * Looks up a sequence of [keys] in [map], recursively, and 300 * Looks up a sequence of [keys] in [map], recursively, and
284 * returns the result. If the value is not found, [valueFn] will be called to 301 * returns the result. If the value is not found, [valueFn] will be called to
285 * add it. For example: 302 * add it. For example:
286 * 303 *
287 * let map = new Map(); 304 * let map = new Map();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 next() { 406 next() {
390 let i = this.dartIterator; 407 let i = this.dartIterator;
391 let done = !i.moveNext(); 408 let done = !i.moveNext();
392 return { done: done, value: done ? void 0 : i.current }; 409 return { done: done, value: done ? void 0 : i.current };
393 } 410 }
394 } 411 }
395 exports.JsIterator = JsIterator; 412 exports.JsIterator = JsIterator;
396 413
397 414
398 }); 415 });
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart/_interceptors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698