Rework the main API"s that implement the calling convention. Provide utility methods to get arguments that were supplied, and provide return values. Add a VM interface to clarify the relationship between the VM, things that call the VM, and things that are called by the VM. Make the code more closely aligned with the C++ version.

This commit is contained in:
James Roseborough
2007-07-24 05:06:10 +00:00
parent 56f33b373d
commit 8bf4c82a12
17 changed files with 424 additions and 862 deletions

View File

@@ -1,7 +1,7 @@
package lua.io;
import lua.CallFrame;
import lua.StackState;
import lua.VM;
import lua.value.LFunction;
import lua.value.LValue;
@@ -9,14 +9,18 @@ public class Closure extends LFunction {
public LValue env;
public Proto p;
public UpVal[] upVals;
// TODO: change arg type to VM?
public Closure(StackState state, Proto p) {
this.env = state._G;
this.p = p;
upVals = new UpVal[p.nups];
}
// perform a lua call
public void luaStackCall(CallFrame call, int base, int top, int nresults) {
call.state.stackCall( this, base, top, nresults );
// called by vm when there is an OP_CALL
// in this case, we are on the stack,
// and simply need to cue the VM to treat it as a stack call
public void luaStackCall(VM vm) {
vm.stackCall();
}
}