@@ -4,14 +4,15 @@ import * as proto from '../cxxrtl/proto';
44import { ILink } from '../cxxrtl/link' ;
55import { Connection } from '../cxxrtl/client' ;
66import { TimeInterval , TimePoint } from '../model/time' ;
7- import { Reference , Sample , UnboundReference } from '../model/sample' ;
7+ import { Diagnostic , Reference , Sample , UnboundReference } from '../model/sample' ;
88import { Variable } from '../model/variable' ;
99import { Scope } from '../model/scope' ;
1010import { Location } from '../model/source' ;
1111
1212function lazy < T > ( thunk : ( ) => Thenable < T > ) : Thenable < T > {
1313 return { then : ( onfulfilled , onrejected ) => thunk ( ) . then ( onfulfilled , onrejected ) } ;
1414}
15+
1516function matchLocation ( location : Location , filename : string , position : vscode . Position ) {
1617 if ( location . file !== filename ) {
1718 return false ;
@@ -214,38 +215,55 @@ export class Session {
214215 }
215216
216217 async queryInterval (
217- reference : Reference ,
218218 interval : TimeInterval ,
219- options : { collapse ?: boolean } = { }
219+ options : {
220+ reference ?: Reference ,
221+ diagnostics ?: boolean
222+ collapse ?: boolean ,
223+ } = { }
220224 ) : 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+ }
222229 const response = await this . connection . queryInterval ( {
223230 type : 'command' ,
224231 command : 'query_interval' ,
225232 interval : interval . toCXXRTL ( ) ,
233+ items : reference ?. name ?? null ,
234+ item_values_encoding : reference ? 'base64(u32)' : null ,
235+ diagnostics : options . diagnostics ?? false ,
226236 collapse : options . collapse ?? true ,
227- items : reference . name ,
228- item_values_encoding : 'base64(u32)' ,
229- diagnostics : false
230237 } ) ;
231238 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+ }
238252 return new Sample (
239253 TimePoint . fromCXXRTL ( cxxrtlSample . time ) ,
240- reference . unbound ,
241- itemValuesArray
254+ reference ?. unbound ?? null ,
255+ itemValuesArray ,
256+ diagnosticsArray ,
242257 ) ;
243258 } ) ;
244259 }
245260
246- async queryAtCursor ( reference : Reference ) : Promise < Sample > {
261+ async queryAtCursor ( options : {
262+ reference ?: Reference ,
263+ diagnostics ?: boolean
264+ } ) : Promise < Sample > {
247265 const interval = new TimeInterval ( this . timeCursor , this . timeCursor ) ;
248- const [ sample ] = await this . queryInterval ( reference , interval ) ;
266+ const [ sample ] = await this . queryInterval ( interval , options ) ;
249267 return sample ;
250268 }
251269
0 commit comments