Fix autoload

This commit is contained in:
James Roseborough
2007-09-22 07:14:23 +00:00
parent e154a158a9
commit e07382c90d
3 changed files with 7 additions and 4 deletions

View File

@@ -454,6 +454,7 @@ public class LuaCompat extends LFunction {
// return true if laoded, false if error put onto the stack // return true if laoded, false if error put onto the stack
private static boolean loadis(VM vm, InputStream is, String chunkname ) { private static boolean loadis(VM vm, InputStream is, String chunkname ) {
try { try {
vm.setResult();
if ( 0 != vm.lua_load(is, chunkname) ) { if ( 0 != vm.lua_load(is, chunkname) ) {
vm.setErrorResult( LNil.NIL, "cannot load "+chunkname+": "+vm.lua_tolvalue(-1) ); vm.setErrorResult( LNil.NIL, "cannot load "+chunkname+": "+vm.lua_tolvalue(-1) );
return false; return false;
@@ -467,7 +468,7 @@ public class LuaCompat extends LFunction {
// return true if loaded, false if error put onto stack // return true if loaded, false if error put onto stack
public static boolean loadfile( VM vm, String fileName ) { private static boolean loadfile( VM vm, String fileName ) {
InputStream is; InputStream is;
String script; String script;

View File

@@ -32,8 +32,7 @@ public class LFunction extends LValue {
vm.setExpectedResultCount( 1 ); vm.setExpectedResultCount( 1 );
if ( this.luaStackCall( vm ) ) if ( this.luaStackCall( vm ) )
vm.execute(); vm.execute();
else vm.adjustResults();
vm.adjustResults();
} }
public LString luaGetType() { public LString luaGetType() {

View File

@@ -5,6 +5,8 @@ import java.io.InputStream;
import lua.StackState; import lua.StackState;
import lua.VM; import lua.VM;
import lua.addon.luacompat.LuaCompat; import lua.addon.luacompat.LuaCompat;
import lua.addon.luajava.LuaJava;
import lua.debug.DebugStackState;
import lua.io.Closure; import lua.io.Closure;
import lua.io.LoadState; import lua.io.LoadState;
import lua.io.Proto; import lua.io.Proto;
@@ -25,9 +27,10 @@ public class LuacRunner {
// add LuaCompat bindings // add LuaCompat bindings
LuaCompat.install(); LuaCompat.install();
LuaJava.install();
// new lua state // new lua state
StackState state = new StackState(); StackState state = new DebugStackState();
VM vm = state; VM vm = state;
// load the file // load the file