2007-06-08 05:11:37 +00:00
|
|
|
package lua.value;
|
|
|
|
|
|
2007-06-14 04:58:09 +00:00
|
|
|
import lua.Lua;
|
2007-06-08 05:11:37 +00:00
|
|
|
import lua.StackState;
|
|
|
|
|
|
|
|
|
|
abstract
|
|
|
|
|
public class LValue {
|
|
|
|
|
|
|
|
|
|
protected static LValue luaUnsupportedOperation() {
|
|
|
|
|
throw new java.lang.UnsupportedOperationException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// test if value is true
|
|
|
|
|
public boolean luaAsBoolean() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-11 04:30:03 +00:00
|
|
|
// perform a lua call, return number of results actually produced
|
2007-06-16 15:31:27 +00:00
|
|
|
public void luaStackCall(StackState state, int base, int top, int nresults) {
|
2007-06-08 05:11:37 +00:00
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for numbers
|
|
|
|
|
public LValue luaBinOpUnknown(int opcode, LValue lhs) {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for numbers
|
|
|
|
|
public LValue luaBinOpInteger(int opcode, int m_value) {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for numbers
|
|
|
|
|
public LValue luaBinOpDouble(int opcode, double m_value) {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-14 04:58:09 +00:00
|
|
|
// unsupported except for numbers, strings, and == with various combinations of Nil, Boolean, etc.
|
2007-06-10 19:49:47 +00:00
|
|
|
public boolean luaBinCmpUnknown(int opcode, LValue lhs) {
|
2007-06-14 04:58:09 +00:00
|
|
|
if ( opcode == Lua.OP_EQ )
|
|
|
|
|
return lhs == this;
|
|
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for strings
|
|
|
|
|
public boolean luaBinCmpString(int opcode, String rhs) {
|
|
|
|
|
if ( opcode == Lua.OP_EQ )
|
|
|
|
|
return false;
|
2007-06-10 19:49:47 +00:00
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for numbers
|
|
|
|
|
public boolean luaBinCmpInteger(int opcode, int rhs) {
|
2007-06-14 04:58:09 +00:00
|
|
|
if ( opcode == Lua.OP_EQ )
|
|
|
|
|
return false;
|
2007-06-10 19:49:47 +00:00
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unsupported except for numbers
|
|
|
|
|
public boolean luaBinCmpDouble(int opcode, double rhs) {
|
2007-06-14 04:58:09 +00:00
|
|
|
if ( opcode == Lua.OP_EQ )
|
|
|
|
|
return false;
|
2007-06-10 19:49:47 +00:00
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-08 05:11:37 +00:00
|
|
|
/** set a value in a table
|
|
|
|
|
*/
|
|
|
|
|
public void luaSetTable(LValue key, LValue value) {
|
|
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Get a value from a table */
|
|
|
|
|
public LValue luaGetTable(LValue value) {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Get the value as a String
|
|
|
|
|
*/
|
|
|
|
|
public String luaAsString() {
|
|
|
|
|
return super.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Override standard toString with lua String conversion by default */
|
|
|
|
|
public String toString() {
|
|
|
|
|
return luaAsString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Return value as an integer */
|
|
|
|
|
public int luaAsInt() {
|
|
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-06-10 19:49:47 +00:00
|
|
|
|
|
|
|
|
/** Arithmetic negative */
|
|
|
|
|
public LValue luaUnaryMinus() {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Built-in opcode LEN, for Strings and Tables */
|
|
|
|
|
public LValue luaLength() {
|
|
|
|
|
// TODO: call meta-method TM_LEN here
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-10 22:53:09 +00:00
|
|
|
/** Valid for tables */
|
|
|
|
|
public LValue luaPairs() {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-16 15:31:27 +00:00
|
|
|
/** Valid for tables */
|
|
|
|
|
public LValue luaGetMetatable() {
|
|
|
|
|
return luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Valid for tables */
|
|
|
|
|
public void luaSetMetatable(LValue metatable) {
|
|
|
|
|
luaUnsupportedOperation();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-08 05:11:37 +00:00
|
|
|
|
|
|
|
|
}
|