Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: src/mirror-debugger.js

Issue 1054763003: Wrap promise implementation in a function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug.cc ('k') | src/promise.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2012 the V8 project authors. All rights reserved. 1 // Copyright 2006-2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 "use strict"; 4 "use strict";
5 5
6 // Handle id counters. 6 // Handle id counters.
7 var next_handle_ = 0; 7 var next_handle_ = 0;
8 var next_transient_handle_ = -1; 8 var next_transient_handle_ = -1;
9 9
10 // Mirror cache. 10 // Mirror cache.
11 var mirror_cache_ = []; 11 var mirror_cache_ = [];
12 var mirror_cache_enabled_ = true; 12 var mirror_cache_enabled_ = true;
13 13
14 14
15 function ToggleMirrorCache(value) { 15 function ToggleMirrorCache(value) {
16 mirror_cache_enabled_ = value; 16 mirror_cache_enabled_ = value;
17 next_handle_ = 0; 17 next_handle_ = 0;
18 mirror_cache_ = []; 18 mirror_cache_ = [];
19 } 19 }
20 20
21 21
22 // Wrapper to check whether an object is a Promise. The call may not work 22 // Wrapper to check whether an object is a Promise. The call may not work
23 // if promises are not enabled. 23 // if promises are not enabled.
24 // TODO(yangguo): remove try-catch once promises are enabled by default. 24 // TODO(yangguo): remove try-catch once promises are enabled by default.
25 function ObjectIsPromise(value) { 25 function ObjectIsPromise(value) {
26 try { 26 try {
27 return IS_SPEC_OBJECT(value) && 27 return IS_SPEC_OBJECT(value) &&
28 !IS_UNDEFINED(%DebugGetProperty(value, builtins.promiseStatus)); 28 !IS_UNDEFINED(%DebugGetProperty(value, builtins.$promiseStatus));
29 } catch (e) { 29 } catch (e) {
30 return false; 30 return false;
31 } 31 }
32 } 32 }
33 33
34 34
35 /** 35 /**
36 * Returns the mirror for a specified value or object. 36 * Returns the mirror for a specified value or object.
37 * 37 *
38 * @param {value or Object} value the value or object to retreive the mirror for 38 * @param {value or Object} value the value or object to retreive the mirror for
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 * @constructor 1328 * @constructor
1329 * @extends ObjectMirror 1329 * @extends ObjectMirror
1330 */ 1330 */
1331 function PromiseMirror(value) { 1331 function PromiseMirror(value) {
1332 %_CallFunction(this, value, PROMISE_TYPE, ObjectMirror); 1332 %_CallFunction(this, value, PROMISE_TYPE, ObjectMirror);
1333 } 1333 }
1334 inherits(PromiseMirror, ObjectMirror); 1334 inherits(PromiseMirror, ObjectMirror);
1335 1335
1336 1336
1337 function PromiseGetStatus_(value) { 1337 function PromiseGetStatus_(value) {
1338 var status = %DebugGetProperty(value, builtins.promiseStatus); 1338 var status = %DebugGetProperty(value, builtins.$promiseStatus);
1339 if (status == 0) return "pending"; 1339 if (status == 0) return "pending";
1340 if (status == 1) return "resolved"; 1340 if (status == 1) return "resolved";
1341 return "rejected"; 1341 return "rejected";
1342 } 1342 }
1343 1343
1344 1344
1345 function PromiseGetValue_(value) { 1345 function PromiseGetValue_(value) {
1346 return %DebugGetProperty(value, builtins.promiseValue); 1346 return %DebugGetProperty(value, builtins.$promiseValue);
1347 } 1347 }
1348 1348
1349 1349
1350 PromiseMirror.prototype.status = function() { 1350 PromiseMirror.prototype.status = function() {
1351 return PromiseGetStatus_(this.value_); 1351 return PromiseGetStatus_(this.value_);
1352 }; 1352 };
1353 1353
1354 1354
1355 PromiseMirror.prototype.promiseValue = function() { 1355 PromiseMirror.prototype.promiseValue = function() {
1356 return MakeMirror(PromiseGetValue_(this.value_)); 1356 return MakeMirror(PromiseGetValue_(this.value_));
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 } 3062 }
3063 if (!NUMBER_IS_FINITE(value)) { 3063 if (!NUMBER_IS_FINITE(value)) {
3064 if (value > 0) { 3064 if (value > 0) {
3065 return 'Infinity'; 3065 return 'Infinity';
3066 } else { 3066 } else {
3067 return '-Infinity'; 3067 return '-Infinity';
3068 } 3068 }
3069 } 3069 }
3070 return value; 3070 return value;
3071 } 3071 }
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698