Fix LuaState.getglobal() and LuaState.setglobal() to use the currently closure's environment.
This commit is contained in:
@@ -1347,9 +1347,7 @@ public class LuaState extends Lua {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public void getglobal(String s) {
|
public void getglobal(String s) {
|
||||||
LTable t = this._G;
|
LTable t = calls[cc].closure.env;
|
||||||
// TODO: what if this triggers metatable ops
|
|
||||||
// pushlvalue( t.luaGetTable(this, t, new LString(s)));
|
|
||||||
t.luaGetTable(this, t, new LString(s));
|
t.luaGetTable(this, t, new LString(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2022,7 +2020,7 @@ public class LuaState extends Lua {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public void setglobal(String name) {
|
public void setglobal(String name) {
|
||||||
LTable g = this._G;
|
LTable g = calls[cc].closure.env;
|
||||||
LValue v = poplvalue();
|
LValue v = poplvalue();
|
||||||
g.luaSetTable(this, g, new LString(name), v);
|
g.luaSetTable(this, g, new LString(name), v);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user