Fix __index and __newindex metatable operations when there are no calls on the call stack.
This commit is contained in:
@@ -76,7 +76,7 @@ public class LFunction extends LValue {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LValue __index(LuaState vm, LValue table, LValue key) {
|
public LValue __index(LuaState vm, LValue table, LValue key) {
|
||||||
return vm.call(this, table, key);
|
return vm.luaV_call_index(this, table, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +89,7 @@ public class LFunction extends LValue {
|
|||||||
* @param val
|
* @param val
|
||||||
*/
|
*/
|
||||||
public void __newindex(LuaState vm, LValue table, LValue key, LValue val) {
|
public void __newindex(LuaState vm, LValue table, LValue key, LValue val) {
|
||||||
vm.call(this, table, key, val);
|
vm.luaV_call_newindex(this, table, key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2250,55 +2250,47 @@ public class LuaState extends Lua {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a function with no arguments and one return value
|
* Call a function with no arguments and one return value.
|
||||||
|
* This may change values in the current stack frame.
|
||||||
* @param function
|
* @param function
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LValue call(LFunction function) {
|
public LValue call(LFunction function) {
|
||||||
int oldtop = top;
|
|
||||||
try {
|
|
||||||
top = base + this.calls[cc].closure.p.maxstacksize;
|
|
||||||
pushlvalue(function);
|
pushlvalue(function);
|
||||||
call(0,1);
|
call(0,1);
|
||||||
return poplvalue();
|
return poplvalue();
|
||||||
} finally {
|
|
||||||
top = oldtop;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a function with one argument and one return value
|
* Call a function with one argument and one return value
|
||||||
|
* This may change values in the current stack frame.
|
||||||
* @param function
|
* @param function
|
||||||
* @param arg0
|
* @param arg0
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LValue call(LFunction function, LValue arg0) {
|
public LValue call(LFunction function, LValue arg0) {
|
||||||
int oldtop = top;
|
|
||||||
try {
|
|
||||||
top = base + this.calls[cc].closure.p.maxstacksize;
|
|
||||||
pushlvalue(function);
|
pushlvalue(function);
|
||||||
pushlvalue(arg0);
|
pushlvalue(arg0);
|
||||||
call(1,1);
|
call(1,1);
|
||||||
return poplvalue();
|
return poplvalue();
|
||||||
} finally {
|
|
||||||
top = oldtop;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a function with two arguments and one return value
|
* Call an index function with two arguments and one return value
|
||||||
* @param function
|
* Values in the current stack frame will be preserved.
|
||||||
* @param arg0
|
* @param function the __index function to call
|
||||||
* @param arg1
|
* @param table the table on which the metadata operation is taking place
|
||||||
* @return
|
* @param key the key used in the index operation
|
||||||
|
* @return the value that results from the metatable operation
|
||||||
*/
|
*/
|
||||||
public LValue call(LFunction function, LValue arg0, LValue arg1) {
|
public LValue luaV_call_index(LFunction function, LValue table, LValue key) {
|
||||||
int oldtop = top;
|
int oldtop = top;
|
||||||
try {
|
try {
|
||||||
|
if ( cc >= 0 )
|
||||||
top = base + this.calls[cc].closure.p.maxstacksize;
|
top = base + this.calls[cc].closure.p.maxstacksize;
|
||||||
pushlvalue(function);
|
pushlvalue(function);
|
||||||
pushlvalue(arg0);
|
pushlvalue(table);
|
||||||
pushlvalue(arg1);
|
pushlvalue(key);
|
||||||
call(2,1);
|
call(2,1);
|
||||||
return poplvalue();
|
return poplvalue();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2307,21 +2299,23 @@ public class LuaState extends Lua {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a function with three arguments and one return value
|
* Call a newindex function with three arguments and one return value
|
||||||
* @param function
|
* Values in the current stack frame will be preserved.
|
||||||
* @param arg0
|
* @param function the __newindex function to call
|
||||||
* @param arg1
|
* @param table the table on which the metadata operation is taking place
|
||||||
* @param arg2
|
* @param key the key used in the newindex operation
|
||||||
* @return
|
* @param value the value beting set in the newindex operation
|
||||||
|
* @return the value that results from the metatable operation
|
||||||
*/
|
*/
|
||||||
public LValue call(LFunction function, LValue arg0, LValue arg1, LValue arg2) {
|
public LValue luaV_call_newindex(LFunction function, LValue table, LValue key, LValue value) {
|
||||||
int oldtop = top;
|
int oldtop = top;
|
||||||
try {
|
try {
|
||||||
|
if ( cc >= 0 )
|
||||||
top = base + this.calls[cc].closure.p.maxstacksize;
|
top = base + this.calls[cc].closure.p.maxstacksize;
|
||||||
pushlvalue(function);
|
pushlvalue(function);
|
||||||
pushlvalue(arg0);
|
pushlvalue(table);
|
||||||
pushlvalue(arg1);
|
pushlvalue(key);
|
||||||
pushlvalue(arg2);
|
pushlvalue(value);
|
||||||
call(3,1);
|
call(3,1);
|
||||||
return poplvalue();
|
return poplvalue();
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user