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

Side by Side Diff: tools/turbolizer/text-view.js

Issue 2133663002: [turbolizer] Improve code comments in disassembly (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [turbolizer] Improve code comments in disassembly Created 4 years, 5 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 | « tools/turbolizer/disassembly-view.js ('k') | tools/turbolizer/turbo-visualizer.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 4
5 "use strict"; 5 "use strict";
6 6
7 class TextView extends View { 7 class TextView extends View {
8 constructor(id, broker, patterns, allowSpanSelection) { 8 constructor(id, broker, patterns, allowSpanSelection) {
9 super(id, broker); 9 super(id, broker);
10 let view = this; 10 let view = this;
(...skipping 10 matching lines...) Expand all
21 broker.clear(selectionHandler); 21 broker.clear(selectionHandler);
22 }, 22 },
23 select: function(items, selected) { 23 select: function(items, selected) {
24 for (let i of items) { 24 for (let i of items) {
25 if (selected) { 25 if (selected) {
26 i.classList.add("selected"); 26 i.classList.add("selected");
27 } else { 27 } else {
28 i.classList.remove("selected"); 28 i.classList.remove("selected");
29 } 29 }
30 } 30 }
31 broker.clear(selectionHandler);
31 broker.select(selectionHandler, view.getRanges(items), selected); 32 broker.select(selectionHandler, view.getRanges(items), selected);
32 }, 33 },
33 selectionDifference: function(span1, inclusive1, span2, inclusive2) { 34 selectionDifference: function(span1, inclusive1, span2, inclusive2) {
34 return null; 35 return null;
35 }, 36 },
36 brokeredSelect: function(ranges, selected) { 37 brokeredSelect: function(ranges, selected) {
37 let locations = view.rangesToLocations(ranges); 38 let locations = view.rangesToLocations(ranges);
38 view.selectLocations(locations, selected, true); 39 view.selectLocations(locations, selected, true);
39 }, 40 },
40 brokeredClear: function() { 41 brokeredClear: function() {
(...skipping 20 matching lines...) Expand all
61 return range; 62 return range;
62 } 63 }
63 64
64 rangesToLocations(ranges) { 65 rangesToLocations(ranges) {
65 let view = this; 66 let view = this;
66 let nodes = new Set(); 67 let nodes = new Set();
67 let result = []; 68 let result = [];
68 for (let range of ranges) { 69 for (let range of ranges) {
69 let start = range[0]; 70 let start = range[0];
70 let end = range[1]; 71 let end = range[1];
71 let location = { pos_start: start, pos_end: end }; 72 let block_id = range[3];
73 let location = { pos_start: start, pos_end: end, block_id: block_id };
72 if (range[2] !== null && range[2] != -1) { 74 if (range[2] !== null && range[2] != -1) {
73 location.node_id = range[2]; 75 location.node_id = range[2];
74 if (range[0] == -1 && range[1] == -1) { 76 if (range[0] == -1 && range[1] == -1) {
75 location.pos_start = view.nodePositionMap[location.node_id]; 77 location.pos_start = view.nodePositionMap[location.node_id];
76 location.pos_end = location.pos_start + 1; 78 location.pos_end = location.pos_start + 1;
77 } 79 }
78 } else { 80 } else {
79 if (range[0] != undefined) { 81 if (range[0] != undefined) {
80 location.pos_start = range[0]; 82 location.pos_start = range[0];
81 location.pos_end = range[1]; 83 location.pos_end = range[1];
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 180
179 getRanges(items) { 181 getRanges(items) {
180 let result = []; 182 let result = [];
181 let lastObject = null; 183 let lastObject = null;
182 for (let i of items) { 184 for (let i of items) {
183 if (i.location) { 185 if (i.location) {
184 let location = i.location; 186 let location = i.location;
185 let start = -1; 187 let start = -1;
186 let end = -1; 188 let end = -1;
187 let node_id = -1; 189 let node_id = -1;
190 let block_id = -1;
188 if (location.node_id !== undefined) { 191 if (location.node_id !== undefined) {
189 node_id = location.node_id; 192 node_id = location.node_id;
190 } 193 }
194 if (location.block_id !== undefined) {
195 block_id = location.block_id;
196 }
191 if (location.pos_start !== undefined) { 197 if (location.pos_start !== undefined) {
192 start = location.pos_start; 198 start = location.pos_start;
193 end = location.pos_end; 199 end = location.pos_end;
194 } else { 200 } else {
195 if (this.nodePositionMap && this.nodePositionMap[node_id]) { 201 if (this.nodePositionMap && this.nodePositionMap[node_id]) {
196 start = this.nodePositionMap[node_id]; 202 start = this.nodePositionMap[node_id];
197 end = start + 1; 203 end = start + 1;
198 } 204 }
199 } 205 }
200 if (lastObject == null || 206 if (lastObject == null ||
201 (lastObject[2] != node_id || 207 (lastObject[2] != node_id ||
202 lastObject[0] != start || 208 lastObject[0] != start ||
203 lastObject[1] != end)) { 209 lastObject[1] != end ||
204 lastObject = [start, end, node_id]; 210 lastObject[3] != block_id)) {
211 lastObject = [start, end, node_id, block_id];
205 result.push(lastObject); 212 result.push(lastObject);
206 } 213 }
207 } 214 }
208 } 215 }
209 return result; 216 return result;
210 } 217 }
211 218
212 createFragment(text, style) { 219 createFragment(text, style) {
213 let view = this; 220 let view = this;
214 let span = document.createElement("SPAN"); 221 let span = document.createElement("SPAN");
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 lineLocation(li) { 392 lineLocation(li) {
386 let view = this; 393 let view = this;
387 for (let i = 0; i < li.children.length; ++i) { 394 for (let i = 0; i < li.children.length; ++i) {
388 let fragment = li.children[i]; 395 let fragment = li.children[i];
389 if (fragment.location != undefined && !view.allowSpanSelection) { 396 if (fragment.location != undefined && !view.allowSpanSelection) {
390 return fragment.location; 397 return fragment.location;
391 } 398 }
392 } 399 }
393 } 400 }
394 } 401 }
OLDNEW
« no previous file with comments | « tools/turbolizer/disassembly-view.js ('k') | tools/turbolizer/turbo-visualizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698