@@ -9,7 +9,7 @@ import * as sb from "smart-buffer";
99import {
1010 LuaAttachMessage , DMReqInitialize , DebugMessageId , DMMessage , DMLoadScript ,
1111 DMAddBreakpoint , DMBreak , StackNodeContainer , StackRootNode , IStackNode ,
12- DMReqEvaluate , DMRespEvaluate , ExprEvaluator
12+ DMReqEvaluate , DMRespEvaluate , ExprEvaluator , LoadedScript , LoadedScriptManager
1313} from './AttachProtol' ;
1414import { ByteArray } from './ByteArray' ;
1515import * as path from 'path' ;
@@ -40,13 +40,7 @@ interface EmmyBreakpoint {
4040 line : number ;
4141}
4242
43- interface LoadedScript {
44- path : string ;
45- index : number ;
46- source ?: string ;
47- }
48-
49- export class AttachDebugSession extends LoggingDebugSession implements ExprEvaluator {
43+ export class AttachDebugSession extends LoggingDebugSession implements ExprEvaluator , LoadedScriptManager {
5044
5145 private socket ?: net . Socket ;
5246 private receiveBuf = new sb . SmartBuffer ( ) ;
@@ -321,7 +315,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
321315 }
322316 }
323317
324- private findScript ( path : string ) : LoadedScript | undefined {
318+ public findScript ( path : string ) : LoadedScript | undefined {
325319 const filePath = this . resolvePath ( path ) ;
326320 if ( filePath ) {
327321 return this . loadedScripts . get ( this . normalize ( filePath ) ) ;
@@ -332,7 +326,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
332326 this . sendEvent ( new Event ( "log" , obj ) ) ;
333327 }
334328
335- private fundScriptByIndex ( index : number ) : LoadedScript | undefined {
329+ public findScriptByIndex ( index : number ) : LoadedScript | undefined {
336330 for ( const iterator of this . loadedScripts ) {
337331 if ( iterator [ "1" ] . index === index ) {
338332 return iterator [ "1" ] ;
@@ -347,7 +341,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
347341 response . body = {
348342 stackFrames : stacks . children . map ( child => {
349343 const root = < StackRootNode > child ;
350- const script = this . fundScriptByIndex ( root . scriptIndex ) ;
344+ const script = this . findScriptByIndex ( root . scriptIndex ) ;
351345 var source : Source | undefined ;
352346 if ( script ) {
353347 source = new Source ( path . basename ( script . path ) , this . resolvePath ( script . path ) ) ;
@@ -377,7 +371,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
377371 protected variablesRequest ( response : DebugProtocol . VariablesResponse , args : DebugProtocol . VariablesArguments ) : void {
378372 if ( this . break ) {
379373 const node = this . handles . get ( args . variablesReference ) ;
380- const ctx = { evaluator : this , handles : this . handles } ;
374+ const ctx = { evaluator : this , handles : this . handles , scriptManager : this } ;
381375 node . computeChildren ( ctx ) . then ( vars => {
382376 response . body = { variables : vars . map ( node => node . toVariable ( ctx ) ) } ;
383377 this . sendResponse ( response ) ;
@@ -410,7 +404,7 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
410404 protected evaluateRequest ( response : DebugProtocol . EvaluateResponse , args : DebugProtocol . EvaluateArguments ) : void {
411405 const stackId = args . frameId || 0 ;
412406 this . eval ( args . expression , stackId ) . then ( v => {
413- const ctx = { evaluator : this , handles : this . handles } ;
407+ const ctx = { evaluator : this , handles : this . handles , scriptManager : this } ;
414408 const variable = v . resultNode . children [ 0 ] . toVariable ( ctx ) ;
415409 response . body = {
416410 result : variable . name ,
0 commit comments