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 part of dart._runtime; | 7 part of dart._runtime; |
| 8 | 8 |
| 9 class InvocationImpl extends Invocation { | 9 class InvocationImpl extends Invocation { |
| 10 final Symbol memberName; | 10 final Symbol memberName; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 var f = obj != null ? JS('', '#[#]', obj, symbol) : null; | 305 var f = obj != null ? JS('', '#[#]', obj, symbol) : null; |
| 306 var ftype = getMethodType(obj, symbol); | 306 var ftype = getMethodType(obj, symbol); |
| 307 return _checkAndCall(f, ftype, obj, typeArgs, args, displayName); | 307 return _checkAndCall(f, ftype, obj, typeArgs, args, displayName); |
| 308 } | 308 } |
| 309 | 309 |
| 310 dsend(obj, method, @rest args) => _callMethod(obj, method, null, args, method); | 310 dsend(obj, method, @rest args) => _callMethod(obj, method, null, args, method); |
| 311 | 311 |
| 312 dgsend(obj, typeArgs, method, @rest args) => | 312 dgsend(obj, typeArgs, method, @rest args) => |
| 313 _callMethod(obj, method, typeArgs, args, method); | 313 _callMethod(obj, method, typeArgs, args, method); |
| 314 | 314 |
| 315 dindex(obj, index) => _callMethod(obj, '_get', null, JS('', '[#]', index), '[]') ; | 315 dindex(obj, index) => |
| 316 _callMethod(obj, '_get', null, JS('', '[#]', index), '[]'); | |
| 316 | 317 |
| 317 dsetindex(obj, index, value) => | 318 dsetindex(obj, index, value) => |
| 318 _callMethod(obj, '_set', null, JS('', '[#, #]', index, value), '[]='); | 319 _callMethod(obj, '_set', null, JS('', '[#, #]', index, value), '[]='); |
| 319 | 320 |
| 320 /// TODO(leafp): This duplicates code in types.dart. | 321 /// TODO(leafp): This duplicates code in types.dart. |
| 321 /// I haven't found a way to factor it out that makes the | 322 /// I haven't found a way to factor it out that makes the |
| 322 /// code generator happy though. | 323 /// code generator happy though. |
| 323 _ignoreMemo(f) => JS( | 324 _ignoreMemo(f) => JS( |
| 324 '', | 325 '', |
| 325 '''(() => { | 326 '''(() => { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 map._set(key, $values[key]); | 543 map._set(key, $values[key]); |
| 543 } | 544 } |
| 544 } | 545 } |
| 545 return map; | 546 return map; |
| 546 })()'''); | 547 })()'''); |
| 547 | 548 |
| 548 @JSExportName('assert') | 549 @JSExportName('assert') |
| 549 assert_(condition) => JS( | 550 assert_(condition) => JS( |
| 550 '', | 551 '', |
| 551 '''(() => { | 552 '''(() => { |
| 552 if (!$condition) $throwAssertionError(); | 553 if (!$condition) $throwAssertionError(); |
|
Jennifer Messerly
2016/12/12 22:36:02
here's how I would change this:
assert_(condition
Bob Nystrom
2016/12/13 19:29:51
Done.
| |
| 553 })()'''); | 554 })()'''); |
| 554 | 555 |
| 556 @JSExportName('assertMessage') | |
| 557 assertMessage_(condition, message) => JS( | |
|
Jennifer Messerly
2016/12/12 22:36:02
this can be removed per earlier suggestions
Bob Nystrom
2016/12/13 19:29:51
Done.
| |
| 558 '', | |
| 559 '''(() => { | |
| 560 if (!$condition) $throwAssertionErrorWithMessage(message()); | |
| 561 })()'''); | |
| 562 | |
| 555 var _stack = null; | 563 var _stack = null; |
| 556 @JSExportName('throw') | 564 @JSExportName('throw') |
| 557 throw_(obj) => JS( | 565 throw_(obj) => JS( |
| 558 '', | 566 '', |
| 559 '''(() => { | 567 '''(() => { |
| 560 $_stack = new Error(); | 568 $_stack = new Error(); |
| 561 throw $obj; | 569 throw $obj; |
| 562 })()'''); | 570 })()'''); |
| 563 | 571 |
| 564 getError(exception) => JS( | 572 getError(exception) => JS( |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 name = '+' + name; | 848 name = '+' + name; |
| 841 } | 849 } |
| 842 return name; | 850 return name; |
| 843 } | 851 } |
| 844 | 852 |
| 845 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 853 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
| 846 /// | 854 /// |
| 847 /// Libraries are not actually deferred in DDC, so this just returns a future | 855 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 848 /// that completes immediately. | 856 /// that completes immediately. |
| 849 Future loadLibrary() => new Future.value(); | 857 Future loadLibrary() => new Future.value(); |
| OLD | NEW |