@@ -4,14 +4,15 @@ import * as proto from '../cxxrtl/proto';
4
4
import { ILink } from '../cxxrtl/link' ;
5
5
import { Connection } from '../cxxrtl/client' ;
6
6
import { TimeInterval , TimePoint } from '../model/time' ;
7
- import { Reference , Sample , UnboundReference } from '../model/sample' ;
7
+ import { Diagnostic , Reference , Sample , UnboundReference } from '../model/sample' ;
8
8
import { Variable } from '../model/variable' ;
9
9
import { Scope } from '../model/scope' ;
10
10
import { Location } from '../model/source' ;
11
11
12
12
function lazy < T > ( thunk : ( ) => Thenable < T > ) : Thenable < T > {
13
13
return { then : ( onfulfilled , onrejected ) => thunk ( ) . then ( onfulfilled , onrejected ) } ;
14
14
}
15
+
15
16
function matchLocation ( location : Location , filename : string , position : vscode . Position ) {
16
17
if ( location . file !== filename ) {
17
18
return false ;
@@ -214,38 +215,55 @@ export class Session {
214
215
}
215
216
216
217
async queryInterval (
217
- reference : Reference ,
218
218
interval : TimeInterval ,
219
- options : { collapse ?: boolean } = { }
219
+ options : {
220
+ reference ?: Reference ,
221
+ diagnostics ?: boolean
222
+ collapse ?: boolean ,
223
+ } = { }
220
224
) : Promise < Sample [ ] > {
221
- this . checkReferenceEpoch ( reference . name , reference . epoch ) ;
225
+ const reference = options . reference ;
226
+ if ( reference !== undefined ) {
227
+ this . checkReferenceEpoch ( reference . name , reference . epoch ) ;
228
+ }
222
229
const response = await this . connection . queryInterval ( {
223
230
type : 'command' ,
224
231
command : 'query_interval' ,
225
232
interval : interval . toCXXRTL ( ) ,
233
+ items : reference ?. name ?? null ,
234
+ item_values_encoding : reference ? 'base64(u32)' : null ,
235
+ diagnostics : options . diagnostics ?? false ,
226
236
collapse : options . collapse ?? true ,
227
- items : reference . name ,
228
- item_values_encoding : 'base64(u32)' ,
229
- diagnostics : false
230
237
} ) ;
231
238
return response . samples . map ( ( cxxrtlSample ) => {
232
- const itemValuesBuffer = Buffer . from ( cxxrtlSample . item_values ! , 'base64' ) ;
233
- const itemValuesArray = new Uint32Array (
234
- itemValuesBuffer . buffer ,
235
- itemValuesBuffer . byteOffset ,
236
- itemValuesBuffer . length / Uint32Array . BYTES_PER_ELEMENT
237
- ) ;
239
+ let itemValuesArray = null ;
240
+ let diagnosticsArray = null ;
241
+ if ( cxxrtlSample . item_values !== undefined ) {
242
+ const itemValuesBuffer = Buffer . from ( cxxrtlSample . item_values , 'base64' ) ;
243
+ itemValuesArray = new Uint32Array (
244
+ itemValuesBuffer . buffer ,
245
+ itemValuesBuffer . byteOffset ,
246
+ itemValuesBuffer . length / Uint32Array . BYTES_PER_ELEMENT
247
+ ) ;
248
+ }
249
+ if ( cxxrtlSample . diagnostics !== undefined ) {
250
+ diagnosticsArray = Array . from ( cxxrtlSample . diagnostics , Diagnostic . fromCXXRTL ) ;
251
+ }
238
252
return new Sample (
239
253
TimePoint . fromCXXRTL ( cxxrtlSample . time ) ,
240
- reference . unbound ,
241
- itemValuesArray
254
+ reference ?. unbound ?? null ,
255
+ itemValuesArray ,
256
+ diagnosticsArray ,
242
257
) ;
243
258
} ) ;
244
259
}
245
260
246
- async queryAtCursor ( reference : Reference ) : Promise < Sample > {
261
+ async queryAtCursor ( options : {
262
+ reference ?: Reference ,
263
+ diagnostics ?: boolean
264
+ } ) : Promise < Sample > {
247
265
const interval = new TimeInterval ( this . timeCursor , this . timeCursor ) ;
248
- const [ sample ] = await this . queryInterval ( reference , interval ) ;
266
+ const [ sample ] = await this . queryInterval ( interval , options ) ;
249
267
return sample ;
250
268
}
251
269
0 commit comments