Improve compatibility with luaj 1.0
This commit is contained in:
@@ -204,7 +204,7 @@ public class LuaC extends Lua implements LuaCompiler {
|
||||
lexstate.open_func(funcstate);
|
||||
/* main func. is always vararg */
|
||||
funcstate.f.is_vararg = LuaC.VARARG_ISVARARG;
|
||||
funcstate.f.source = (LuaString) LuaValue.valueOf("@"+name);
|
||||
funcstate.f.source = (LuaString) LuaValue.valueOf(name);
|
||||
lexstate.next(); /* read first token */
|
||||
lexstate.chunk();
|
||||
lexstate.check(LexState.TK_EOS);
|
||||
|
||||
@@ -204,7 +204,7 @@ public class PackageLib extends OneArgFunction {
|
||||
if ( e < 0 )
|
||||
e = fname.m_length;
|
||||
LuaString key = fname.substring(b, e);
|
||||
LuaValue val = table.get(key);
|
||||
LuaValue val = table.rawget(key);
|
||||
if ( val.isnil() ) { /* no such field? */
|
||||
LuaTable field = new LuaTable(); /* new table for field */
|
||||
table.set(key, field);
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
package org.luaj.vm2.vm1;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
@@ -55,9 +57,10 @@ public class Luajvm1CompatibilityTest extends TestCase {
|
||||
|
||||
private static InputStream open(String file) {
|
||||
try {
|
||||
String path = jarpath+file;
|
||||
URL url = new URL(path);
|
||||
return url.openStream();
|
||||
File f = new File(file);
|
||||
return f.exists()?
|
||||
new FileInputStream(f):
|
||||
new URL(jarpath+file).openStream();
|
||||
} catch ( Exception e ) {
|
||||
return null;
|
||||
}
|
||||
@@ -99,7 +102,7 @@ public class Luajvm1CompatibilityTest extends TestCase {
|
||||
if ( is == null )
|
||||
return LuaValue.valueOf("not found: "+file);
|
||||
try {
|
||||
return org.luaj.vm2.LoadState.load(is, name, env);
|
||||
return org.luaj.vm2.LoadState.load(is, file, env);
|
||||
} catch (IOException e) {
|
||||
return LuaValue.valueOf(e.toString());
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user