@@ -265,13 +265,15 @@ interface ComputeContext {
265265}
266266
267267export interface IStackNode {
268- parent ? : IStackNode ;
268+ parent : IStackNode | undefined ;
269269 read ( ctx : Context , buf : ByteArray ) : void ;
270270 toVariable ( ctx : ComputeContext ) : Variable ;
271271 computeChildren ( ctx : ComputeContext ) : Thenable < IStackNode [ ] > ;
272272}
273273
274274abstract class StackNode implements IStackNode {
275+ parent : IStackNode | undefined ;
276+
275277 abstract read ( ctx : Context , buf : ByteArray ) : void ;
276278
277279 abstract toVariable ( ctx : ComputeContext ) : Variable ;
@@ -326,8 +328,6 @@ export abstract class LuaXObjectValue extends StackNode {
326328 public type = "" ;
327329 public data = "" ;
328330
329- public parent ?: LuaXObjectValue ;
330-
331331 read ( ctx : Context , buf : ByteArray ) {
332332 this . name = buf . readString ( ) ;
333333 this . type = buf . readString ( ) ;
@@ -375,6 +375,7 @@ class LuaXTable extends LuaXObjectValue {
375375 const key = < LuaXObjectValue > readNode ( ctx , buf ) ;
376376 const value = < LuaXObjectValue > readNode ( ctx , buf ) ;
377377 value . name = key . toKeyString ( ) ;
378+ value . parent = this ;
378379 this . children . push ( value ) ;
379380 }
380381 }
@@ -385,19 +386,21 @@ class LuaXTable extends LuaXObjectValue {
385386 return Promise . resolve ( this . children ) ;
386387 }
387388 return new Promise ( ( resolve ) => {
388- ctx . evaluator . eval ( this . calcExpr ( ) ) . then ( value => {
389+ let expr = this . calcExpr ( ) ;
390+ ctx . evaluator . eval ( expr ) . then ( value => {
389391 const n = value . resultNode . children [ 0 ] ;
390392 if ( n instanceof LuaXTable ) {
391393 this . children = n . children ;
392- this . children . forEach ( node => node . parent = this ) ;
393- resolve ( n . children ) ;
394+ this . children . map ( c => c . parent = this ) ;
394395 }
396+ resolve ( this . children ) ;
395397 } ) ;
396398 } ) ;
397399 }
398400
399401 toVariable ( ctx : ComputeContext ) : DebugProtocol . Variable {
400- return { name : this . name , value : "table" , variablesReference : ctx . handles . create ( this ) , type :"object" } ;
402+ let ref = ctx . handles . create ( this ) ;
403+ return { name : "table" , value : "table" , variablesReference : ref , type :"object" } ;
401404 }
402405}
403406
0 commit comments