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/_operations', null, /* Imports */[ | 8 dart_library.library('dart/_operations', null, /* Imports */[ |
9 ], /* Lazy Imports */[ | 9 ], /* Lazy Imports */[ |
10 'dart/async', | 10 'dart/async', |
(...skipping 27 matching lines...) Expand all Loading... | |
38 function dload(obj, field) { | 38 function dload(obj, field) { |
39 field = _canonicalFieldName(obj, field, [], field); | 39 field = _canonicalFieldName(obj, field, [], field); |
40 if (classes.hasMethod(obj, field)) { | 40 if (classes.hasMethod(obj, field)) { |
41 return classes.bind(obj, field); | 41 return classes.bind(obj, field); |
42 } | 42 } |
43 // TODO(vsm): Implement NSM robustly. An 'in' check breaks on certain | 43 // TODO(vsm): Implement NSM robustly. An 'in' check breaks on certain |
44 // types. hasOwnProperty doesn't chase the proto chain. | 44 // types. hasOwnProperty doesn't chase the proto chain. |
45 // Also, do we want an NSM on regular JS objects? | 45 // Also, do we want an NSM on regular JS objects? |
46 // See: https://github.com/dart-lang/dev_compiler/issues/169 | 46 // See: https://github.com/dart-lang/dev_compiler/issues/169 |
47 let result = obj[field]; | 47 let result = obj[field]; |
48 | 48 return result; |
49 // TODO(vsm): Check this more robustly. | |
vsm
2015/11/30 22:21:30
The method tearoffs should be caught in line 40 ab
| |
50 if (typeof result == "function" && !hasOwnProperty.call(obj, field)) { | |
51 // This appears to be a method tearoff. Bind this. | |
52 return result.bind(obj); | |
53 } | |
54 return result; | |
55 } | 49 } |
56 exports.dload = dload; | 50 exports.dload = dload; |
57 | 51 |
58 function dput(obj, field, value) { | 52 function dput(obj, field, value) { |
59 field = _canonicalFieldName(obj, field, [value], field); | 53 field = _canonicalFieldName(obj, field, [value], field); |
60 // TODO(vsm): Implement NSM and type checks. | 54 // TODO(vsm): Implement NSM and type checks. |
61 // See: https://github.com/dart-lang/dev_compiler/issues/170 | 55 // See: https://github.com/dart-lang/dev_compiler/issues/170 |
62 obj[field] = value; | 56 obj[field] = value; |
63 return value; | 57 return value; |
64 } | 58 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 next() { | 447 next() { |
454 let i = this.dartIterator; | 448 let i = this.dartIterator; |
455 let done = !i.moveNext(); | 449 let done = !i.moveNext(); |
456 return { done: done, value: done ? void 0 : i.current }; | 450 return { done: done, value: done ? void 0 : i.current }; |
457 } | 451 } |
458 } | 452 } |
459 exports.JsIterator = JsIterator; | 453 exports.JsIterator = JsIterator; |
460 | 454 |
461 | 455 |
462 }); | 456 }); |
OLD | NEW |