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

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

Issue 760303002: Expose generator object internal properties via mirrors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | « no previous file | test/mjsunit/es6/generators-mirror.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.
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 return result; 924 return result;
925 } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) { 925 } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) {
926 var details = IS_MAP_ITERATOR(value) ? %MapIteratorDetails(value) 926 var details = IS_MAP_ITERATOR(value) ? %MapIteratorDetails(value)
927 : %SetIteratorDetails(value); 927 : %SetIteratorDetails(value);
928 var kind; 928 var kind;
929 switch (details[2]) { 929 switch (details[2]) {
930 case 1: kind = "keys"; break; 930 case 1: kind = "keys"; break;
931 case 2: kind = "values"; break; 931 case 2: kind = "values"; break;
932 case 3: kind = "entries"; break; 932 case 3: kind = "entries"; break;
933 } 933 }
934 var result = []; 934 var result = [
935 result.push(new InternalPropertyMirror("[[IteratorHasMore]]", details[0])); 935 new InternalPropertyMirror("[[IteratorHasMore]]", details[0]),
936 result.push(new InternalPropertyMirror("[[IteratorIndex]]", details[1])); 936 new InternalPropertyMirror("[[IteratorIndex]]", details[1])
937 ];
937 if (kind) { 938 if (kind) {
938 result.push(new InternalPropertyMirror("[[IteratorKind]]", kind)); 939 result.push(new InternalPropertyMirror("[[IteratorKind]]", kind));
939 } 940 }
940 return result; 941 return result;
942 } else if (IS_GENERATOR(value)) {
943 return [
944 new InternalPropertyMirror("[[GeneratorStatus]]",
945 GeneratorGetStatus_(value)),
946 new InternalPropertyMirror("[[GeneratorFunction]]",
947 %GeneratorGetFunction(value)),
948 new InternalPropertyMirror("[[GeneratorReceiver]]",
949 %GeneratorGetReceiver(value))
950 ];
941 } else if (ObjectIsPromise(value)) { 951 } else if (ObjectIsPromise(value)) {
942 var result = []; 952 return [
943 result.push(new InternalPropertyMirror("[[PromiseStatus]]", 953 new InternalPropertyMirror("[[PromiseStatus]]", PromiseGetStatus_(value)),
944 PromiseGetStatus_(value))); 954 new InternalPropertyMirror("[[PromiseValue]]", PromiseGetValue_(value))
945 result.push(new InternalPropertyMirror("[[PromiseValue]]", 955 ];
946 PromiseGetValue_(value)));
947 return result;
948 } 956 }
949 return []; 957 return [];
950 } 958 }
951 959
952 960
953 /** 961 /**
954 * Mirror object for functions. 962 * Mirror object for functions.
955 * @param {function} value The function object reflected by this mirror. 963 * @param {function} value The function object reflected by this mirror.
956 * @constructor 964 * @constructor
957 * @extends ObjectMirror 965 * @extends ObjectMirror
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 * @param {Object} data The Generator object 1444 * @param {Object} data The Generator object
1437 * @constructor 1445 * @constructor
1438 * @extends Mirror 1446 * @extends Mirror
1439 */ 1447 */
1440 function GeneratorMirror(value) { 1448 function GeneratorMirror(value) {
1441 %_CallFunction(this, value, GENERATOR_TYPE, ObjectMirror); 1449 %_CallFunction(this, value, GENERATOR_TYPE, ObjectMirror);
1442 } 1450 }
1443 inherits(GeneratorMirror, ObjectMirror); 1451 inherits(GeneratorMirror, ObjectMirror);
1444 1452
1445 1453
1446 GeneratorMirror.prototype.status = function() { 1454 function GeneratorGetStatus_(value) {
1447 var continuation = %GeneratorGetContinuation(this.value_); 1455 var continuation = %GeneratorGetContinuation(value);
1448 if (continuation < 0) return "running"; 1456 if (continuation < 0) return "running";
1449 if (continuation == 0) return "closed"; 1457 if (continuation == 0) return "closed";
1450 return "suspended"; 1458 return "suspended";
1459 }
1460
1461
1462 GeneratorMirror.prototype.status = function() {
1463 return GeneratorGetStatus_(this.value_);
1451 }; 1464 };
1452 1465
1453 1466
1454 GeneratorMirror.prototype.sourcePosition_ = function() { 1467 GeneratorMirror.prototype.sourcePosition_ = function() {
1455 return %GeneratorGetSourcePosition(this.value_); 1468 return %GeneratorGetSourcePosition(this.value_);
1456 }; 1469 };
1457 1470
1458 1471
1459 GeneratorMirror.prototype.sourceLocation = function() { 1472 GeneratorMirror.prototype.sourceLocation = function() {
1460 var pos = this.sourcePosition_(); 1473 var pos = this.sourcePosition_();
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 } 3044 }
3032 if (!NUMBER_IS_FINITE(value)) { 3045 if (!NUMBER_IS_FINITE(value)) {
3033 if (value > 0) { 3046 if (value > 0) {
3034 return 'Infinity'; 3047 return 'Infinity';
3035 } else { 3048 } else {
3036 return '-Infinity'; 3049 return '-Infinity';
3037 } 3050 }
3038 } 3051 }
3039 return value; 3052 return value;
3040 } 3053 }
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/generators-mirror.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698