Fix basic class processing via metatables. Make print output more closely match that produces by C interpreter
This commit is contained in:
@@ -36,7 +36,7 @@ final class Builtin extends LFunction {
|
||||
switch ( id ) {
|
||||
case PRINT:
|
||||
for ( int i=base+1; i<top; i++ ) {
|
||||
System.out.print( String.valueOf(state.stack[i]) );
|
||||
System.out.print( state.stack[i].luaAsString() );
|
||||
System.out.print( "\t" );
|
||||
}
|
||||
System.out.println();
|
||||
@@ -53,7 +53,8 @@ final class Builtin extends LFunction {
|
||||
break;
|
||||
case SETMETATABLE:
|
||||
state.stack[base+1].luaSetMetatable(state.stack[base+2]);
|
||||
state.top = base;
|
||||
state.stack[base] = state.stack[base+1];
|
||||
state.top = base+1;
|
||||
break;
|
||||
default:
|
||||
luaUnsupportedOperation();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package lua.io;
|
||||
|
||||
import lua.StackState;
|
||||
import lua.value.LFunction;
|
||||
import lua.value.LValue;
|
||||
|
||||
public class Closure extends LValue {
|
||||
public class Closure extends LFunction {
|
||||
public LValue env;
|
||||
public Proto p;
|
||||
public UpVal[] upVals;
|
||||
@@ -19,8 +20,4 @@ public class Closure extends LValue {
|
||||
public void luaStackCall(StackState state, int base, int top, int nresults) {
|
||||
state.setupCall( this, base, top );
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "closure: "+hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Proto extends LValue {
|
||||
public int maxstacksize;
|
||||
|
||||
|
||||
public String toString() {
|
||||
return "proto: "+hashCode();
|
||||
public String luaAsString() {
|
||||
return "proto: "+id();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class UpVal {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "up("+name+")";
|
||||
return "up."+name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import lua.StackState;
|
||||
|
||||
public class LFunction extends LValue {
|
||||
|
||||
public String toString() {
|
||||
public String luaAsString() {
|
||||
return "function: "+hashCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,14 @@ public class LTable extends LValue {
|
||||
state.stack[base] = val;
|
||||
}
|
||||
|
||||
public String luaAsString() {
|
||||
public String toString() {
|
||||
return m_hash.toString();
|
||||
}
|
||||
|
||||
public String luaAsString() {
|
||||
return "table: "+id();
|
||||
}
|
||||
|
||||
/** Built-in opcode LEN, for Strings and Tables */
|
||||
public LValue luaLength() {
|
||||
return new LInteger( m_hash.size() );
|
||||
|
||||
@@ -9,6 +9,10 @@ public class LValue {
|
||||
protected static LValue luaUnsupportedOperation() {
|
||||
throw new java.lang.UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return Integer.toHexString(hashCode());
|
||||
}
|
||||
|
||||
// test if value is true
|
||||
public boolean luaAsBoolean() {
|
||||
|
||||
Reference in New Issue
Block a user