| 603 | |
| 604 | |
| 605 | bool GetStackVariables(lua_State *L, int32 StackLevel, TArray<FLuaVariable> &LocalVariables, TArray<FLuaVariable> &Upvalues, int32 Level) |
| 606 | { |
| 607 | if (!L) |
| 608 | { |
| 609 | return false; |
| 610 | } |
| 611 | lua_Debug ar; |
| 612 | if (!lua_getstack(L, StackLevel, &ar)) |
| 613 | { |
| 614 | return false; |
| 615 | } |
| 616 | if (!lua_getinfo(L, "nSlu", &ar)) |
| 617 | { |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | for (int32 i = 1; ; ++i) |
| 622 | { |
| 623 | const char *VarName = lua_getlocal(L, &ar, i); |
| 624 | if (!VarName) |
| 625 | { |
| 626 | break; |
| 627 | } |
| 628 | if (VarName[0] == '(') |
| 629 | { |
| 630 | lua_pop(L, 1); |
| 631 | continue; |
| 632 | } |
| 633 | LocalVariables.AddDefaulted(); |
| 634 | FLuaVariable &Variable = LocalVariables.Top(); |
| 635 | Variable.Key = UTF8_TO_TCHAR(VarName); |
| 636 | Variable.Value.Depth = 0; |
| 637 | Variable.Value.Build(L, -1, Level); |
| 638 | lua_pop(L, 1); |
| 639 | } |
| 640 | |
| 641 | if (lua_getinfo(L, "f", &ar)) |
| 642 | { |
| 643 | int32 FunctionIdx = lua_gettop(L); |
| 644 | for (int32 i = 1; ; ++i) |
| 645 | { |
| 646 | const char *UpvalueName = lua_getupvalue(L, FunctionIdx, i); |
| 647 | if (!UpvalueName) |
| 648 | { |
| 649 | break; |
| 650 | } |
| 651 | Upvalues.AddDefaulted(); |
| 652 | FLuaVariable &Upvalue = Upvalues.Top(); |
| 653 | Upvalue.Key = UTF8_TO_TCHAR(UpvalueName); |
| 654 | Upvalue.Value.Depth = 0; |
| 655 | Upvalue.Value.Build(L, -1, Level); |
| 656 | lua_pop(L, 1); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | return true; |
| 661 | } |
| 662 |
nothing calls this directly
no test coverage detected