@@ -248,6 +248,7 @@ interface ComputeContext {
248248}
249249
250250export interface IStackNode {
251+ parent ?: IStackNode ;
251252 read ( ctx : Context , buf : ByteArray ) : void ;
252253 toVariable ( ctx : ComputeContext ) : Variable ;
253254 computeChildren ( ctx : ComputeContext ) : Thenable < IStackNode [ ] > ;
@@ -308,6 +309,8 @@ export abstract class LuaXObjectValue extends StackNode {
308309 public type = "" ;
309310 public data = "" ;
310311
312+ public parent ?: LuaXObjectValue ;
313+
311314 read ( ctx : Context , buf : ByteArray ) {
312315 this . name = buf . readString ( ) ;
313316 this . type = buf . readString ( ) ;
@@ -327,6 +330,25 @@ class LuaXTable extends LuaXObjectValue {
327330
328331 public children = new Array < IStackNode > ( ) ;
329332
333+ private calcExpr ( ) {
334+ var p : IStackNode | undefined = this ;
335+ var list = [ ] ;
336+ while ( p instanceof LuaXObjectValue ) {
337+ const name = p . name ;
338+ list . push ( name ) ;
339+ p = p . parent ;
340+ }
341+ const head = list . pop ( ) ;
342+ list = list . reverse ( ) . map ( n => {
343+ if ( n . startsWith ( '[' ) ) {
344+ return n ;
345+ } else {
346+ return `["${ n } "]` ;
347+ }
348+ } ) ;
349+ return head + list . join ( "" ) ;
350+ }
351+
330352 read ( ctx : Context , buf : ByteArray ) {
331353 super . read ( ctx , buf ) ;
332354 const deep = buf . readBoolean ( ) ;
@@ -346,10 +368,11 @@ class LuaXTable extends LuaXObjectValue {
346368 return Promise . resolve ( this . children ) ;
347369 }
348370 return new Promise ( ( resolve ) => {
349- ctx . evaluator . eval ( this . name , 0 ) . then ( value => {
371+ ctx . evaluator . eval ( this . calcExpr ( ) , 0 ) . then ( value => {
350372 const n = value . resultNode . children [ 0 ] ;
351373 if ( n instanceof LuaXTable ) {
352374 this . children = n . children ;
375+ this . children . forEach ( node => node . parent = this ) ;
353376 resolve ( n . children ) ;
354377 }
355378 } ) ;
0 commit comments