@@ -58,7 +58,7 @@ export class GenericEvaluator implements Evaluator {
5858 name : "Generic" ,
5959 priority : 1 ,
6060 } ,
61- data : await this . constructObjectFromVariablesReference ( reply . variablesReference , { } ) ,
61+ data : await this . constructObjectFromVariablesReference ( reply . variablesReference ) ,
6262 } ,
6363 }
6464 } else {
@@ -88,21 +88,24 @@ export class GenericEvaluator implements Evaluator {
8888 }
8989 }
9090
91- private async constructObjectFromVariablesReference ( variablesReference : number , knownObjects : { [ ref : number ] : any ; } ) : Promise < any > {
91+ private async constructObjectFromVariablesReference (
92+ variablesReference : number ,
93+ knownObjects : { [ ref : number ] : any ; } = { } ,
94+ recursionDepth : number = 0 ,
95+ maxRecursionDepth : number = 50 ,
96+ ) : Promise < any > {
9297 var result : any = { } ;
9398 knownObjects [ variablesReference ] = result ;
9499
95100 for ( const variable of await this . session . getVariables ( { variablesReference } ) ) {
96101 let child : any ;
97102
98- if ( variable . variablesReference > 0 ) {
99- if ( variable . variablesReference in knownObjects ) {
100- // If the object is known, we have a (potentially cyclic) reference
101- child = knownObjects [ variable . variablesReference ] ;
102- } else {
103- // Recurse on a new object
104- child = await this . constructObjectFromVariablesReference ( variable . variablesReference , knownObjects ) ;
105- }
103+ if ( variable . variablesReference > 0 && variable . variablesReference in knownObjects ) {
104+ // If the object is known, we have a (potentially cyclic) reference
105+ child = knownObjects [ variable . variablesReference ] ;
106+ } else if ( variable . variablesReference > 0 && recursionDepth < maxRecursionDepth ) {
107+ // Recurse on a new object
108+ child = await this . constructObjectFromVariablesReference ( variable . variablesReference , knownObjects , recursionDepth + 1 , maxRecursionDepth ) ;
106109 } else {
107110 // If there are no childs, just assign the value
108111 child = variable . value ;
0 commit comments