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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 216883008: Use tokenPos instead of line/col in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js / handle multiple reloads Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/stack_frame.html ('k') | runtime/vm/debugger.cc » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of service; 5 part of service;
6 6
7 /// A [ServiceObject] is an object known to the VM service and is tied 7 /// A [ServiceObject] is an object known to the VM service and is tied
8 /// to an owning [Isolate]. 8 /// to an owning [Isolate].
9 abstract class ServiceObject extends Observable { 9 abstract class ServiceObject extends Observable {
10 /// The owner of this [ServiceObject]. This can be an [Isolate], a 10 /// The owner of this [ServiceObject]. This can be an [Isolate], a
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 /// If [this] was created from a reference, load the full object 92 /// If [this] was created from a reference, load the full object
93 /// from the service by calling [reload]. Else, return [this]. 93 /// from the service by calling [reload]. Else, return [this].
94 Future<ServiceObject> load() { 94 Future<ServiceObject> load() {
95 if (loaded) { 95 if (loaded) {
96 return new Future.value(this); 96 return new Future.value(this);
97 } 97 }
98 // Call reload which will fill in the entire object. 98 // Call reload which will fill in the entire object.
99 return reload(); 99 return reload();
100 } 100 }
101 101
102 Future<ServiceObject> _inProgressReload;
103
102 /// Reload [this]. Returns a future which completes to [this] or 104 /// Reload [this]. Returns a future which completes to [this] or
103 /// a [ServiceError]. 105 /// a [ServiceError].
104 Future<ServiceObject> reload() { 106 Future<ServiceObject> reload() {
105 if (id == '') { 107 if (id == '') {
106 // Errors don't have ids. 108 // Errors don't have ids.
107 assert(serviceType == 'Error'); 109 assert(serviceType == 'Error');
108 return new Future.value(this); 110 return new Future.value(this);
109 } 111 }
110 if (loaded && immutable) { 112 if (loaded && immutable) {
111 return new Future.value(this); 113 return new Future.value(this);
112 } 114 }
113 return vm.getAsMap(link).then((ObservableMap map) { 115 if (_inProgressReload == null) {
114 var mapType = _stripRef(map['type']); 116 _inProgressReload = vm.getAsMap(link).then((ObservableMap map) {
115 if (mapType != _serviceType) { 117 var mapType = _stripRef(map['type']);
116 // If the type changes, return a new object instead of 118 if (mapType != _serviceType) {
117 // updating the existing one. 119 // If the type changes, return a new object instead of
118 assert(mapType == 'Error' || mapType == 'Null'); 120 // updating the existing one.
119 return new ServiceObject._fromMap(owner, map); 121 assert(mapType == 'Error' || mapType == 'Null');
120 } 122 return new ServiceObject._fromMap(owner, map);
121 update(map); 123 }
122 return this; 124 update(map);
125 return this;
126 }).whenComplete(() {
127 // This reload is complete.
128 _inProgressReload = null;
123 }); 129 });
130 }
131 return _inProgressReload;
124 } 132 }
125 133
126 /// Update [this] using [map] as a source. [map] can be a reference. 134 /// Update [this] using [map] as a source. [map] can be a reference.
127 void update(ObservableMap map) { 135 void update(ObservableMap map) {
128 assert(_isServiceMap(map)); 136 assert(_isServiceMap(map));
129 137
130 // Don't allow the type to change on an object update. 138 // Don't allow the type to change on an object update.
131 // TODO(turnidge): Make this a ServiceError? 139 // TODO(turnidge): Make this a ServiceError?
132 var mapIsRef = _hasRef(map['type']); 140 var mapIsRef = _hasRef(map['type']);
133 var mapType = _stripRef(map['type']); 141 var mapType = _stripRef(map['type']);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 @observable String kind; 820 @observable String kind;
813 821
814 bool get canCache => true; 822 bool get canCache => true;
815 bool get immutable => true; 823 bool get immutable => true;
816 824
817 String _shortUrl; 825 String _shortUrl;
818 String _url; 826 String _url;
819 827
820 Script._empty(ServiceObjectOwner owner) : super._empty(owner); 828 Script._empty(ServiceObjectOwner owner) : super._empty(owner);
821 829
830 /// This function maps a token position to a line number.
831 int tokenToLine(int token) => _tokenToLine[token];
832 Map _tokenToLine;
833
834 /// This function maps a token position to a column number.
835 int tokenToCol(int token) => _tokenToCol[token];
836 Map _tokenToCol;
837
822 void _update(ObservableMap map, bool mapIsRef) { 838 void _update(ObservableMap map, bool mapIsRef) {
823 kind = map['kind']; 839 kind = map['kind'];
824 _url = map['name']; 840 _url = map['name'];
825 _shortUrl = _url.substring(_url.lastIndexOf('/') + 1); 841 _shortUrl = _url.substring(_url.lastIndexOf('/') + 1);
826 name = _shortUrl; 842 name = _shortUrl;
827 vmName = _url; 843 vmName = _url;
828 _processSource(map['source']); 844 _processSource(map['source']);
845 _parseTokenPosTable(map['tokenPosTable']);
846 }
847
848 void _parseTokenPosTable(List<List<int>> table) {
849 if (table == null) {
850 return;
851 }
852 _tokenToLine = {};
853 _tokenToCol = {};
854 for (var line in table) {
855 // Each entry begins with a line number...
856 var lineNumber = line[0];
857 for (var pos = 1; pos < line.length; pos += 2) {
858 // ...and is followed by (token offset, col number) pairs.
859 var tokenOffset = line[pos];
860 var colNumber = line[pos+1];
861 _tokenToLine[tokenOffset] = lineNumber;
862 _tokenToCol[tokenOffset] = colNumber;
863 }
864 }
829 } 865 }
830 866
831 void _processHits(List scriptHits) { 867 void _processHits(List scriptHits) {
832 if (!_loaded) { 868 if (!_loaded) {
833 // Eagerly grab script source. 869 // Eagerly grab script source.
834 load(); 870 load();
835 } 871 }
836 // Update hits table. 872 // Update hits table.
837 for (var i = 0; i < scriptHits.length; i += 2) { 873 for (var i = 0; i < scriptHits.length; i += 2) {
838 var line = scriptHits[i]; 874 var line = scriptHits[i];
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 var v = list[i]; 1208 var v = list[i];
1173 if ((v is ObservableMap) && _isServiceMap(v)) { 1209 if ((v is ObservableMap) && _isServiceMap(v)) {
1174 list[i] = owner.getFromMap(v); 1210 list[i] = owner.getFromMap(v);
1175 } else if (v is ObservableList) { 1211 } else if (v is ObservableList) {
1176 _upgradeObservableList(v, owner); 1212 _upgradeObservableList(v, owner);
1177 } else if (v is ObservableMap) { 1213 } else if (v is ObservableMap) {
1178 _upgradeObservableMap(v, owner); 1214 _upgradeObservableMap(v, owner);
1179 } 1215 }
1180 } 1216 }
1181 } 1217 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/elements/stack_frame.html ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698