Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 tools . | |
|
Jennifer Messerly
2015/07/14 18:30:33
long line.
Maybe we need a module of debug utils?
| |
| 285 function stackPrint(exception) { | |
| 286 var error = getError(exception); | |
| 287 console.log(error.stack ? error.stack : 'No stack trace for: ' + error); | |
|
Jennifer Messerly
2015/07/14 18:30:33
is this different from _js_helper.getTraceFromExce
| |
| 288 } | |
| 289 exports.stackPrint = stackPrint; | |
| 275 | 290 |
| 276 function stackTrace(exception) { | 291 function stackTrace(exception) { |
| 277 return _js_helper.getTraceFromException(exception); | 292 var error = getError(exception); |
| 293 return _js_helper.getTraceFromException(error); | |
| 278 } | 294 } |
| 279 exports.stackTrace = stackTrace; | 295 exports.stackTrace = stackTrace; |
| 280 | 296 |
| 281 let _value = Symbol('_value'); | 297 let _value = Symbol('_value'); |
| 282 /** | 298 /** |
| 283 * Looks up a sequence of [keys] in [map], recursively, and | 299 * 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 | 300 * returns the result. If the value is not found, [valueFn] will be called to |
| 285 * add it. For example: | 301 * add it. For example: |
| 286 * | 302 * |
| 287 * let map = new Map(); | 303 * let map = new Map(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 next() { | 405 next() { |
| 390 let i = this.dartIterator; | 406 let i = this.dartIterator; |
| 391 let done = !i.moveNext(); | 407 let done = !i.moveNext(); |
| 392 return { done: done, value: done ? void 0 : i.current }; | 408 return { done: done, value: done ? void 0 : i.current }; |
| 393 } | 409 } |
| 394 } | 410 } |
| 395 exports.JsIterator = JsIterator; | 411 exports.JsIterator = JsIterator; |
| 396 | 412 |
| 397 | 413 |
| 398 }); | 414 }); |
| OLD | NEW |