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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 const getOwnNamesAndSymbols = dart_utils.getOwnNamesAndSymbols; | 22 const getOwnNamesAndSymbols = dart_utils.getOwnNamesAndSymbols; |
23 const throwError = dart_utils.throwError; | 23 const throwError = dart_utils.throwError; |
24 | 24 |
25 const getOwnPropertyNames = Object.getOwnPropertyNames; | 25 const getOwnPropertyNames = Object.getOwnPropertyNames; |
26 const hasOwnProperty = Object.prototype.hasOwnProperty; | 26 const hasOwnProperty = Object.prototype.hasOwnProperty; |
27 | 27 |
28 const slice = [].slice; | 28 const slice = [].slice; |
29 | 29 |
30 function _canonicalFieldName(obj, name, args, displayName) { | 30 function _canonicalFieldName(obj, name, args, displayName) { |
31 name = classes.canonicalMember(obj, name) | 31 name = classes.canonicalMember(obj, name); |
32 if (name) return name; | 32 if (name) return name; |
33 // TODO(jmesserly): in the future we might have types that "overlay" Dart | 33 // TODO(jmesserly): in the future we might have types that "overlay" Dart |
34 // methods while also exposing the full native API, e.g. dart:html vs | 34 // methods while also exposing the full native API, e.g. dart:html vs |
35 // dart:dom. To support that we'd need to fall back to the normal name | 35 // dart:dom. To support that we'd need to fall back to the normal name |
36 // if an extension method wasn't found. | 36 // if an extension method wasn't found. |
37 errors.throwNoSuchMethod(obj, displayName, args); | 37 errors.throwNoSuchMethod(obj, displayName, args); |
38 } | 38 } |
39 | 39 |
40 function dload(obj, field) { | 40 function dload(obj, field) { |
41 field = _canonicalFieldName(obj, field, [], field); | 41 field = _canonicalFieldName(obj, field, [], field); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 function throwNoSuchMethod(obj, name, args, opt_func) { | 106 function throwNoSuchMethod(obj, name, args, opt_func) { |
107 if (obj === void 0) obj = opt_func; | 107 if (obj === void 0) obj = opt_func; |
108 errors.throwNoSuchMethod(obj, name, args); | 108 errors.throwNoSuchMethod(obj, name, args); |
109 } | 109 } |
110 | 110 |
111 function checkAndCall(f, ftype, obj, args, name) { | 111 function checkAndCall(f, ftype, obj, args, name) { |
112 if (!(f instanceof Function)) { | 112 if (!(f instanceof Function)) { |
113 // We're not a function (and hence not a method either) | 113 // We're not a function (and hence not a method either) |
114 // Grab the `call` method if it's not a function. | 114 // Grab the `call` method if it's not a function. |
115 if (f !== null) { | 115 if (f != null) { |
116 ftype = classes.getMethodType(f, 'call'); | 116 ftype = classes.getMethodType(f, 'call'); |
117 f = f.call; | 117 f = f.call; |
118 } | 118 } |
119 if (!(f instanceof Function)) { | 119 if (!(f instanceof Function)) { |
120 throwNoSuchMethod(obj, name, args); | 120 throwNoSuchMethod(obj, name, args); |
121 } | 121 } |
122 } | 122 } |
123 // If f is a function, but not a method (no method type) | 123 // If f is a function, but not a method (no method type) |
124 // then it should have been a function valued field, so | 124 // then it should have been a function valued field, so |
125 // get the type from the function. | 125 // get the type from the function. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 next() { | 389 next() { |
390 let i = this.dartIterator; | 390 let i = this.dartIterator; |
391 let done = !i.moveNext(); | 391 let done = !i.moveNext(); |
392 return { done: done, value: done ? void 0 : i.current }; | 392 return { done: done, value: done ? void 0 : i.current }; |
393 } | 393 } |
394 } | 394 } |
395 exports.JsIterator = JsIterator; | 395 exports.JsIterator = JsIterator; |
396 | 396 |
397 | 397 |
398 }); | 398 }); |
OLD | NEW |