Various changes to bring pm.lua test closer to passing:

* New and complete character class support
 * string.gsub implemented
 * rawset implemented
 * lua_call added (based on lua_pcall)
 * lua_pop added
 * newCall removed; luaGetTable and luaSetTable in LFunction updated to
   use lua_call instead.
 * StandardTest changed to avoid an ArrayIndexOutOfBoundsException

Unfortunately I discovered a problem where execute() will loop around too
many times and call exec() with a call frame that has already completed.
This might be due to the lack of the "tailcalls" field in our CallInfo class
that the C version maintains?
This commit is contained in:
Ian Farmer
2007-09-24 04:35:53 +00:00
parent f801e648bb
commit ec11c472c8
8 changed files with 269 additions and 53 deletions

View File

@@ -11,10 +11,6 @@ public interface VM {
// ================ interfaces for performing calls
/** Prepare the VM stack for a new call with arguments to be pushed
*/
public void newCall();
/** Push an argument or return value onto the stack
*/
public void push( LValue value );
@@ -163,6 +159,13 @@ public interface VM {
*/
public void lua_error(String message);
/**
* Run the method on the stack, propagating any error that occurs.
* @param nArgs number of arguments on the stack
* @param nResults number of results on the stack
*/
public void lua_call(int nArgs, int nResults);
/**
* Run the method on the stack in protected mode.
* @param nArgs number of arguments on the stack
@@ -186,4 +189,9 @@ public interface VM {
* @return
*/
public LValue lua_tolvalue(int i);
/**
* Pop some number of items off the stack.
*/
public void lua_pop(int n);
}

View File

@@ -12,27 +12,18 @@ public class LFunction extends LValue {
}
public void luaSetTable(VM vm, LValue table, LValue key, LValue val) {
vm.newCall();
vm.push( this );
vm.push( table );
vm.push( key );
vm.push( val );
vm.setExpectedResultCount( 0 );
if ( this.luaStackCall( vm ) )
vm.execute();
else
vm.adjustResults();
vm.lua_call( 3, 0 );
}
public void luaGetTable(VM vm, LValue table, LValue key) {
vm.newCall();
vm.push( this );
vm.push( table );
vm.push( key );
vm.setExpectedResultCount( 1 );
if ( this.luaStackCall( vm ) )
vm.execute();
vm.adjustResults();
vm.lua_call( 2, 1 );
}
public LString luaGetType() {