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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 case '_constructor': | 227 case '_constructor': |
228 case '_prototype': | 228 case '_prototype': |
229 return $name.substring(1); | 229 return $name.substring(1); |
230 } | 230 } |
231 } | 231 } |
232 return $name; | 232 return $name; |
233 })()'''); | 233 })()'''); |
234 | 234 |
235 Symbol _dartSymbol(name) { | 235 Symbol _dartSymbol(name) { |
236 return (JS('bool', 'typeof # === "symbol"', name)) | 236 return (JS('bool', 'typeof # === "symbol"', name)) |
237 ? JS('', '#(new #(#, #))', const_, _internal.PrivateSymbol, | 237 ? JS('Symbol', '#(new #.new(#, #))', const_, _internal.PrivateSymbol, |
238 _toSymbolName(name), name) | 238 _toSymbolName(name), name) |
239 : JS('', '#(#.new(#))', const_, Symbol, _toDisplayName(name)); | 239 : JS('Symbol', '#(#.new(#))', const_, Symbol, _toDisplayName(name)); |
240 } | 240 } |
241 | 241 |
242 /// Extracts the named argument array from a list of arguments, and returns it. | 242 /// Extracts the named argument array from a list of arguments, and returns it. |
243 // TODO(jmesserly): we need to handle named arguments better. | 243 // TODO(jmesserly): we need to handle named arguments better. |
244 extractNamedArgs(args) { | 244 extractNamedArgs(args) { |
245 if (JS('bool', '#.length > 0', args)) { | 245 if (JS('bool', '#.length > 0', args)) { |
246 var last = JS('', '#[#.length - 1]', args, args); | 246 var last = JS('', '#[#.length - 1]', args, args); |
247 if (JS( | 247 if (JS( |
248 'bool', '# != null && #.__proto__ === Object.prototype', last, last)) { | 248 'bool', '# != null && #.__proto__ === Object.prototype', last, last)) { |
249 return JS('', '#.pop()', args); | 249 return JS('', '#.pop()', args); |
250 } | 250 } |
251 } | 251 } |
252 return null; | 252 return null; |
253 } | 253 } |
254 | 254 |
255 _checkAndCall(f, ftype, obj, typeArgs, args, name) => JS( | 255 _checkAndCall(f, ftype, obj, typeArgs, args, name) => JS( |
256 '', | 256 '', |
257 '''(() => { | 257 '''(() => { |
258 $_trackCall($obj); | 258 $_trackCall($obj); |
259 | 259 |
260 let originalTarget = obj === void 0 ? f : obj; | 260 let originalTarget = obj === void 0 ? f : obj; |
261 | 261 |
262 function callNSM() { | 262 function callNSM() { |
263 return $noSuchMethod(originalTarget, new $InvocationImpl( | 263 return $noSuchMethod(originalTarget, new $InvocationImpl.new( |
264 $name, $args, | 264 $name, $args, |
265 {namedArguments: $extractNamedArgs($args), isMethod: true})); | 265 {namedArguments: $extractNamedArgs($args), isMethod: true})); |
266 } | 266 } |
267 if (!($f instanceof Function)) { | 267 if (!($f instanceof Function)) { |
268 // We're not a function (and hence not a method either) | 268 // We're not a function (and hence not a method either) |
269 // Grab the `call` method if it's not a function. | 269 // Grab the `call` method if it's not a function. |
270 if ($f != null) { | 270 if ($f != null) { |
271 $ftype = $getMethodType($getType($f), 'call'); | 271 $ftype = $getMethodType($getType($f), 'call'); |
272 $f = f.call ? $bind($f, 'call') : void 0; | 272 $f = f.call ? $bind($f, 'call') : void 0; |
273 } | 273 } |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 name = '+' + name; | 1010 name = '+' + name; |
1011 } | 1011 } |
1012 return name; | 1012 return name; |
1013 } | 1013 } |
1014 | 1014 |
1015 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 1015 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
1016 /// | 1016 /// |
1017 /// Libraries are not actually deferred in DDC, so this just returns a future | 1017 /// Libraries are not actually deferred in DDC, so this just returns a future |
1018 /// that completes immediately. | 1018 /// that completes immediately. |
1019 Future loadLibrary() => new Future.value(); | 1019 Future loadLibrary() => new Future.value(); |
OLD | NEW |