| 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) => _callMethod(obj, '_get', null, JS('', '[#]', index), '[]')
; |
| 316 | 316 |
| 317 dsetindex(obj, index, value) => | 317 dsetindex(obj, index, value) => |
| 318 _callMethod(obj, 'set', null, JS('', '[#, #]', index, value), '[]='); | 318 _callMethod(obj, '_set', null, JS('', '[#, #]', index, value), '[]='); |
| 319 | 319 |
| 320 /// TODO(leafp): This duplicates code in types.dart. | 320 /// TODO(leafp): This duplicates code in types.dart. |
| 321 /// I haven't found a way to factor it out that makes the | 321 /// I haven't found a way to factor it out that makes the |
| 322 /// code generator happy though. | 322 /// code generator happy though. |
| 323 _ignoreMemo(f) => JS( | 323 _ignoreMemo(f) => JS( |
| 324 '', | 324 '', |
| 325 '''(() => { | 325 '''(() => { |
| 326 let memo = new Map(); | 326 let memo = new Map(); |
| 327 return (t1, t2) => { | 327 return (t1, t2) => { |
| 328 let map = memo.get(t1); | 328 let map = memo.get(t1); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 map(values, [K, V]) => JS( | 528 map(values, [K, V]) => JS( |
| 529 '', | 529 '', |
| 530 '''(() => { | 530 '''(() => { |
| 531 if ($K == null) $K = $dynamic; | 531 if ($K == null) $K = $dynamic; |
| 532 if ($V == null) $V = $dynamic; | 532 if ($V == null) $V = $dynamic; |
| 533 let map = ${getGenericClass(LinkedHashMap)}($K, $V).new(); | 533 let map = ${getGenericClass(LinkedHashMap)}($K, $V).new(); |
| 534 if (Array.isArray($values)) { | 534 if (Array.isArray($values)) { |
| 535 for (let i = 0, end = $values.length - 1; i < end; i += 2) { | 535 for (let i = 0, end = $values.length - 1; i < end; i += 2) { |
| 536 let key = $values[i]; | 536 let key = $values[i]; |
| 537 let value = $values[i + 1]; | 537 let value = $values[i + 1]; |
| 538 map.set(key, value); | 538 map._set(key, value); |
| 539 } | 539 } |
| 540 } else if (typeof $values === 'object') { | 540 } else if (typeof $values === 'object') { |
| 541 for (let key of $getOwnPropertyNames($values)) { | 541 for (let key of $getOwnPropertyNames($values)) { |
| 542 map.set(key, $values[key]); | 542 map._set(key, $values[key]); |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 return map; | 545 return map; |
| 546 })()'''); | 546 })()'''); |
| 547 | 547 |
| 548 @JSExportName('assert') | 548 @JSExportName('assert') |
| 549 assert_(condition) => JS( | 549 assert_(condition) => JS( |
| 550 '', | 550 '', |
| 551 '''(() => { | 551 '''(() => { |
| 552 if (!$condition) $throwAssertionError(); | 552 if (!$condition) $throwAssertionError(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 if (obj != null && getExtensionType(obj) != null) { | 838 if (obj != null && getExtensionType(obj) != null) { |
| 839 return JS('', 'dartx.#', name); | 839 return JS('', 'dartx.#', name); |
| 840 } | 840 } |
| 841 | 841 |
| 842 // Check for certain names that we can't use in JS | 842 // Check for certain names that we can't use in JS |
| 843 if (name == 'constructor' || name == 'prototype') { | 843 if (name == 'constructor' || name == 'prototype') { |
| 844 name = '+' + name; | 844 name = '+' + name; |
| 845 } | 845 } |
| 846 return name; | 846 return name; |
| 847 } | 847 } |
| OLD | NEW |