| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // var $WeakMap = global.WeakMap | 34 // var $WeakMap = global.WeakMap |
| 35 | 35 |
| 36 | 36 |
| 37 var $Promise = Promise; | 37 var $Promise = Promise; |
| 38 | 38 |
| 39 | 39 |
| 40 //------------------------------------------------------------------- | 40 //------------------------------------------------------------------- |
| 41 | 41 |
| 42 // Core functionality. | 42 // Core functionality. |
| 43 | 43 |
| 44 // Event queue format: [(value, [(handler, deferred)*])*] | |
| 45 // I.e., a list of value/tasks pairs, where the value is a resolution value or | |
| 46 // rejection reason, and the tasks are a respective list of handler/deferred | |
| 47 // pairs waiting for notification of this value. Each handler is an onResolve or | |
| 48 // onReject function provided to the same call of 'chain' that produced the | |
| 49 // associated deferred. | |
| 50 var promiseEvents = new InternalArray; | |
| 51 | |
| 52 // Status values: 0 = pending, +1 = resolved, -1 = rejected | 44 // Status values: 0 = pending, +1 = resolved, -1 = rejected |
| 53 var promiseStatus = NEW_PRIVATE("Promise#status"); | 45 var promiseStatus = NEW_PRIVATE("Promise#status"); |
| 54 var promiseValue = NEW_PRIVATE("Promise#value"); | 46 var promiseValue = NEW_PRIVATE("Promise#value"); |
| 55 var promiseOnResolve = NEW_PRIVATE("Promise#onResolve"); | 47 var promiseOnResolve = NEW_PRIVATE("Promise#onResolve"); |
| 56 var promiseOnReject = NEW_PRIVATE("Promise#onReject"); | 48 var promiseOnReject = NEW_PRIVATE("Promise#onReject"); |
| 57 var promiseRaw = NEW_PRIVATE("Promise#raw"); | 49 var promiseRaw = NEW_PRIVATE("Promise#raw"); |
| 58 | 50 |
| 59 function IsPromise(x) { | 51 function IsPromise(x) { |
| 60 return IS_SPEC_OBJECT(x) && %HasLocalProperty(x, promiseStatus); | 52 return IS_SPEC_OBJECT(x) && %HasLocalProperty(x, promiseStatus); |
| 61 } | 53 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 "resolve", PromiseCast | 318 "resolve", PromiseCast |
| 327 ]); | 319 ]); |
| 328 InstallFunctions($Promise.prototype, DONT_ENUM, [ | 320 InstallFunctions($Promise.prototype, DONT_ENUM, [ |
| 329 "chain", PromiseChain, | 321 "chain", PromiseChain, |
| 330 "then", PromiseThen, | 322 "then", PromiseThen, |
| 331 "catch", PromiseCatch | 323 "catch", PromiseCatch |
| 332 ]); | 324 ]); |
| 333 } | 325 } |
| 334 | 326 |
| 335 SetUpPromise(); | 327 SetUpPromise(); |
| OLD | NEW |