Fixes to luajc bytecode generation.
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2;
|
||||
|
||||
import org.luaj.vm2.lib.DebugLib;
|
||||
|
||||
/**
|
||||
* Extension of {@link LuaFunction} which executes lua bytecode.
|
||||
* <p>
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2;
|
||||
|
||||
import org.luaj.vm2.Varargs.SubVarargs;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for all concrete lua type values.
|
||||
* <p>
|
||||
@@ -432,7 +429,7 @@ public class LuaValue extends Varargs {
|
||||
*/
|
||||
public boolean isuserdata(Class c) { return false; }
|
||||
|
||||
/** Convert to boolean false if {@link #NIL} or {@link FALSE}, true if anything else
|
||||
/** Convert to boolean false if {@link #NIL} or {@link #FALSE}, true if anything else
|
||||
* @return Value cast to byte if number or string convertible to number, otherwise 0
|
||||
* @see #optboolean(boolean)
|
||||
* @see #checkboolean()
|
||||
|
||||
@@ -105,11 +105,12 @@ public class LuaJC implements LuaCompiler {
|
||||
|
||||
private static String toStandardJavaClassName( String luachunkname ) {
|
||||
String stub = toStub( luachunkname );
|
||||
String classname = stub.replace('/','.').replaceAll(NON_IDENTIFIER, "_");
|
||||
int c = classname.charAt(0);
|
||||
if ( c!='_' && !Character.isJavaIdentifierStart(c) )
|
||||
classname = "_"+classname;
|
||||
return classname;
|
||||
StringBuffer classname = new StringBuffer();
|
||||
for (int i = 0, n = stub.length(); i < n; ++i) {
|
||||
final char c = stub.charAt(i);
|
||||
classname.append((((i == 0) && Character.isJavaIdentifierStart(c)) || ((i > 0) && Character.isJavaIdentifierPart(c)))? c: '_');
|
||||
}
|
||||
return classname.toString();
|
||||
}
|
||||
|
||||
private static String toStandardLuaFileName( String luachunkname ) {
|
||||
|
||||
@@ -26,13 +26,13 @@ public class ProtoInfo {
|
||||
// A main chunk proto info.
|
||||
public ProtoInfo(Prototype p, String name) {
|
||||
// For the outer chunk, we have one upvalue which is the environment.
|
||||
this(p,name,new UpvalInfo[] { new UpvalInfo() });
|
||||
this(p,name,null);
|
||||
}
|
||||
|
||||
private ProtoInfo(Prototype p, String name, UpvalInfo[] u) {
|
||||
this.name = name;
|
||||
this.prototype = p;
|
||||
this.upvals = u;
|
||||
this.upvals = u != null? u: new UpvalInfo[] { new UpvalInfo(this) };
|
||||
this.subprotos = p.p!=null&&p.p.length>0? new ProtoInfo[p.p.length]: null;
|
||||
|
||||
// find basic blocks
|
||||
@@ -364,6 +364,10 @@ public class ProtoInfo {
|
||||
break;
|
||||
|
||||
case Lua.OP_JMP: /* sBx pc+=sBx */
|
||||
a = Lua.GETARG_A( ins );
|
||||
if (a > 0)
|
||||
for ( --a; a<m; a++ )
|
||||
v[a][pc] = VarInfo.INVALID;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -13,9 +13,12 @@ public class UpvalInfo {
|
||||
boolean rw; // read-write
|
||||
|
||||
// Upval info representing the implied context containing only the environment.
|
||||
public UpvalInfo() {
|
||||
nvars = 1;
|
||||
var = new VarInfo[] { VarInfo.PARAM(0) };
|
||||
public UpvalInfo(ProtoInfo pi) {
|
||||
this.pi = pi;
|
||||
this.slot = 0;
|
||||
this.nvars = 1;
|
||||
this.var = new VarInfo[] { VarInfo.PARAM(0) };
|
||||
this.rw = false;
|
||||
}
|
||||
|
||||
public UpvalInfo(ProtoInfo pi, int pc, int slot) {
|
||||
|
||||
Reference in New Issue
Block a user