OLD | NEW |
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] represents a persistent object within the vm. | 7 /// A [ServiceObject] represents a persistent object within the vm. |
8 abstract class ServiceObject extends Observable { | 8 abstract class ServiceObject extends Observable { |
9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
10 return o1.name.compareTo(o2.name); | 10 return o1.name.compareTo(o2.name); |
(...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)"; | 2168 String toString() => "CallSiteEntry(${receiverContainer.name}, $count)"; |
2169 } | 2169 } |
2170 | 2170 |
2171 class Script extends ServiceObject with Coverage { | 2171 class Script extends ServiceObject with Coverage { |
2172 Set<CallSite> callSites = new Set<CallSite>(); | 2172 Set<CallSite> callSites = new Set<CallSite>(); |
2173 final lines = new ObservableList<ScriptLine>(); | 2173 final lines = new ObservableList<ScriptLine>(); |
2174 final _hits = new Map<int, int>(); | 2174 final _hits = new Map<int, int>(); |
2175 @observable String kind; | 2175 @observable String kind; |
2176 @observable int firstTokenPos; | 2176 @observable int firstTokenPos; |
2177 @observable int lastTokenPos; | 2177 @observable int lastTokenPos; |
| 2178 @observable int lineOffset; |
| 2179 @observable int columnOffset; |
2178 @observable Library library; | 2180 @observable Library library; |
2179 bool get canCache => true; | 2181 bool get canCache => true; |
2180 bool get immutable => true; | 2182 bool get immutable => true; |
2181 | 2183 |
2182 String _shortUrl; | 2184 String _shortUrl; |
2183 String _url; | 2185 String _url; |
2184 | 2186 |
2185 Script._empty(ServiceObjectOwner owner) : super._empty(owner); | 2187 Script._empty(ServiceObjectOwner owner) : super._empty(owner); |
2186 | 2188 |
2187 ScriptLine getLine(int line) { | 2189 ScriptLine getLine(int line) { |
2188 assert(line >= 1); | 2190 assert(line >= 1); |
2189 return lines[line - 1]; | 2191 return lines[line - lineOffset - 1]; |
2190 } | 2192 } |
2191 | 2193 |
2192 /// This function maps a token position to a line number. | 2194 /// This function maps a token position to a line number. |
2193 int tokenToLine(int token) => _tokenToLine[token]; | 2195 int tokenToLine(int token) => _tokenToLine[token]; |
2194 Map _tokenToLine = {}; | 2196 Map _tokenToLine = {}; |
2195 | 2197 |
2196 /// This function maps a token position to a column number. | 2198 /// This function maps a token position to a column number. |
2197 int tokenToCol(int token) => _tokenToCol[token]; | 2199 int tokenToCol(int token) => _tokenToCol[token]; |
2198 Map _tokenToCol = {}; | 2200 Map _tokenToCol = {}; |
2199 | 2201 |
2200 void _update(ObservableMap map, bool mapIsRef) { | 2202 void _update(ObservableMap map, bool mapIsRef) { |
2201 _upgradeCollection(map, isolate); | 2203 _upgradeCollection(map, isolate); |
2202 kind = map['kind']; | 2204 kind = map['kind']; |
2203 _url = map['name']; | 2205 _url = map['name']; |
2204 _shortUrl = _url.substring(_url.lastIndexOf('/') + 1); | 2206 _shortUrl = _url.substring(_url.lastIndexOf('/') + 1); |
2205 name = _shortUrl; | 2207 name = _shortUrl; |
2206 vmName = _url; | 2208 vmName = _url; |
2207 if (mapIsRef) { | 2209 if (mapIsRef) { |
2208 return; | 2210 return; |
2209 } | 2211 } |
| 2212 lineOffset = map['lineOffset']; |
| 2213 columnOffset = map['columnOffset']; |
2210 _parseTokenPosTable(map['tokenPosTable']); | 2214 _parseTokenPosTable(map['tokenPosTable']); |
2211 _processSource(map['source']); | 2215 _processSource(map['source']); |
2212 library = map['library']; | 2216 library = map['library']; |
2213 } | 2217 } |
2214 | 2218 |
2215 void _parseTokenPosTable(List<List<int>> table) { | 2219 void _parseTokenPosTable(List<List<int>> table) { |
2216 if (table == null) { | 2220 if (table == null) { |
2217 return; | 2221 return; |
2218 } | 2222 } |
2219 _tokenToLine.clear(); | 2223 _tokenToLine.clear(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 } | 2289 } |
2286 var sourceLines = source.split('\n'); | 2290 var sourceLines = source.split('\n'); |
2287 if (sourceLines.length == 0) { | 2291 if (sourceLines.length == 0) { |
2288 return; | 2292 return; |
2289 } | 2293 } |
2290 // We have the source to the script. This is now loaded. | 2294 // We have the source to the script. This is now loaded. |
2291 _loaded = true; | 2295 _loaded = true; |
2292 lines.clear(); | 2296 lines.clear(); |
2293 Logger.root.info('Adding ${sourceLines.length} source lines for ${_url}'); | 2297 Logger.root.info('Adding ${sourceLines.length} source lines for ${_url}'); |
2294 for (var i = 0; i < sourceLines.length; i++) { | 2298 for (var i = 0; i < sourceLines.length; i++) { |
2295 lines.add(new ScriptLine(this, i + 1, sourceLines[i])); | 2299 lines.add(new ScriptLine(this, i + lineOffset + 1, sourceLines[i])); |
2296 } | 2300 } |
2297 for (var bpt in isolate.breakpoints.values) { | 2301 for (var bpt in isolate.breakpoints.values) { |
2298 if (bpt.script == this) { | 2302 if (bpt.script == this) { |
2299 _addBreakpoint(bpt); | 2303 _addBreakpoint(bpt); |
2300 } | 2304 } |
2301 } | 2305 } |
2302 | 2306 |
2303 _applyHitsToLines(); | 2307 _applyHitsToLines(); |
2304 // Notify any Observers that this Script's state has changed. | 2308 // Notify any Observers that this Script's state has changed. |
2305 notifyChange(null); | 2309 notifyChange(null); |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 var v = list[i]; | 2995 var v = list[i]; |
2992 if ((v is ObservableMap) && _isServiceMap(v)) { | 2996 if ((v is ObservableMap) && _isServiceMap(v)) { |
2993 list[i] = owner.getFromMap(v); | 2997 list[i] = owner.getFromMap(v); |
2994 } else if (v is ObservableList) { | 2998 } else if (v is ObservableList) { |
2995 _upgradeObservableList(v, owner); | 2999 _upgradeObservableList(v, owner); |
2996 } else if (v is ObservableMap) { | 3000 } else if (v is ObservableMap) { |
2997 _upgradeObservableMap(v, owner); | 3001 _upgradeObservableMap(v, owner); |
2998 } | 3002 } |
2999 } | 3003 } |
3000 } | 3004 } |
OLD | NEW |