|
2 | 2 | #include "emmy_debugger/emmy_facade.h" |
3 | 3 |
|
4 | 4 | std::string ExtensionPoint::ExtensionTable = "emmyHelper"; |
5 | | - |
| 5 | +Arena<Variable> *ExtensionPoint::Arena = nullptr; |
6 | 6 |
|
7 | 7 | int metaQuery(lua_State *L) { |
8 | 8 | const int argN = lua_gettop(L); |
@@ -79,20 +79,14 @@ void pushVariable(lua_State *L, Idx<Variable> variable) { |
79 | 79 | lua_setmetatable(L, -2); |
80 | 80 | } |
81 | 81 |
|
82 | | -void setArena(lua_State *L, Arena<Variable> *arena) { |
83 | | - lua_pushstring(L, "EMMY_ARENA"); |
84 | | - lua_pushlightuserdata(L, arena); |
85 | | - lua_rawset(L, LUA_REGISTRYINDEX); |
86 | | -} |
87 | | - |
88 | 82 | int createNode(lua_State *L) { |
89 | | - lua_pushstring(L, "EMMY_ARENA"); |
90 | | - lua_rawget(L, LUA_REGISTRYINDEX); |
91 | | - auto arena = (Arena<Variable>*) lua_touserdata(L, -1); |
92 | | - lua_pop(L, 1); |
93 | | - auto idx = arena->Alloc(); |
94 | | - pushVariable(L, idx); |
95 | | - return 1; |
| 83 | + if (ExtensionPoint::Arena) { |
| 84 | + auto idx = ExtensionPoint::Arena->Alloc(); |
| 85 | + pushVariable(L, idx); |
| 86 | + return 1; |
| 87 | + } else { |
| 88 | + return 0; |
| 89 | + } |
96 | 90 | } |
97 | 91 |
|
98 | 92 | ExtensionPoint::ExtensionPoint() { |
@@ -137,6 +131,7 @@ bool ExtensionPoint::QueryVariable(lua_State *L, Idx<Variable> variable, const c |
137 | 131 | if (lua_istable(L, -1)) { |
138 | 132 | lua_getfield(L, -1, "queryVariable"); |
139 | 133 | if (lua_isfunction(L, -1)) { |
| 134 | + ExtensionPoint::Arena = variable.GetArena(); |
140 | 135 | pushVariable(L, variable); |
141 | 136 | lua_pushvalue(L, object); |
142 | 137 | lua_pushstring(L, typeName); |
|
0 commit comments